| OLD | NEW |
| 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/browser_feature_extractor.h" | 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 13 #include "base/location.h" |
| 14 #include "base/single_thread_task_runner.h" |
| 13 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 14 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 16 #include "chrome/browser/history/history_service_factory.h" | 19 #include "chrome/browser/history/history_service_factory.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/safe_browsing/browser_features.h" | 21 #include "chrome/browser/safe_browsing/browser_features.h" |
| 19 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | 22 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| 20 #include "chrome/browser/safe_browsing/database_manager.h" | 23 #include "chrome/browser/safe_browsing/database_manager.h" |
| 21 #include "chrome/common/safe_browsing/csd.pb.h" | 24 #include "chrome/common/safe_browsing/csd.pb.h" |
| 22 #include "components/history/core/browser/history_service.h" | 25 #include "components/history/core/browser/history_service.h" |
| 23 #include "components/history/core/browser/history_types.h" | 26 #include "components/history/core/browser/history_types.h" |
| 24 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 first_host_index, | 232 first_host_index, |
| 230 info->host_redirects, | 233 info->host_redirects, |
| 231 request); | 234 request); |
| 232 } | 235 } |
| 233 | 236 |
| 234 // The API doesn't take a scoped_ptr because the API gets mocked and we | 237 // The API doesn't take a scoped_ptr because the API gets mocked and we |
| 235 // cannot mock an API that takes scoped_ptr as arguments. | 238 // cannot mock an API that takes scoped_ptr as arguments. |
| 236 scoped_ptr<ClientPhishingRequest> req(request); | 239 scoped_ptr<ClientPhishingRequest> req(request); |
| 237 | 240 |
| 238 ExtractBrowseInfoFeatures(*info, request); | 241 ExtractBrowseInfoFeatures(*info, request); |
| 239 base::MessageLoop::current()->PostTask( | 242 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 240 FROM_HERE, | 243 FROM_HERE, |
| 241 base::Bind(&BrowserFeatureExtractor::StartExtractFeatures, | 244 base::Bind(&BrowserFeatureExtractor::StartExtractFeatures, |
| 242 weak_factory_.GetWeakPtr(), | 245 weak_factory_.GetWeakPtr(), base::Passed(&req), callback)); |
| 243 base::Passed(&req), | |
| 244 callback)); | |
| 245 } | 246 } |
| 246 | 247 |
| 247 void BrowserFeatureExtractor::ExtractMalwareFeatures( | 248 void BrowserFeatureExtractor::ExtractMalwareFeatures( |
| 248 BrowseInfo* info, | 249 BrowseInfo* info, |
| 249 ClientMalwareRequest* request, | 250 ClientMalwareRequest* request, |
| 250 const MalwareDoneCallback& callback) { | 251 const MalwareDoneCallback& callback) { |
| 251 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 252 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 252 DCHECK(!callback.is_null()); | 253 DCHECK(!callback.is_null()); |
| 253 | 254 |
| 254 // Grab the IPs because they might go away before we're done | 255 // Grab the IPs because they might go away before we're done |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // Limit the number of matched bad IPs in one request to control | 483 // Limit the number of matched bad IPs in one request to control |
| 483 // the request's size | 484 // the request's size |
| 484 if (matched_bad_ips >= kMaxMalwareIPPerRequest) { | 485 if (matched_bad_ips >= kMaxMalwareIPPerRequest) { |
| 485 break; | 486 break; |
| 486 } | 487 } |
| 487 } | 488 } |
| 488 callback.Run(true, request.Pass()); | 489 callback.Run(true, request.Pass()); |
| 489 } | 490 } |
| 490 | 491 |
| 491 } // namespace safe_browsing | 492 } // namespace safe_browsing |
| OLD | NEW |