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

Side by Side Diff: components/download/internal/noop_store.cc

Issue 2870753003: Add a Model to the download component. (Closed)
Patch Set: Renamed test base class Created 3 years, 7 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
« no previous file with comments | « components/download/internal/noop_store.h ('k') | components/download/internal/store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/download/internal/noop_store.h"
6
7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h"
9 #include "components/download/internal/entry.h"
10
11 namespace download {
12
13 NoopStore::NoopStore() : initialized_(false), weak_ptr_factory_(this) {}
14
15 NoopStore::~NoopStore() = default;
16
17 bool NoopStore::IsInitialized() {
18 return initialized_;
19 }
20
21 void NoopStore::Initialize(InitCallback callback) {
22 DCHECK(!IsInitialized());
23
24 base::ThreadTaskRunnerHandle::Get()->PostTask(
25 FROM_HERE,
26 base::BindOnce(&NoopStore::OnInitFinished, weak_ptr_factory_.GetWeakPtr(),
27 std::move(callback)));
28 }
29
30 void NoopStore::Destroy(StoreCallback callback) {
31 base::ThreadTaskRunnerHandle::Get()->PostTask(
32 FROM_HERE, base::BindOnce(std::move(callback), true /** success */));
33 }
34
35 void NoopStore::Update(const Entry& entry, StoreCallback callback) {
36 base::ThreadTaskRunnerHandle::Get()->PostTask(
37 FROM_HERE, base::BindOnce(std::move(callback), true /** success */));
38 }
39
40 void NoopStore::Remove(const std::string& guid, StoreCallback callback) {
41 base::ThreadTaskRunnerHandle::Get()->PostTask(
42 FROM_HERE, base::BindOnce(std::move(callback), true /** success */));
43 }
44
45 void NoopStore::OnInitFinished(InitCallback callback) {
46 initialized_ = true;
47
48 std::unique_ptr<std::vector<Entry>> entries =
49 base::MakeUnique<std::vector<Entry>>();
50 std::move(callback).Run(true /** success */, std::move(entries));
51 }
52
53 } // namespace download
OLDNEW
« no previous file with comments | « components/download/internal/noop_store.h ('k') | components/download/internal/store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698