Index: components/safe_browsing_db/v4_store.cc |
diff --git a/components/safe_browsing_db/v4_store.cc b/components/safe_browsing_db/v4_store.cc |
index 0262965bedc5daf2f2ceffbf96d1e5b171b815fd..a887185422590057e0163b2ed0f1eefeed2111fa 100644 |
--- a/components/safe_browsing_db/v4_store.cc |
+++ b/components/safe_browsing_db/v4_store.cc |
@@ -2,6 +2,9 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/base64.h" |
+#include "base/bind.h" |
+#include "base/strings/stringprintf.h" |
#include "components/safe_browsing_db/v4_store.h" |
namespace safe_browsing { |
@@ -16,11 +19,47 @@ V4Store::V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
const base::FilePath& store_path) |
: task_runner_(task_runner), store_path_(store_path) {} |
-V4Store::~V4Store() {} |
+V4Store::V4Store(const V4Store& other) |
+ : task_runner_(other.task_runner_), store_path_(other.store_path_) {} |
Nathan Parker
2016/06/15 21:24:21
Document what this constructor does or will do in
vakh (use Gerrit instead)
2016/06/16 01:07:35
Done.
|
+ |
+V4Store::~V4Store() { |
+ DVLOG(1) << "Destroying V4Store: " << *this; |
+} |
+ |
+std::string V4Store::DebugString() const { |
+ std::string value; |
+ base::SStringPrintf(&value, "path: %s; state: %s", |
+ store_path_.value().c_str(), |
+ GetHumanReadableState().c_str()); |
+ return value; |
+} |
bool V4Store::Reset() { |
// TODO(vakh): Implement skeleton. |
+ state_ = ""; |
return true; |
} |
+void V4Store::ApplyUpdate( |
+ const ListUpdateResponse& response, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, |
+ UpdatedStoreReadyCallback callback) { |
+ std::unique_ptr<V4Store> new_store(new V4Store(*this)); |
+ |
+ // TODO(vakh): The new store currently only picks up the new state. Do more. |
+ new_store->state_ = response.new_client_state(); |
+ |
+ DVLOG(1) << "Created V4Store: " << new_store->DebugString(); |
+ |
+ // new_store is done updataing, pass it to the callback. |
Nathan Parker
2016/06/15 21:24:19
nit: updating
vakh (use Gerrit instead)
2016/06/16 01:07:35
Done.
|
+ callback_task_runner->PostTask( |
+ FROM_HERE, base::Bind(callback, base::Passed(&new_store))); |
+} |
+ |
+std::string V4Store::GetHumanReadableState() const { |
+ std::string state_base64; |
+ base::Base64Encode(state_, &state_base64); |
+ return state_base64; |
+} |
+ |
} // namespace safe_browsing |