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