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..c32f42009865f756bb3d42077c431aaa8490d655 100644 |
--- a/components/safe_browsing_db/v4_store.cc |
+++ b/components/safe_browsing_db/v4_store.cc |
@@ -2,10 +2,18 @@ |
// 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 { |
+std::ostream& operator<<(std::ostream& os, const V4Store& store) { |
+ os << store.DebugString(); |
+ return os; |
+} |
+ |
V4Store* V4StoreFactory::CreateV4Store( |
const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
const base::FilePath& store_path) { |
@@ -14,13 +22,38 @@ V4Store* V4StoreFactory::CreateV4Store( |
V4Store::V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
const base::FilePath& store_path) |
- : task_runner_(task_runner), store_path_(store_path) {} |
+ : store_path_(store_path), task_runner_(task_runner) {} |
V4Store::~V4Store() {} |
+std::string V4Store::DebugString() const { |
+ std::string state_base64; |
+ base::Base64Encode(state_, &state_base64); |
+ |
+ std::string value; |
+ return base::SStringPrintf(&value, "path: %s; state: %s", |
+ store_path_.value().c_str(), state_base64.c_str()); |
Scott Hess - ex-Googler
2016/06/21 22:23:25
You should be able to drop |value| and just return
vakh (use Gerrit instead)
2016/06/23 06:23:50
Done.
|
+} |
+ |
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->task_runner_, this->store_path_)); |
+ |
+ // TODO(vakh): The new store currently only picks up the new state. Do more. |
+ new_store->state_ = response.new_client_state(); |
+ |
+ // new_store is done updating, pass it to the callback. |
+ callback_task_runner->PostTask( |
+ FROM_HERE, base::Bind(callback, base::Passed(&new_store))); |
+} |
+ |
} // namespace safe_browsing |