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

Unified Diff: remoting/base/auto_message_loop.cc

Issue 10796099: Introducing remoting::Stoppable helper base class implementing asynchronous shutdown on a specific t (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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..d62174f2d8920fed6799bc3cc567d133c8cb713f
--- /dev/null
+++ b/remoting/base/auto_message_loop.cc
@@ -0,0 +1,46 @@
+// 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(MessageLoop::Type type) {
+ message_loop_.reset(new MessageLoop(type));
+}
+
+AutoMessageLoop::~AutoMessageLoop() {
+}
+
+void AutoMessageLoop::Run() {
+ message_loop_->Run();
+}
+
+bool AutoMessageLoop::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ message_loop_->PostDelayedTask(from_here, task, delay);
+ return true;
+}
+
+bool AutoMessageLoop::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ message_loop_->PostNonNestableDelayedTask(from_here, task, delay);
+ return true;
+}
+
+bool AutoMessageLoop::RunsTasksOnCurrentThread() const {
+ return MessageLoop::current() == message_loop_.get();
+}
+
+void AutoMessageLoop::OnDestruct() const {
+ message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698