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

Unified Diff: components/download/internal/noop_store.cc

Issue 2870753003: Add a Model to the download component. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: components/download/internal/noop_store.cc
diff --git a/components/download/internal/noop_store.cc b/components/download/internal/noop_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..36edb728f451a988d19999805168e0f86968bb9a
--- /dev/null
+++ b/components/download/internal/noop_store.cc
@@ -0,0 +1,52 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/download/internal/noop_store.h"
+
+#include "base/bind.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "components/download/internal/entry.h"
+
+namespace download {
+
+NoopStore::NoopStore() : initialized_(false), weak_ptr_factory_(this) {}
+
+NoopStore::~NoopStore() = default;
+
+bool NoopStore::IsInitialized() {
+ return initialized_;
+}
+
+void NoopStore::Initialize(const InitCallback& callback) {
+ DCHECK(!IsInitialized());
+
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&NoopStore::OnInitFinished,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+}
+
+void NoopStore::Destroy(const StoreCallback& callback) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback, true /** success */));
+}
+
+void NoopStore::Update(const Entry& entry, const StoreCallback& callback) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback, true /** success */));
+}
+
+void NoopStore::Remove(const std::string& guid, const StoreCallback& callback) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback, true /** success */));
+}
+
+void NoopStore::OnInitFinished(const InitCallback& callback) {
+ initialized_ = true;
+
+ std::unique_ptr<std::vector<Entry>> entries =
+ base::MakeUnique<std::vector<Entry>>();
+ callback.Run(true /** success */, std::move(entries));
+}
+
+} // namespace download

Powered by Google App Engine
This is Rietveld 408576698