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 #include "base/base64.h" | 5 #include "base/base64.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 DCHECK(state_.empty()); | 187 DCHECK(state_.empty()); |
| 188 | 188 |
| 189 StoreReadResult store_read_result = ReadFromDisk(); | 189 StoreReadResult store_read_result = ReadFromDisk(); |
| 190 RecordStoreReadResult(store_read_result); | 190 RecordStoreReadResult(store_read_result); |
| 191 } | 191 } |
| 192 | 192 |
| 193 V4Store::V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 193 V4Store::V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 194 const base::FilePath& store_path) | 194 const base::FilePath& store_path) |
| 195 : store_path_(store_path), task_runner_(task_runner) {} | 195 : store_path_(store_path), task_runner_(task_runner) {} |
| 196 | 196 |
| 197 V4Store::~V4Store() {} | 197 V4Store::~V4Store() { |
| 198 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | |
| 199 } | |
| 198 | 200 |
| 199 std::string V4Store::DebugString() const { | 201 std::string V4Store::DebugString() const { |
| 200 std::string state_base64; | 202 std::string state_base64; |
| 201 base::Base64Encode(state_, &state_base64); | 203 base::Base64Encode(state_, &state_base64); |
| 202 | 204 |
| 203 return base::StringPrintf("path: %" PRIsFP "; state: %s", | 205 return base::StringPrintf("path: %" PRIsFP "; state: %s", |
| 204 store_path_.value().c_str(), state_base64.c_str()); | 206 store_path_.value().c_str(), state_base64.c_str()); |
| 205 } | 207 } |
| 206 | 208 |
| 209 // static | |
| 210 void V4Store::Destroy(std::unique_ptr<V4Store> v4_store) { | |
| 211 V4Store* v4_store_raw = v4_store.release(); | |
| 212 if (v4_store_raw) { | |
| 213 v4_store_raw->task_runner_->DeleteSoon(FROM_HERE, v4_store_raw); | |
| 214 } | |
|
Scott Hess - ex-Googler
2016/10/18 02:57:01
OK, yeah, same pattern as V4Database, makes sense.
| |
| 215 } | |
| 216 | |
| 207 void V4Store::Reset() { | 217 void V4Store::Reset() { |
| 208 expected_checksum_.clear(); | 218 expected_checksum_.clear(); |
| 209 hash_prefix_map_.clear(); | 219 hash_prefix_map_.clear(); |
| 210 state_ = ""; | 220 state_ = ""; |
| 211 } | 221 } |
| 212 | 222 |
| 213 ApplyUpdateResult V4Store::ProcessPartialUpdateAndWriteToDisk( | 223 ApplyUpdateResult V4Store::ProcessPartialUpdateAndWriteToDisk( |
| 214 const std::string& metric, | 224 const std::string& metric, |
| 215 const HashPrefixMap& hash_prefix_map_old, | 225 const HashPrefixMap& hash_prefix_map_old, |
| 216 std::unique_ptr<ListUpdateResponse> response) { | 226 std::unique_ptr<ListUpdateResponse> response) { |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 << "; expected: " << expected_checksum_b64 | 819 << "; expected: " << expected_checksum_b64 |
| 810 << "; store: " << *this; | 820 << "; store: " << *this; |
| 811 #endif | 821 #endif |
| 812 return false; | 822 return false; |
| 813 } | 823 } |
| 814 } | 824 } |
| 815 return true; | 825 return true; |
| 816 } | 826 } |
| 817 | 827 |
| 818 } // namespace safe_browsing | 828 } // namespace safe_browsing |
| OLD | NEW |