| 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. | |
| 29 if (request_context_getter) { | 31 if (request_context_getter) { |
| 32 // Instantiate a V4GetHashProtocolManager. |
| 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); |
| 35 // Instantiate a V4UpdateProtocolManager. |
| 36 v4_update_protocol_manager_ = V4UpdateProtocolManager::Create( |
| 37 request_context_getter, config); |
| 32 } | 38 } |
| 33 } | 39 } |
| 34 | 40 |
| 35 // |shutdown| not used. Destroys the v4 protocol manager. This may be called | 41 // |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 | 42 // multiple times during the life of the DatabaseManager. |
| 37 // thread. | 43 // Must be called on IO thread. |
| 38 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { | 44 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { |
| 39 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 45 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 40 // This cancels all in-flight GetHash requests. | 46 // This cancels all in-flight GetHash requests. |
| 41 if (v4_get_hash_protocol_manager_) { | 47 if (v4_get_hash_protocol_manager_) { |
| 42 delete v4_get_hash_protocol_manager_; | 48 delete v4_get_hash_protocol_manager_; |
| 43 v4_get_hash_protocol_manager_ = NULL; | 49 v4_get_hash_protocol_manager_ = NULL; |
| 44 } | 50 } |
| 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 } |
| 45 } | 57 } |
| 46 | 58 |
| 47 void SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url, | 59 void SafeBrowsingDatabaseManager::CheckApiBlacklistUrl(const GURL& url, |
| 48 Client* client) { | 60 Client* client) { |
| 49 // TODO(kcarattini): Implement this. | 61 // TODO(kcarattini): Implement this. |
| 50 } | 62 } |
| 51 | 63 |
| 52 } // namespace safe_browsing | 64 } // namespace safe_browsing |
| OLD | NEW |