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

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

Issue 2062013002: Fetch incremental updates. Store new state in V4Store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit: Use base::SStringPrintf instead of string concat Created 4 years, 6 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 "base/base64.h"
6 #include "base/bind.h"
7 #include "base/strings/stringprintf.h"
5 #include "components/safe_browsing_db/v4_store.h" 8 #include "components/safe_browsing_db/v4_store.h"
6 9
7 namespace safe_browsing { 10 namespace safe_browsing {
8 11
9 V4Store* V4StoreFactory::CreateV4Store( 12 V4Store* V4StoreFactory::CreateV4Store(
10 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 13 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
11 const base::FilePath& store_path) { 14 const base::FilePath& store_path) {
12 return new V4Store(task_runner, store_path); 15 return new V4Store(task_runner, store_path);
13 } 16 }
14 17
15 V4Store::V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner, 18 V4Store::V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner,
16 const base::FilePath& store_path) 19 const base::FilePath& store_path)
17 : task_runner_(task_runner), store_path_(store_path) {} 20 : task_runner_(task_runner), store_path_(store_path) {}
18 21
19 V4Store::~V4Store() {} 22 V4Store::V4Store(const V4Store& other)
23 : 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.
24
25 V4Store::~V4Store() {
26 DVLOG(1) << "Destroying V4Store: " << *this;
27 }
28
29 std::string V4Store::DebugString() const {
30 std::string value;
31 base::SStringPrintf(&value, "path: %s; state: %s",
32 store_path_.value().c_str(),
33 GetHumanReadableState().c_str());
34 return value;
35 }
20 36
21 bool V4Store::Reset() { 37 bool V4Store::Reset() {
22 // TODO(vakh): Implement skeleton. 38 // TODO(vakh): Implement skeleton.
39 state_ = "";
23 return true; 40 return true;
24 } 41 }
25 42
43 void V4Store::ApplyUpdate(
44 const ListUpdateResponse& response,
45 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner,
46 UpdatedStoreReadyCallback callback) {
47 std::unique_ptr<V4Store> new_store(new V4Store(*this));
48
49 // TODO(vakh): The new store currently only picks up the new state. Do more.
50 new_store->state_ = response.new_client_state();
51
52 DVLOG(1) << "Created V4Store: " << new_store->DebugString();
53
54 // 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.
55 callback_task_runner->PostTask(
56 FROM_HERE, base::Bind(callback, base::Passed(&new_store)));
57 }
58
59 std::string V4Store::GetHumanReadableState() const {
60 std::string state_base64;
61 base::Base64Encode(state_, &state_base64);
62 return state_base64;
63 }
64
26 } // namespace safe_browsing 65 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698