OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/safe_browsing/incident_reporting/resource_request_detec
tor.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/resource_request_detec
tor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 OnResultCallback; | 66 OnResultCallback; |
67 | 67 |
68 ResourceRequestDetectorClient( | 68 ResourceRequestDetectorClient( |
69 const GURL& resource_url, | 69 const GURL& resource_url, |
70 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, | 70 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, |
71 const OnResultCallback& callback) | 71 const OnResultCallback& callback) |
72 : database_manager_(database_manager) | 72 : database_manager_(database_manager) |
73 , callback_(callback) { | 73 , callback_(callback) { |
74 content::BrowserThread::PostTask( | 74 content::BrowserThread::PostTask( |
75 content::BrowserThread::IO, FROM_HERE, | 75 content::BrowserThread::IO, FROM_HERE, |
76 base::Bind(&ResourceRequestDetectorClient::StartCheck, this, | 76 base::BindOnce(&ResourceRequestDetectorClient::StartCheck, this, |
77 resource_url)); | 77 resource_url)); |
78 } | 78 } |
79 | 79 |
80 private: | 80 private: |
81 friend class base::RefCountedThreadSafe<ResourceRequestDetectorClient>; | 81 friend class base::RefCountedThreadSafe<ResourceRequestDetectorClient>; |
82 ~ResourceRequestDetectorClient() override {} | 82 ~ResourceRequestDetectorClient() override {} |
83 | 83 |
84 void StartCheck(const GURL& resource_url) { | 84 void StartCheck(const GURL& resource_url) { |
85 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 85 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
86 if (!database_manager_) | 86 if (!database_manager_) |
87 return; | 87 return; |
(...skipping 12 matching lines...) Expand all Loading... |
100 void OnCheckResourceUrlResult(const GURL& url, | 100 void OnCheckResourceUrlResult(const GURL& url, |
101 SBThreatType threat_type, | 101 SBThreatType threat_type, |
102 const std::string& threat_hash) override { | 102 const std::string& threat_hash) override { |
103 if (threat_type == SB_THREAT_TYPE_BLACKLISTED_RESOURCE) { | 103 if (threat_type == SB_THREAT_TYPE_BLACKLISTED_RESOURCE) { |
104 std::unique_ptr<ResourceRequestIncidentMessage> incident_data( | 104 std::unique_ptr<ResourceRequestIncidentMessage> incident_data( |
105 new ResourceRequestIncidentMessage()); | 105 new ResourceRequestIncidentMessage()); |
106 incident_data->set_type(ResourceRequestIncidentMessage::TYPE_PATTERN); | 106 incident_data->set_type(ResourceRequestIncidentMessage::TYPE_PATTERN); |
107 incident_data->set_digest(threat_hash); | 107 incident_data->set_digest(threat_hash); |
108 content::BrowserThread::PostTask( | 108 content::BrowserThread::PostTask( |
109 content::BrowserThread::UI, FROM_HERE, | 109 content::BrowserThread::UI, FROM_HERE, |
110 base::Bind(callback_, base::Passed(&incident_data))); | 110 base::BindOnce(callback_, base::Passed(&incident_data))); |
111 } | 111 } |
112 Release(); // Balanced in StartCheck. | 112 Release(); // Balanced in StartCheck. |
113 } | 113 } |
114 | 114 |
115 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 115 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
116 OnResultCallback callback_; | 116 OnResultCallback callback_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(ResourceRequestDetectorClient); | 118 DISALLOW_COPY_AND_ASSIGN(ResourceRequestDetectorClient); |
119 }; | 119 }; |
120 | 120 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 if (host_url.is_valid()) | 180 if (host_url.is_valid()) |
181 incident_data->set_origin(host_url.GetOrigin().spec()); | 181 incident_data->set_origin(host_url.GetOrigin().spec()); |
182 | 182 |
183 incident_receiver_->AddIncidentForProfile( | 183 incident_receiver_->AddIncidentForProfile( |
184 profile, | 184 profile, |
185 base::MakeUnique<ResourceRequestIncident>(std::move(incident_data))); | 185 base::MakeUnique<ResourceRequestIncident>(std::move(incident_data))); |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 } // namespace safe_browsing | 189 } // namespace safe_browsing |
OLD | NEW |