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

Side by Side Diff: remoting/base/auto_thread_task_runner.cc

Issue 10829467: [Chromoting] Introducing refcount-based life time management of the message loops in the service (d… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "remoting/base/auto_thread_task_runner.h"
6
7 #include "base/logging.h"
8
9 namespace remoting {
10
11 AutoThreadTaskRunner::AutoThreadTaskRunner(
12 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
13 : task_runner_(task_runner) {
14 }
15
16 AutoThreadTaskRunner::AutoThreadTaskRunner(
17 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
18 const base::Closure& stop_callback)
19 : stop_callback_(stop_callback),
20 task_runner_(task_runner) {
21 }
22
23 AutoThreadTaskRunner::AutoThreadTaskRunner(
24 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
25 scoped_refptr<AutoThreadTaskRunner> parent)
26 : parent_(parent),
27 task_runner_(task_runner) {
28 }
29
30 AutoThreadTaskRunner::AutoThreadTaskRunner(
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
32 scoped_refptr<AutoThreadTaskRunner> parent,
33 const base::Closure& stop_callback)
34 : parent_(parent),
35 stop_callback_(stop_callback),
36 task_runner_(task_runner) {
37 }
38
39 bool AutoThreadTaskRunner::PostDelayedTask(
40 const tracked_objects::Location& from_here,
41 const base::Closure& task,
42 base::TimeDelta delay) {
43 // CHECK() makes sure that |task_runner_| is still running, - the assumption
44 // made by |AutoThreadTaskRunner| owners.
45 CHECK(task_runner_->PostDelayedTask(from_here, task, delay));
46 return true;
47 }
48
49 bool AutoThreadTaskRunner::PostNonNestableDelayedTask(
50 const tracked_objects::Location& from_here,
51 const base::Closure& task,
52 base::TimeDelta delay) {
53 // CHECK() makes sure that |task_runner_| is still running, - the assumption
54 // made by |AutoThreadTaskRunner| owners.
55 CHECK(task_runner_->PostNonNestableDelayedTask(from_here, task, delay));
56 return true;
57 }
58
59 bool AutoThreadTaskRunner::RunsTasksOnCurrentThread() const {
60 return task_runner_->RunsTasksOnCurrentThread();
61 }
62
63 AutoThreadTaskRunner::~AutoThreadTaskRunner() {
64 if (!stop_callback_.is_null())
65 stop_callback_.Run();
66 }
67
68 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/auto_thread_task_runner.h ('k') | remoting/base/auto_thread_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698