Chromium Code Reviews| 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> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #define PLATFORM_TYPE OSX_PLATFORM | 26 #define PLATFORM_TYPE OSX_PLATFORM |
| 27 #else | 27 #else |
| 28 // This should ideally never compile but it is getting compiled on Android. | 28 // This should ideally never compile but it is getting compiled on Android. |
| 29 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=621647 | 29 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=621647 |
| 30 // TODO(vakh): Once that bug is fixed, this should be removed. If we leave | 30 // TODO(vakh): Once that bug is fixed, this should be removed. If we leave |
| 31 // the platform_type empty, the server won't recognize the request and | 31 // the platform_type empty, the server won't recognize the request and |
| 32 // return an error response which will pollute our UMA metrics. | 32 // return an error response which will pollute our UMA metrics. |
| 33 #define PLATFORM_TYPE LINUX_PLATFORM | 33 #define PLATFORM_TYPE LINUX_PLATFORM |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 // TODO(vakh): Implement this to populate the map appopriately. | 36 // TODO(vakh): Implement this to populate the map appopriately. |
|
Scott Hess - ex-Googler
2016/06/29 03:25:50
"appropriately", while you're here...
| |
| 37 // Filed as http://crbug.com/608075 | 37 // Filed as http://crbug.com/608075 |
| 38 StoreFileNameMap store_file_name_map{ | 38 StoreFileNameMap GetStoreFileNameMap() { |
| 39 {UpdateListIdentifier(PLATFORM_TYPE, URL, MALWARE_THREAT), | 39 return StoreFileNameMap( |
| 40 "UrlMalware.store"}, | 40 {{UpdateListIdentifier(PLATFORM_TYPE, URL, MALWARE_THREAT), |
| 41 {UpdateListIdentifier(PLATFORM_TYPE, URL, SOCIAL_ENGINEERING_PUBLIC), | 41 "UrlMalware.store"}, |
| 42 "UrlSoceng.store"}}; | 42 {UpdateListIdentifier(PLATFORM_TYPE, URL, SOCIAL_ENGINEERING_PUBLIC), |
| 43 "UrlSoceng.store"}}); | |
| 44 } | |
| 43 | 45 |
| 44 } // namespace | 46 } // namespace |
| 45 | 47 |
| 46 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) | 48 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) |
| 47 : base_path_(base_path), enabled_(false) { | 49 : base_path_(base_path), enabled_(false) { |
| 48 DCHECK(!base_path_.empty()); | 50 DCHECK(!base_path_.empty()); |
| 49 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " | 51 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " |
| 50 << "base_path_: " << base_path_.AsUTF8Unsafe(); | 52 << "base_path_: " << base_path_.AsUTF8Unsafe(); |
| 51 } | 53 } |
| 52 | 54 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 // previously been started and stopped, a task runner could already exist. | 201 // previously been started and stopped, a task runner could already exist. |
| 200 if (!task_runner_) { | 202 if (!task_runner_) { |
| 201 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 203 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 202 task_runner_ = pool->GetSequencedTaskRunnerWithShutdownBehavior( | 204 task_runner_ = pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| 203 pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 205 pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 204 } | 206 } |
| 205 | 207 |
| 206 // Do not create the database on the IO thread since this may be an expensive | 208 // Do not create the database on the IO thread since this may be an expensive |
| 207 // operation. Instead, do that on the task_runner and when the new database | 209 // operation. Instead, do that on the task_runner and when the new database |
| 208 // has been created, swap it out on the IO thread. | 210 // has been created, swap it out on the IO thread. |
| 211 StoreFileNameMap store_file_name_map = GetStoreFileNameMap(); | |
| 209 DCHECK(!store_file_name_map.empty()); | 212 DCHECK(!store_file_name_map.empty()); |
| 210 NewDatabaseReadyCallback db_ready_callback = base::Bind( | 213 NewDatabaseReadyCallback db_ready_callback = base::Bind( |
| 211 &V4LocalDatabaseManager::DatabaseReady, base::Unretained(this)); | 214 &V4LocalDatabaseManager::DatabaseReady, base::Unretained(this)); |
| 212 V4Database::Create(task_runner_, base_path_, store_file_name_map, | 215 V4Database::Create(task_runner_, base_path_, store_file_name_map, |
| 213 db_ready_callback); | 216 db_ready_callback); |
| 214 } | 217 } |
| 215 | 218 |
| 216 void V4LocalDatabaseManager::DatabaseReady( | 219 void V4LocalDatabaseManager::DatabaseReady( |
| 217 std::unique_ptr<V4Database> v4_database) { | 220 std::unique_ptr<V4Database> v4_database) { |
| 218 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 221 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 258 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 256 v4_database_->ApplyUpdate(responses, db_updated_callback_); | 259 v4_database_->ApplyUpdate(responses, db_updated_callback_); |
| 257 } | 260 } |
| 258 | 261 |
| 259 void V4LocalDatabaseManager::DatabaseUpdated() { | 262 void V4LocalDatabaseManager::DatabaseUpdated() { |
| 260 v4_update_protocol_manager_->ScheduleNextUpdate( | 263 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 261 v4_database_->GetStoreStateMap()); | 264 v4_database_->GetStoreStateMap()); |
| 262 } | 265 } |
| 263 | 266 |
| 264 } // namespace safe_browsing | 267 } // namespace safe_browsing |
| OLD | NEW |