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

Side by Side Diff: components/offline_pages/core/task.cc

Issue 2359933007: [Offline pages] Introduces TaskQueue to serialize tasks that asynchronously access SQLStore (Closed)
Patch Set: Addressing feedback from Dmitry Created 4 years, 2 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/offline_pages/core/task.h ('k') | components/offline_pages/core/task_queue.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 2016 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/offline_pages/core/task.h"
6
7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h"
9
10 namespace offline_pages {
11
12 Task::Task() {}
13
14 Task::~Task() {}
15
16 void Task::SetTaskCompletionCallbackForTesting(
17 scoped_refptr<base::SingleThreadTaskRunner> task_completion_runner,
18 const TaskCompletionCallback& task_completion_callback) {
19 SetTaskCompletionCallback(task_completion_runner, task_completion_callback);
20 }
21
22 void Task::SetTaskCompletionCallback(
23 scoped_refptr<base::SingleThreadTaskRunner> task_completion_runner,
24 const TaskCompletionCallback& task_completion_callback) {
25 // Attempts to enforce that SetTaskCompletionCallback is at most called once
26 // and enforces that reasonable values are set once that happens.
27 DCHECK(!task_completion_runner_);
28 DCHECK(task_completion_runner);
29 DCHECK(task_completion_callback_.is_null());
30 DCHECK(!task_completion_callback.is_null());
31 task_completion_runner_ = task_completion_runner;
32 task_completion_callback_ = task_completion_callback;
33 }
34
35 void Task::TaskComplete() {
36 if (task_completion_callback_.is_null() || !task_completion_runner_)
37 return;
38
39 task_completion_runner_->PostTask(
40 FROM_HERE, base::Bind(task_completion_callback_, this));
41 }
42
43 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/core/task.h ('k') | components/offline_pages/core/task_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698