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

Side by Side 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 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
OLDNEW
(Empty)
1 // Copyright 2015 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 "mojo/edk/base_edk/platform_message_loop_impl.h"
6
7 #include <utility>
8
9 #include "mojo/edk/base_edk/platform_task_runner_impl.h"
10
11 using mojo::platform::TaskRunner;
12 using mojo::util::MakeRefCounted;
13 using mojo::util::RefPtr;
14
15 namespace base_edk {
16
17 PlatformMessageLoopImpl::PlatformMessageLoopImpl(base::MessageLoop::Type type)
18 : base_message_loop_(type),
19 task_runner_(MakeRefCounted<PlatformTaskRunnerImpl>(
20 base_message_loop_.task_runner())) {}
21
22 PlatformMessageLoopImpl::PlatformMessageLoopImpl(
23 scoped_ptr<base::MessagePump> pump)
24 : base_message_loop_(std::move(pump)),
25 task_runner_(MakeRefCounted<PlatformTaskRunnerImpl>(
26 base_message_loop_.task_runner())) {}
27
28 PlatformMessageLoopImpl::~PlatformMessageLoopImpl() {}
29
30 void PlatformMessageLoopImpl::Run() {
31 base_message_loop_.Run();
32 }
33
34 void PlatformMessageLoopImpl::RunUntilIdle() {
35 base_message_loop_.RunUntilIdle();
36 }
37
38 void PlatformMessageLoopImpl::QuitWhenIdle() {
39 base_message_loop_.QuitWhenIdle();
40 }
41
42 const RefPtr<TaskRunner>& PlatformMessageLoopImpl::GetTaskRunner() const {
43 return task_runner_;
44 }
45
46 bool PlatformMessageLoopImpl::IsRunningOnCurrentThread() const {
47 return base::MessageLoop::current() == &base_message_loop_ &&
48 base_message_loop_.is_running();
49 }
50
51 } // namespace base_edk
OLDNEW
« 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