OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This file should not be build on Android but is currently getting built. | 5 // This file should not be build on Android but is currently getting built. |
6 // TODO(vakh): Fix that: http://crbug.com/621647 | 6 // TODO(vakh): Fix that: http://crbug.com/621647 |
7 | 7 |
8 #include "components/safe_browsing_db/v4_local_database_manager.h" | 8 #include "components/safe_browsing_db/v4_local_database_manager.h" |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/ref_counted.h" |
| 16 #include "components/safe_browsing_db/v4_feature_list.h" |
15 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
16 | 18 |
17 using content::BrowserThread; | 19 using content::BrowserThread; |
18 | 20 |
19 namespace safe_browsing { | 21 namespace safe_browsing { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 const ThreatSeverity kLeastSeverity = | 25 const ThreatSeverity kLeastSeverity = |
24 std::numeric_limits<ThreatSeverity>::max(); | 26 std::numeric_limits<ThreatSeverity>::max(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 : client(client), | 59 : client(client), |
58 client_callback_type(client_callback_type), | 60 client_callback_type(client_callback_type), |
59 result_threat_type(SB_THREAT_TYPE_SAFE), | 61 result_threat_type(SB_THREAT_TYPE_SAFE), |
60 stores_to_check(stores_to_check), | 62 stores_to_check(stores_to_check), |
61 url(url) { | 63 url(url) { |
62 DCHECK_GT(ClientCallbackType::CHECK_MAX, client_callback_type); | 64 DCHECK_GT(ClientCallbackType::CHECK_MAX, client_callback_type); |
63 } | 65 } |
64 | 66 |
65 V4LocalDatabaseManager::PendingCheck::~PendingCheck() {} | 67 V4LocalDatabaseManager::PendingCheck::~PendingCheck() {} |
66 | 68 |
| 69 // static |
| 70 scoped_refptr<V4LocalDatabaseManager> V4LocalDatabaseManager::Create( |
| 71 const base::FilePath& base_path) { |
| 72 if (!V4FeatureList::IsLocalDatabaseManagerEnabled()) { |
| 73 return nullptr; |
| 74 } |
| 75 |
| 76 return make_scoped_refptr(new V4LocalDatabaseManager(base_path)); |
| 77 } |
| 78 |
67 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) | 79 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) |
68 : base_path_(base_path), enabled_(false), list_infos_(GetListInfos()) { | 80 : base_path_(base_path), enabled_(false), list_infos_(GetListInfos()) { |
69 DCHECK(!base_path_.empty()); | 81 DCHECK(!base_path_.empty()); |
70 DCHECK(!list_infos_.empty()); | 82 DCHECK(!list_infos_.empty()); |
71 | 83 |
72 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " | 84 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " |
73 << "base_path_: " << base_path_.AsUTF8Unsafe(); | 85 << "base_path_: " << base_path_.AsUTF8Unsafe(); |
74 } | 86 } |
75 | 87 |
76 V4LocalDatabaseManager::~V4LocalDatabaseManager() { | 88 V4LocalDatabaseManager::~V4LocalDatabaseManager() { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 471 } |
460 | 472 |
461 void V4LocalDatabaseManager::UpdateRequestCompleted( | 473 void V4LocalDatabaseManager::UpdateRequestCompleted( |
462 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 474 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
463 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 475 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
464 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 476 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
465 db_updated_callback_); | 477 db_updated_callback_); |
466 } | 478 } |
467 | 479 |
468 } // namespace safe_browsing | 480 } // namespace safe_browsing |
OLD | NEW |