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

Unified Diff: components/offline_pages/core/task.cc

Issue 2359933007: [Offline pages] Introduces TaskQueue to serialize tasks that asynchronously access SQLStore (Closed)
Patch Set: Addressing gn problems, adding missing test file to build Created 4 years, 3 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/offline_pages/core/task.cc
diff --git a/components/offline_pages/core/task.cc b/components/offline_pages/core/task.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cb17dd563a9abb3d1541aa891f38fef78a5be741
--- /dev/null
+++ b/components/offline_pages/core/task.cc
@@ -0,0 +1,33 @@
+// Copyright 2016 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/offline_pages/core/task.h"
+
+#include "base/bind.h"
+#include "base/threading/thread_task_runner_handle.h"
+
+namespace offline_pages {
+
+Task::Task() {}
+
+Task::~Task() {}
+
+void Task::SetCompletionCallback(
+ scoped_refptr<base::SingleThreadTaskRunner> runner,
+ const CompletionCallback& callback) {
+ DCHECK(runner);
+ DCHECK(!callback.is_null());
+ completion_runner_ = runner;
+ completion_callback_ = callback;
+}
+
+void Task::Complete() {
+ if (completion_callback_.is_null() || !completion_runner_)
+ return;
+
+ completion_runner_->PostTask(FROM_HERE,
+ base::Bind(completion_callback_, this));
+}
+
+} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698