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" | |
17 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
18 | 16 |
19 using content::BrowserThread; | 17 using content::BrowserThread; |
20 | 18 |
21 namespace safe_browsing { | 19 namespace safe_browsing { |
22 | 20 |
23 namespace { | 21 namespace { |
24 | 22 |
25 const ThreatSeverity kLeastSeverity = | 23 const ThreatSeverity kLeastSeverity = |
26 std::numeric_limits<ThreatSeverity>::max(); | 24 std::numeric_limits<ThreatSeverity>::max(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 : client(client), | 57 : client(client), |
60 client_callback_type(client_callback_type), | 58 client_callback_type(client_callback_type), |
61 result_threat_type(SB_THREAT_TYPE_SAFE), | 59 result_threat_type(SB_THREAT_TYPE_SAFE), |
62 stores_to_check(stores_to_check), | 60 stores_to_check(stores_to_check), |
63 url(url) { | 61 url(url) { |
64 DCHECK_GT(ClientCallbackType::CHECK_MAX, client_callback_type); | 62 DCHECK_GT(ClientCallbackType::CHECK_MAX, client_callback_type); |
65 } | 63 } |
66 | 64 |
67 V4LocalDatabaseManager::PendingCheck::~PendingCheck() {} | 65 V4LocalDatabaseManager::PendingCheck::~PendingCheck() {} |
68 | 66 |
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 | |
79 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) | 67 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) |
80 : base_path_(base_path), enabled_(false), list_infos_(GetListInfos()) { | 68 : base_path_(base_path), enabled_(false), list_infos_(GetListInfos()) { |
81 DCHECK(!base_path_.empty()); | 69 DCHECK(!base_path_.empty()); |
82 DCHECK(!list_infos_.empty()); | 70 DCHECK(!list_infos_.empty()); |
83 | 71 |
84 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " | 72 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " |
85 << "base_path_: " << base_path_.AsUTF8Unsafe(); | 73 << "base_path_: " << base_path_.AsUTF8Unsafe(); |
86 } | 74 } |
87 | 75 |
88 V4LocalDatabaseManager::~V4LocalDatabaseManager() { | 76 V4LocalDatabaseManager::~V4LocalDatabaseManager() { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 459 } |
472 | 460 |
473 void V4LocalDatabaseManager::UpdateRequestCompleted( | 461 void V4LocalDatabaseManager::UpdateRequestCompleted( |
474 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 462 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
475 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 463 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
476 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 464 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
477 db_updated_callback_); | 465 db_updated_callback_); |
478 } | 466 } |
479 | 467 |
480 } // namespace safe_browsing | 468 } // namespace safe_browsing |
OLD | NEW |