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

Side by Side Diff: mojo/edk/test/scoped_ipc_support.cc

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to mojo::edk namespace in preparation for runtim flag Created 5 years, 2 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 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/test/scoped_ipc_support.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "mojo/edk/embedder/embedder.h"
9
10 namespace mojo {
11 namespace edk {
12 namespace test {
13
14 namespace internal {
15
16 ScopedIPCSupportHelper::ScopedIPCSupportHelper()
17 : event_(true, false) { // Manual reset.
18 }
19
20 ScopedIPCSupportHelper::~ScopedIPCSupportHelper() {
21 if (base::MessageLoop::current() &&
22 base::MessageLoop::current()->task_runner() == io_thread_task_runner_) {
23 ShutdownIPCSupportOnIOThread();
24 } else {
25 ShutdownIPCSupportAndWaitForNoChannels();
26 event_.Wait();
27 }
28 }
29
30 void ScopedIPCSupportHelper::Init(
31 ProcessDelegate* process_delegate,
32 scoped_refptr<base::TaskRunner> io_thread_task_runner,
33 ScopedPlatformHandle platform_handle) {
34 io_thread_task_runner_ = io_thread_task_runner;
35 // Note: Run delegate methods on the I/O thread.
36 InitIPCSupport(io_thread_task_runner_, process_delegate,
37 io_thread_task_runner_, platform_handle.Pass());
38 }
39
40 void ScopedIPCSupportHelper::OnShutdownCompleteImpl() {
41 event_.Signal();
42 }
43
44 } // namespace internal
45
46 ScopedIPCSupport::ScopedIPCSupport(
47 scoped_refptr<base::TaskRunner> io_thread_task_runner) {
48 helper_.Init(this, io_thread_task_runner.Pass(), ScopedPlatformHandle());
49 }
50
51 ScopedIPCSupport::~ScopedIPCSupport() {
52 }
53
54 void ScopedIPCSupport::OnShutdownComplete() {
55 helper_.OnShutdownCompleteImpl();
56 }
57
58 } // namespace test
59 } // namespace edk
60 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698