Chromium Code Reviews| 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 "components/safe_browsing_db/v4_update_protocol_manager.h" | |
| 8 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 9 #include "net/url_request/url_request_context_getter.h" | 10 #include "net/url_request/url_request_context_getter.h" |
| 10 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 11 | 12 |
| 12 using content::BrowserThread; | 13 using content::BrowserThread; |
| 13 | 14 |
| 14 namespace safe_browsing { | 15 namespace safe_browsing { |
| 15 | 16 |
| 16 SafeBrowsingDatabaseManager::SafeBrowsingDatabaseManager() | 17 SafeBrowsingDatabaseManager::SafeBrowsingDatabaseManager() |
| 17 : v4_get_hash_protocol_manager_(NULL) { | 18 : v4_get_hash_protocol_manager_(NULL), |
| 19 v4_update_protocol_manager_(NULL) { | |
| 18 } | 20 } |
| 19 | 21 |
| 20 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { | 22 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { |
| 21 DCHECK(v4_get_hash_protocol_manager_ == NULL); | 23 DCHECK(v4_get_hash_protocol_manager_ == NULL); |
| 24 DCHECK(v4_update_protocol_manager_ == NULL); | |
| 22 } | 25 } |
| 23 | 26 |
| 24 void SafeBrowsingDatabaseManager::StartOnIOThread( | 27 void SafeBrowsingDatabaseManager::StartOnIOThread( |
| 25 net::URLRequestContextGetter* request_context_getter, | 28 net::URLRequestContextGetter* request_context_getter, |
| 26 const V4ProtocolConfig& config) { | 29 const V4ProtocolConfig& config) { |
| 27 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 30 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 28 // Instantiate a V4GetHashProtocolManager. | 31 // Instantiate a V4GetHashProtocolManager. |
| 29 if (request_context_getter) { | 32 if (request_context_getter) { |
| 30 v4_get_hash_protocol_manager_ = V4GetHashProtocolManager::Create( | 33 v4_get_hash_protocol_manager_ = V4GetHashProtocolManager::Create( |
| 31 request_context_getter, config); | 34 request_context_getter, config); |
| 32 } | 35 } |
| 36 | |
| 37 // Instantiate a V4UpdateProtocolManager. | |
| 38 if (request_context_getter) { | |
| 39 v4_update_protocol_manager_ = V4UpdateProtocolManager::Create( | |
|
kcarattini
2016/03/22 00:41:43
Why not just put this in the same if statement abo
| |
| 40 request_context_getter, config); | |
| 41 } | |
| 33 } | 42 } |
| 34 | 43 |
| 35 // |shutdown| not used. Destroys the v4 protocol manager. This may be called | 44 // |shutdown| not used. Destroys the v4 protocol managers. This may be called |
| 36 // multiple times during the life of the DatabaseManager. Must be called on IO | 45 // multiple times during the life of the DatabaseManager. |
| 37 // thread. | 46 // Must be called on IO thread. |
| 38 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { | 47 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { |
| 39 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 48 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 40 // This cancels all in-flight GetHash requests. | 49 // This cancels all in-flight GetHash requests. |
| 41 if (v4_get_hash_protocol_manager_) { | 50 if (v4_get_hash_protocol_manager_) { |
| 42 delete v4_get_hash_protocol_manager_; | 51 delete v4_get_hash_protocol_manager_; |
| 43 v4_get_hash_protocol_manager_ = NULL; | 52 v4_get_hash_protocol_manager_ = NULL; |
| 44 } | 53 } |
| 54 | |
| 55 // This cancels all in-flight update requests. | |
| 56 if (v4_update_protocol_manager_) { | |
| 57 delete v4_update_protocol_manager_; | |
| 58 v4_update_protocol_manager_ = NULL; | |
| 59 } | |
| 45 } | 60 } |
| 46 | 61 |
| 47 void SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url, | 62 void SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url, |
| 48 Client* client) { | 63 Client* client) { |
| 49 // TODO(kcarattini): Implement this. | 64 // TODO(kcarattini): Implement this. |
| 50 } | 65 } |
| 51 | 66 |
| 52 } // namespace safe_browsing | 67 } // namespace safe_browsing |
| OLD | NEW |