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

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

Issue 2648193002: SafeBrowsing: Move enabled_ to base class DB Manager (Closed)
Patch Set: Update comments 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/database_manager.h" 5 #include "components/safe_browsing_db/database_manager.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" 8 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h"
9 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 9 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 using content::BrowserThread; 14 using content::BrowserThread;
15 15
16 namespace safe_browsing { 16 namespace safe_browsing {
17 17
18 SafeBrowsingDatabaseManager::SafeBrowsingDatabaseManager() {} 18 SafeBrowsingDatabaseManager::SafeBrowsingDatabaseManager() : enabled_(false) {}
19 19
20 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { 20 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() {
21 DCHECK(!v4_get_hash_protocol_manager_); 21 DCHECK(!v4_get_hash_protocol_manager_);
22 } 22 }
23 23
24 bool SafeBrowsingDatabaseManager::CancelApiCheck(Client* client) { 24 bool SafeBrowsingDatabaseManager::CancelApiCheck(Client* client) {
25 DCHECK_CURRENTLY_ON(BrowserThread::IO); 25 DCHECK_CURRENTLY_ON(BrowserThread::IO);
26 ApiCheckSet::iterator it = FindClientApiCheck(client); 26 ApiCheckSet::iterator it = FindClientApiCheck(client);
27 if (it != api_checks_.end()) { 27 if (it != api_checks_.end()) {
28 api_checks_.erase(it); 28 api_checks_.erase(it);
29 return true; 29 return true;
30 } 30 }
31 NOTREACHED(); 31 NOTREACHED();
32 return false; 32 return false;
33 } 33 }
34 34
35 bool SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url, 35 bool SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url,
36 Client* client) { 36 Client* client) {
37 DCHECK_CURRENTLY_ON(BrowserThread::IO); 37 DCHECK_CURRENTLY_ON(BrowserThread::IO);
38 DCHECK(v4_get_hash_protocol_manager_); 38 DCHECK(v4_get_hash_protocol_manager_);
39 39
40 // Make sure we can check this url. 40 // Make sure we can check this url and that the service is enabled.
41 if (!(url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme))) { 41 if (!enabled_ ||
42 !(url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme))) {
42 return true; 43 return true;
43 } 44 }
44 45
45 // There can only be one in-progress check for the same client at a time. 46 // There can only be one in-progress check for the same client at a time.
46 DCHECK(FindClientApiCheck(client) == api_checks_.end()); 47 DCHECK(FindClientApiCheck(client) == api_checks_.end());
47 48
48 std::unique_ptr<SafeBrowsingApiCheck> check( 49 std::unique_ptr<SafeBrowsingApiCheck> check(
49 new SafeBrowsingApiCheck(url, client)); 50 new SafeBrowsingApiCheck(url, client));
50 api_checks_.insert(check.get()); 51 api_checks_.insert(check.get());
51 v4_get_hash_protocol_manager_->GetFullHashesWithApis( 52 v4_get_hash_protocol_manager_->GetFullHashesWithApis(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 116 }
116 117
117 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck( 118 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck(
118 const GURL& url, 119 const GURL& url,
119 Client* client) 120 Client* client)
120 : url_(url), client_(client) {} 121 : url_(url), client_(client) {}
121 122
122 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() {} 123 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() {}
123 124
124 } // namespace safe_browsing 125 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing_db/database_manager.h ('k') | components/safe_browsing_db/remote_database_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698