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 "components/safe_browsing_db/database_manager.h" | 5 #include "components/safe_browsing_db/database_manager.h" |
6 | 6 |
7 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" | 7 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "net/url_request/url_request_context_getter.h" | 9 #include "net/url_request/url_request_context_getter.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 using content::BrowserThread; | 12 using content::BrowserThread; |
13 | 13 |
14 namespace safe_browsing { | 14 namespace safe_browsing { |
15 | 15 |
16 SafeBrowsingDatabaseManager::SafeBrowsingDatabaseManager() | 16 SafeBrowsingDatabaseManager::SafeBrowsingDatabaseManager() |
17 : SafeBrowsingDatabaseManager(NULL, V4ProtocolConfig()) { | 17 : v4_get_hash_protocol_manager_(NULL) { |
| 18 } |
| 19 |
| 20 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { |
| 21 DCHECK(v4_get_hash_protocol_manager_ == NULL); |
18 } | 22 } |
19 | 23 |
20 void SafeBrowsingDatabaseManager::StartOnIOThread( | 24 void SafeBrowsingDatabaseManager::StartOnIOThread( |
21 net::URLRequestContextGetter* request_context_getter, | 25 net::URLRequestContextGetter* request_context_getter, |
22 const V4ProtocolConfig& config) { | 26 const V4ProtocolConfig& config) { |
| 27 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
23 // Instantiate a V4GetHashProtocolManager. | 28 // Instantiate a V4GetHashProtocolManager. |
24 if (request_context_getter) { | 29 if (request_context_getter) { |
25 v4_get_hash_protocol_manager_ = V4GetHashProtocolManager::Create( | 30 v4_get_hash_protocol_manager_ = V4GetHashProtocolManager::Create( |
26 request_context_getter, config); | 31 request_context_getter, config); |
27 } | 32 } |
28 } | 33 } |
29 | 34 |
30 // |shutdown| not used. Destroys the v4 protocol manager. This may be called | 35 // |shutdown| not used. Destroys the v4 protocol manager. This may be called |
31 // multiple times during the life of the DatabaseManager. Must be called on IO | 36 // multiple times during the life of the DatabaseManager. Must be called on IO |
32 // thread. | 37 // thread. |
33 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { | 38 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { |
34 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 39 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
35 // This cancels all in-flight GetHash requests. | 40 // This cancels all in-flight GetHash requests. |
36 if (v4_get_hash_protocol_manager_) { | 41 if (v4_get_hash_protocol_manager_) { |
37 delete v4_get_hash_protocol_manager_; | 42 delete v4_get_hash_protocol_manager_; |
38 v4_get_hash_protocol_manager_ = NULL; | 43 v4_get_hash_protocol_manager_ = NULL; |
39 } | 44 } |
40 } | 45 } |
41 | 46 |
42 void SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url, | 47 void SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url, |
43 Client* client) { | 48 Client* client) { |
44 // TODO(kcarattini): Implement this. | 49 // TODO(kcarattini): Implement this. |
45 } | 50 } |
46 | 51 |
47 } // namespace safe_browsing | 52 } // namespace safe_browsing |
OLD | NEW |