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

Unified Diff: remoting/base/auto_message_loop.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 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_message_loop.cc
diff --git a/remoting/base/auto_message_loop.cc b/remoting/base/auto_message_loop.cc
new file mode 100644
index 0000000000000000000000000000000000000000..491d7721817dd0e8f75852af63f97c76193e6d74
--- /dev/null
+++ b/remoting/base/auto_message_loop.cc
@@ -0,0 +1,48 @@
+// 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_message_loop.h"
+
+#include "base/logging.h"
+
+namespace remoting {
+
+AutoMessageLoop::AutoMessageLoop(base::SingleThreadTaskRunner* parent,
+ base::SingleThreadTaskRunner* task_runner,
+ const base::Closure& stop_callback)
+ : parent_(parent),
+ stop_callback_(stop_callback),
+ task_runner_(task_runner) {
+}
+
+bool AutoMessageLoop::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ CHECK(task_runner_->PostDelayedTask(from_here, task, delay));
Wez 2012/08/28 17:34:53 Why CHECK rather than returning the result?
alexeypa (please no reviews) 2012/08/28 19:18:51 The whole purpose of this class is to make sure th
+ return true;
+}
+
+bool AutoMessageLoop::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ CHECK(task_runner_->PostNonNestableDelayedTask(from_here, task, delay));
Wez 2012/08/28 17:34:53 Ditto.
alexeypa (please no reviews) 2012/08/28 19:18:51 See above.
+ return true;
+}
+
+bool AutoMessageLoop::RunsTasksOnCurrentThread() const {
+ return task_runner_->RunsTasksOnCurrentThread();
+}
+
+void AutoMessageLoop::OnDestruct() const {
+ if (!stop_callback_.is_null())
+ stop_callback_.Run();
+ delete this;
+}
+
+AutoMessageLoop::~AutoMessageLoop() {
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698