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

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: convert remaining MP tests and simplify RawChannel destruction Created 5 years, 3 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 test {
12
13 namespace internal {
14
15 ScopedIPCSupportHelper::ScopedIPCSupportHelper()
16 : event_(true, false) { // Manual reset.
17 }
18
19 ScopedIPCSupportHelper::~ScopedIPCSupportHelper() {
20 if (base::MessageLoop::current() &&
21 base::MessageLoop::current()->task_runner() == io_thread_task_runner_) {
22 embedder::ShutdownIPCSupportOnIOThread();
23 } else {
24 embedder::ShutdownIPCSupportAndWaitForNoChannels();
25 event_.Wait();
26 }
27 }
28
29 void ScopedIPCSupportHelper::Init(
30 embedder::ProcessType process_type,
31 embedder::ProcessDelegate* process_delegate,
32 scoped_refptr<base::TaskRunner> io_thread_task_runner,
33 embedder::ScopedPlatformHandle platform_handle) {
34 io_thread_task_runner_ = io_thread_task_runner;
35 // Note: Run delegate methods on the I/O thread.
36 embedder::InitIPCSupport(process_type, io_thread_task_runner_,
37 process_delegate, io_thread_task_runner_,
38 platform_handle.Pass());
39 }
40
41 void ScopedIPCSupportHelper::OnShutdownCompleteImpl() {
42 event_.Signal();
43 }
44
45 } // namespace internal
46
47 ScopedIPCSupport::ScopedIPCSupport(
48 scoped_refptr<base::TaskRunner> io_thread_task_runner) {
49 helper_.Init(embedder::ProcessType::NONE,
50 this,
51 io_thread_task_runner.Pass(),
52 embedder::ScopedPlatformHandle());
53 }
54
55 ScopedIPCSupport::~ScopedIPCSupport() {
56 }
57
58 void ScopedIPCSupport::OnShutdownComplete() {
59 helper_.OnShutdownCompleteImpl();
60 }
61
62 } // namespace test
63 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698