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

Unified Diff: mojo/edk/base_edk/platform_message_loop_impl.cc

Issue 1469193002: EDK: Add a mojo::platform::MessageLoop abstraction. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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: mojo/edk/base_edk/platform_message_loop_impl.cc
diff --git a/mojo/edk/base_edk/platform_message_loop_impl.cc b/mojo/edk/base_edk/platform_message_loop_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d8752ce4c2e4c1013693df54b8cd34cc16e85789
--- /dev/null
+++ b/mojo/edk/base_edk/platform_message_loop_impl.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 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 "mojo/edk/base_edk/platform_message_loop_impl.h"
+
+#include <utility>
+
+#include "mojo/edk/base_edk/platform_task_runner_impl.h"
+
+using mojo::platform::TaskRunner;
+using mojo::util::MakeRefCounted;
+using mojo::util::RefPtr;
+
+namespace base_edk {
+
+PlatformMessageLoopImpl::PlatformMessageLoopImpl(base::MessageLoop::Type type)
+ : base_message_loop_(type),
+ task_runner_(MakeRefCounted<PlatformTaskRunnerImpl>(
+ base_message_loop_.task_runner())) {}
+
+PlatformMessageLoopImpl::PlatformMessageLoopImpl(
+ scoped_ptr<base::MessagePump> pump)
+ : base_message_loop_(std::move(pump)),
+ task_runner_(MakeRefCounted<PlatformTaskRunnerImpl>(
+ base_message_loop_.task_runner())) {}
+
+PlatformMessageLoopImpl::~PlatformMessageLoopImpl() {}
+
+void PlatformMessageLoopImpl::Run() {
+ base_message_loop_.Run();
+}
+
+void PlatformMessageLoopImpl::RunUntilIdle() {
+ base_message_loop_.RunUntilIdle();
+}
+
+void PlatformMessageLoopImpl::QuitWhenIdle() {
+ base_message_loop_.QuitWhenIdle();
+}
+
+const RefPtr<TaskRunner>& PlatformMessageLoopImpl::GetTaskRunner() const {
+ return task_runner_;
+}
+
+bool PlatformMessageLoopImpl::IsRunningOnCurrentThread() const {
+ return base::MessageLoop::current() == &base_message_loop_ &&
+ base_message_loop_.is_running();
+}
+
+} // namespace base_edk
« no previous file with comments | « mojo/edk/base_edk/platform_message_loop_impl.h ('k') | mojo/edk/base_edk/platform_message_loop_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698