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

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 CR feedback 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
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::SetTaskCompletionCallback(
17 scoped_refptr<base::SingleThreadTaskRunner> task_completion_runner,
18 const TaskCompletionCallback& task_completion_callback) {
19 // Attempts to enforce that SetTaskCompletionCallback is at most called once
20 // and enforces that reasonable values are set once that happens.
21 DCHECK(!task_completion_runner_);
22 DCHECK(task_completion_runner);
23 DCHECK(task_completion_callback_.is_null());
24 DCHECK(!task_completion_callback.is_null());
25 task_completion_runner_ = task_completion_runner;
26 task_completion_callback_ = task_completion_callback;
27 }
28
29 void Task::TaskComplete() {
30 if (task_completion_callback_.is_null() || !task_completion_runner_)
31 return;
32
33 task_completion_runner_->PostTask(
34 FROM_HERE, base::Bind(task_completion_callback_, this));
35 }
36
37 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698