| 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 #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/files/file_util.h" | 
|   10 #include "base/memory/ptr_util.h" |   10 #include "base/memory/ptr_util.h" | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  130   if (!pending_store_updates_) { |  130   if (!pending_store_updates_) { | 
|  131     current_task_runner->PostTask(FROM_HERE, db_updated_callback_); |  131     current_task_runner->PostTask(FROM_HERE, db_updated_callback_); | 
|  132     db_updated_callback_.Reset(); |  132     db_updated_callback_.Reset(); | 
|  133   } |  133   } | 
|  134 } |  134 } | 
|  135  |  135  | 
|  136 void V4Database::UpdatedStoreReady(UpdateListIdentifier identifier, |  136 void V4Database::UpdatedStoreReady(UpdateListIdentifier identifier, | 
|  137                                    std::unique_ptr<V4Store> new_store) { |  137                                    std::unique_ptr<V4Store> new_store) { | 
|  138   DCHECK_CURRENTLY_ON(BrowserThread::IO); |  138   DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
|  139   DCHECK(pending_store_updates_); |  139   DCHECK(pending_store_updates_); | 
|  140   (*store_map_)[identifier] = std::move(new_store); |  140   if (new_store) { | 
 |  141     (*store_map_)[identifier] = std::move(new_store); | 
 |  142   } | 
|  141  |  143  | 
|  142   pending_store_updates_--; |  144   pending_store_updates_--; | 
|  143   if (!pending_store_updates_) { |  145   if (!pending_store_updates_) { | 
|  144     db_updated_callback_.Run(); |  146     db_updated_callback_.Run(); | 
|  145     db_updated_callback_.Reset(); |  147     db_updated_callback_.Reset(); | 
|  146   } |  148   } | 
|  147 } |  149 } | 
|  148  |  150  | 
|  149 bool V4Database::ResetDatabase() { |  151 bool V4Database::ResetDatabase() { | 
|  150   DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); |  152   DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); | 
|  151   bool reset_success = true; |  153   bool reset_success = true; | 
|  152   for (const auto& store_map_iter : *store_map_) { |  154   for (const auto& store_map_iter : *store_map_) { | 
|  153     if (!store_map_iter.second->Reset()) { |  155     if (!store_map_iter.second->Reset()) { | 
|  154       reset_success = false; |  156       reset_success = false; | 
|  155     } |  157     } | 
|  156   } |  158   } | 
|  157   return reset_success; |  159   return reset_success; | 
|  158 } |  160 } | 
|  159  |  161  | 
|  160 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() { |  162 std::unique_ptr<StoreStateMap> V4Database::GetStoreStateMap() { | 
|  161   std::unique_ptr<StoreStateMap> store_state_map = |  163   std::unique_ptr<StoreStateMap> store_state_map = | 
|  162       base::MakeUnique<StoreStateMap>(); |  164       base::MakeUnique<StoreStateMap>(); | 
|  163   for (const auto& store_map_iter : *store_map_) { |  165   for (const auto& store_map_iter : *store_map_) { | 
|  164     (*store_state_map)[store_map_iter.first] = store_map_iter.second->state(); |  166     (*store_state_map)[store_map_iter.first] = store_map_iter.second->state(); | 
|  165   } |  167   } | 
|  166   return store_state_map; |  168   return store_state_map; | 
|  167 } |  169 } | 
|  168  |  170  | 
|  169 }  // namespace safe_browsing |  171 }  // namespace safe_browsing | 
| OLD | NEW |