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

Side by Side Diff: components/safe_browsing_db/remote_database_manager.cc

Issue 2648193002: SafeBrowsing: Move enabled_ to base class DB Manager (Closed)
Patch Set: Fix compile error Created 3 years, 11 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
OLDNEW
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 "components/safe_browsing_db/remote_database_manager.h" 5 #include "components/safe_browsing_db/remote_database_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 UMA_HISTOGRAM_TIMES("SB2.RemoteCall.Elapsed", timer_.Elapsed()); 91 UMA_HISTOGRAM_TIMES("SB2.RemoteCall.Elapsed", timer_.Elapsed());
92 // CancelCheck() will delete *this. 92 // CancelCheck() will delete *this.
93 db_manager_->CancelCheck(client_); 93 db_manager_->CancelCheck(client_);
94 } 94 }
95 95
96 // 96 //
97 // RemoteSafeBrowsingDatabaseManager methods 97 // RemoteSafeBrowsingDatabaseManager methods
98 // 98 //
99 99
100 // TODO(nparker): Add more tests for this class 100 // TODO(nparker): Add more tests for this class
101 RemoteSafeBrowsingDatabaseManager::RemoteSafeBrowsingDatabaseManager() 101 RemoteSafeBrowsingDatabaseManager::RemoteSafeBrowsingDatabaseManager() {
102 : enabled_(false) {
103 // Decide which resource types to check. These two are the minimum. 102 // Decide which resource types to check. These two are the minimum.
104 resource_types_to_check_.insert(content::RESOURCE_TYPE_MAIN_FRAME); 103 resource_types_to_check_.insert(content::RESOURCE_TYPE_MAIN_FRAME);
105 resource_types_to_check_.insert(content::RESOURCE_TYPE_SUB_FRAME); 104 resource_types_to_check_.insert(content::RESOURCE_TYPE_SUB_FRAME);
106 105
107 // The param is expected to be a comma-separated list of ints 106 // The param is expected to be a comma-separated list of ints
108 // corresponding to the enum types. We're keeping this finch 107 // corresponding to the enum types. We're keeping this finch
109 // control around so we can add back types if they later become dangerous. 108 // control around so we can add back types if they later become dangerous.
110 const std::string ints_str = variations::GetVariationParamValue( 109 const std::string ints_str = variations::GetVariationParamValue(
111 kAndroidFieldExperiment, kAndroidTypesToCheckParam); 110 kAndroidFieldExperiment, kAndroidTypesToCheckParam);
112 if (ints_str.empty()) { 111 if (ints_str.empty()) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 272
274 bool RemoteSafeBrowsingDatabaseManager::IsSupported() const { 273 bool RemoteSafeBrowsingDatabaseManager::IsSupported() const {
275 return SafeBrowsingApiHandler::GetInstance() != nullptr; 274 return SafeBrowsingApiHandler::GetInstance() != nullptr;
276 } 275 }
277 276
278 void RemoteSafeBrowsingDatabaseManager::StartOnIOThread( 277 void RemoteSafeBrowsingDatabaseManager::StartOnIOThread(
279 net::URLRequestContextGetter* request_context_getter, 278 net::URLRequestContextGetter* request_context_getter,
280 const V4ProtocolConfig& config) { 279 const V4ProtocolConfig& config) {
281 VLOG(1) << "RemoteSafeBrowsingDatabaseManager starting"; 280 VLOG(1) << "RemoteSafeBrowsingDatabaseManager starting";
282 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config); 281 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config);
283 enabled_ = true;
284 } 282 }
285 283
286 void RemoteSafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { 284 void RemoteSafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) {
287 // |shutdown| is not used. 285 // |shutdown| is not used.
288 DCHECK_CURRENTLY_ON(BrowserThread::IO); 286 DCHECK_CURRENTLY_ON(BrowserThread::IO);
289 DVLOG(1) << "RemoteSafeBrowsingDatabaseManager stopping"; 287 DVLOG(1) << "RemoteSafeBrowsingDatabaseManager stopping";
290 288
291 // Call back and delete any remaining clients. OnRequestDone() modifies 289 // Call back and delete any remaining clients. OnRequestDone() modifies
292 // |current_requests_|, so we make a copy first. 290 // |current_requests_|, so we make a copy first.
293 std::vector<ClientRequest*> to_callback(current_requests_); 291 std::vector<ClientRequest*> to_callback(current_requests_);
294 for (auto* req : to_callback) { 292 for (auto* req : to_callback) {
295 DVLOG(1) << "Stopping: Invoking unfinished req for URL " << req->url(); 293 DVLOG(1) << "Stopping: Invoking unfinished req for URL " << req->url();
296 req->OnRequestDone(SB_THREAT_TYPE_SAFE, ThreatMetadata()); 294 req->OnRequestDone(SB_THREAT_TYPE_SAFE, ThreatMetadata());
297 } 295 }
298 enabled_ = false;
299 296
300 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown); 297 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown);
301 } 298 }
302 299
303 } // namespace safe_browsing 300 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698