Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: components/safe_browsing_db/v4_database.cc

Issue 2066083002: SafeBrowising: Read and write V4Store from/to disk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_UpdateDbAndStores
Patch Set: git pull Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <memory> 5 #include <memory>
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
9 #include "base/files/file_util.h"
9 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "components/safe_browsing_db/v4_database.h" 12 #include "components/safe_browsing_db/v4_database.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 14
14 using content::BrowserThread; 15 using content::BrowserThread;
15 16
16 namespace safe_browsing { 17 namespace safe_browsing {
17 18
18 // static 19 // static
(...skipping 23 matching lines...) Expand all
42 const StoreFileNameMap& store_file_name_map, 43 const StoreFileNameMap& store_file_name_map,
43 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, 44 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner,
44 NewDatabaseReadyCallback new_db_callback) { 45 NewDatabaseReadyCallback new_db_callback) {
45 DCHECK(db_task_runner->RunsTasksOnCurrentThread()); 46 DCHECK(db_task_runner->RunsTasksOnCurrentThread());
46 47
47 if (!factory_) { 48 if (!factory_) {
48 factory_ = new V4StoreFactory(); 49 factory_ = new V4StoreFactory();
49 ANNOTATE_LEAKING_OBJECT_PTR(factory_); 50 ANNOTATE_LEAKING_OBJECT_PTR(factory_);
50 } 51 }
51 52
53 if (!base::CreateDirectory(base_path)) {
54 NOTREACHED();
55 }
56
52 std::unique_ptr<StoreMap> store_map = base::MakeUnique<StoreMap>(); 57 std::unique_ptr<StoreMap> store_map = base::MakeUnique<StoreMap>();
53 for (const auto& store_info : store_file_name_map) { 58 for (const auto& store_info : store_file_name_map) {
54 const UpdateListIdentifier& update_list_identifier = store_info.first; 59 const UpdateListIdentifier& update_list_identifier = store_info.first;
55 const base::FilePath store_path = base_path.AppendASCII(store_info.second); 60 const base::FilePath store_path = base_path.AppendASCII(store_info.second);
56 (*store_map)[update_list_identifier].reset( 61 (*store_map)[update_list_identifier].reset(
57 factory_->CreateV4Store(db_task_runner, store_path)); 62 factory_->CreateV4Store(db_task_runner, store_path));
58 } 63 }
59 std::unique_ptr<V4Database> v4_database( 64 std::unique_ptr<V4Database> v4_database(
60 new V4Database(db_task_runner, std::move(store_map))); 65 new V4Database(db_task_runner, std::move(store_map)));
61 66
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() { 157 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() {
153 std::unique_ptr<StoreStateMap> store_state_map = 158 std::unique_ptr<StoreStateMap> store_state_map =
154 base::MakeUnique<StoreStateMap>(); 159 base::MakeUnique<StoreStateMap>();
155 for (const auto& store_map_iter : *store_map_) { 160 for (const auto& store_map_iter : *store_map_) {
156 (*store_state_map)[store_map_iter.first] = store_map_iter.second->state(); 161 (*store_state_map)[store_map_iter.first] = store_map_iter.second->state();
157 } 162 }
158 return store_state_map; 163 return store_state_map;
159 } 164 }
160 165
161 } // namespace safe_browsing 166 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698