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

Unified 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: CR feedback and a unit test for AutoThreadTaskRunner. Created 8 years, 4 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: remoting/base/auto_thread_task_runner.cc
diff --git a/remoting/base/auto_thread_task_runner.cc b/remoting/base/auto_thread_task_runner.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d995a22c1c97e06ff7dfc0ad8c366fb95288caf
--- /dev/null
+++ b/remoting/base/auto_thread_task_runner.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 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 "remoting/base/auto_thread_task_runner.h"
+
+#include "base/logging.h"
+
+namespace remoting {
+
+AutoThreadTaskRunner::AutoThreadTaskRunner(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner)
+ : task_runner_(task_runner) {
+}
+
+AutoThreadTaskRunner::AutoThreadTaskRunner(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ const base::Closure& stop_callback)
+ : stop_callback_(stop_callback),
+ task_runner_(task_runner) {
+}
+
+AutoThreadTaskRunner::AutoThreadTaskRunner(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ scoped_refptr<AutoThreadTaskRunner> parent)
+ : parent_(parent),
+ task_runner_(task_runner) {
+}
+
+AutoThreadTaskRunner::AutoThreadTaskRunner(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ scoped_refptr<AutoThreadTaskRunner> parent,
+ const base::Closure& stop_callback)
+ : parent_(parent),
+ stop_callback_(stop_callback),
+ task_runner_(task_runner) {
+}
+
+bool AutoThreadTaskRunner::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ // CHECK() makes sure that |task_runner_| is still running, - the assumption
+ // made by |AutoThreadTaskRunner| owners.
+ CHECK(task_runner_->PostDelayedTask(from_here, task, delay));
+ return true;
+}
+
+bool AutoThreadTaskRunner::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ // CHECK() makes sure that |task_runner_| is still running, - the assumption
+ // made by |AutoThreadTaskRunner| owners.
+ CHECK(task_runner_->PostNonNestableDelayedTask(from_here, task, delay));
+ return true;
+}
+
+bool AutoThreadTaskRunner::RunsTasksOnCurrentThread() const {
+ return task_runner_->RunsTasksOnCurrentThread();
+}
+
+AutoThreadTaskRunner::~AutoThreadTaskRunner() {
+ if (!stop_callback_.is_null())
+ stop_callback_.Run();
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698