Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/safe_browsing/client_side_detection_service.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/client_side_detection_service.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 client_malware_reports_.end()); 157 client_malware_reports_.end());
158 client_malware_reports_.clear(); 158 client_malware_reports_.clear();
159 cache_.clear(); 159 cache_.clear();
160 } 160 }
161 } 161 }
162 162
163 void ClientSideDetectionService::SendClientReportPhishingRequest( 163 void ClientSideDetectionService::SendClientReportPhishingRequest(
164 ClientPhishingRequest* verdict, 164 ClientPhishingRequest* verdict,
165 const ClientReportPhishingRequestCallback& callback) { 165 const ClientReportPhishingRequestCallback& callback) {
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
167 MessageLoop::current()->PostTask( 167 base::MessageLoop::current()->PostTask(
168 FROM_HERE, 168 FROM_HERE,
169 base::Bind(&ClientSideDetectionService::StartClientReportPhishingRequest, 169 base::Bind(&ClientSideDetectionService::StartClientReportPhishingRequest,
170 weak_factory_.GetWeakPtr(), verdict, callback)); 170 weak_factory_.GetWeakPtr(), verdict, callback));
171 } 171 }
172 172
173 void ClientSideDetectionService::SendClientReportMalwareRequest( 173 void ClientSideDetectionService::SendClientReportMalwareRequest(
174 ClientMalwareRequest* verdict, 174 ClientMalwareRequest* verdict,
175 const ClientReportMalwareRequestCallback& callback) { 175 const ClientReportMalwareRequestCallback& callback) {
176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
177 MessageLoop::current()->PostTask( 177 base::MessageLoop::current()->PostTask(
178 FROM_HERE, 178 FROM_HERE,
179 base::Bind(&ClientSideDetectionService::StartClientReportMalwareRequest, 179 base::Bind(&ClientSideDetectionService::StartClientReportMalwareRequest,
180 weak_factory_.GetWeakPtr(), verdict, callback)); 180 weak_factory_.GetWeakPtr(), verdict, callback));
181 } 181 }
182 182
183 bool ClientSideDetectionService::IsPrivateIPAddress( 183 bool ClientSideDetectionService::IsPrivateIPAddress(
184 const std::string& ip_address) const { 184 const std::string& ip_address) const {
185 net::IPAddressNumber ip_number; 185 net::IPAddressNumber ip_number;
186 if (!net::ParseIPLiteralToNumber(ip_address, &ip_number)) { 186 if (!net::ParseIPLiteralToNumber(ip_address, &ip_number)) {
187 VLOG(2) << "Unable to parse IP address: '" << ip_address << "'"; 187 VLOG(2) << "Unable to parse IP address: '" << ip_address << "'";
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 content::RenderProcessHost::AllHostsIterator()); 287 content::RenderProcessHost::AllHostsIterator());
288 !i.IsAtEnd(); i.Advance()) { 288 !i.IsAtEnd(); i.Advance()) {
289 SendModelToProcess(i.GetCurrentValue()); 289 SendModelToProcess(i.GetCurrentValue());
290 } 290 }
291 } 291 }
292 292
293 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { 293 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) {
294 if (CommandLine::ForCurrentProcess()->HasSwitch( 294 if (CommandLine::ForCurrentProcess()->HasSwitch(
295 switches::kSbDisableAutoUpdate)) 295 switches::kSbDisableAutoUpdate))
296 return; 296 return;
297 MessageLoop::current()->PostDelayedTask( 297 base::MessageLoop::current()->PostDelayedTask(
298 FROM_HERE, 298 FROM_HERE,
299 base::Bind(&ClientSideDetectionService::StartFetchModel, 299 base::Bind(&ClientSideDetectionService::StartFetchModel,
300 weak_factory_.GetWeakPtr()), 300 weak_factory_.GetWeakPtr()),
301 base::TimeDelta::FromMilliseconds(delay_ms)); 301 base::TimeDelta::FromMilliseconds(delay_ms));
302 } 302 }
303 303
304 void ClientSideDetectionService::StartFetchModel() { 304 void ClientSideDetectionService::StartFetchModel() {
305 if (enabled_) { 305 if (enabled_) {
306 // Start fetching the model either from the cache or possibly from the 306 // Start fetching the model either from the cache or possibly from the
307 // network if the model isn't in the cache. 307 // network if the model isn't in the cache.
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 const std::string& report_url) { 686 const std::string& report_url) {
687 std::string url = report_url; 687 std::string url = report_url;
688 std::string api_key = google_apis::GetAPIKey(); 688 std::string api_key = google_apis::GetAPIKey();
689 if (!api_key.empty()) { 689 if (!api_key.empty()) {
690 base::StringAppendF(&url, "?key=%s", 690 base::StringAppendF(&url, "?key=%s",
691 net::EscapeQueryParamValue(api_key, true).c_str()); 691 net::EscapeQueryParamValue(api_key, true).c_str());
692 } 692 }
693 return url; 693 return url;
694 } 694 }
695 } // namespace safe_browsing 695 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698