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

Side by Side Diff: mojo/edk/embedder/embedder.cc

Issue 1488853002: Add multiplexing of message pipes in the new EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix chrome and POSIX 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/edk/embedder/embedder.h" 5 #include "mojo/edk/embedder/embedder.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 void PreInitializeParentProcess() { 91 void PreInitializeParentProcess() {
92 BrokerState::GetInstance(); 92 BrokerState::GetInstance();
93 } 93 }
94 94
95 void PreInitializeChildProcess() { 95 void PreInitializeChildProcess() {
96 ChildBroker::GetInstance(); 96 ChildBroker::GetInstance();
97 } 97 }
98 98
99 ScopedPlatformHandle ChildProcessLaunched(base::ProcessHandle child_process) { 99 ScopedPlatformHandle ChildProcessLaunched(base::ProcessHandle child_process) {
100 #if defined(OS_WIN)
101 PlatformChannelPair token_channel; 100 PlatformChannelPair token_channel;
102 new ChildBrokerHost(child_process, token_channel.PassServerHandle()); 101 new ChildBrokerHost(child_process, token_channel.PassServerHandle());
103 return token_channel.PassClientHandle(); 102 return token_channel.PassClientHandle();
104 #else
105 // TODO(jam): create this for POSIX. Need to implement channel reading first
106 // so we don't leak handles.
107 return ScopedPlatformHandle();
108 #endif
109 } 103 }
110 104
111 void ChildProcessLaunched(base::ProcessHandle child_process, 105 void ChildProcessLaunched(base::ProcessHandle child_process,
112 ScopedPlatformHandle server_pipe) { 106 ScopedPlatformHandle server_pipe) {
113 new ChildBrokerHost(child_process, server_pipe.Pass()); 107 new ChildBrokerHost(child_process, server_pipe.Pass());
114 } 108 }
115 109
116 void SetParentPipeHandle(ScopedPlatformHandle pipe) { 110 void SetParentPipeHandle(ScopedPlatformHandle pipe) {
117 ChildBroker::GetInstance()->SetChildBrokerHostHandle(pipe.Pass()); 111 ChildBroker::GetInstance()->SetChildBrokerHostHandle(pipe.Pass());
118 } 112 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 188 }
195 189
196 void ShutdownIPCSupportAndWaitForNoChannels() { 190 void ShutdownIPCSupportAndWaitForNoChannels() {
197 g_delegate_task_runner = base::MessageLoop::current()->task_runner().get(); 191 g_delegate_task_runner = base::MessageLoop::current()->task_runner().get();
198 internal::g_io_thread_task_runner->PostTask( 192 internal::g_io_thread_task_runner->PostTask(
199 FROM_HERE, base::Bind(&ShutdownIPCSupportHelper, true)); 193 FROM_HERE, base::Bind(&ShutdownIPCSupportHelper, true));
200 } 194 }
201 195
202 ScopedMessagePipeHandle CreateMessagePipe( 196 ScopedMessagePipeHandle CreateMessagePipe(
203 ScopedPlatformHandle platform_handle) { 197 ScopedPlatformHandle platform_handle) {
198 MojoCreateMessagePipeOptions options = {
199 static_cast<uint32_t>(sizeof(MojoCreateMessagePipeOptions)),
200 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE};
204 scoped_refptr<MessagePipeDispatcher> dispatcher = 201 scoped_refptr<MessagePipeDispatcher> dispatcher =
205 MessagePipeDispatcher::Create( 202 MessagePipeDispatcher::Create(options);
206 MessagePipeDispatcher::kDefaultCreateOptions);
207 203
208 ScopedMessagePipeHandle rv( 204 ScopedMessagePipeHandle rv(
209 MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher))); 205 MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher)));
210 CHECK(rv.is_valid()); 206 CHECK(rv.is_valid());
211 dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr, 207 dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr,
212 nullptr); 208 nullptr);
213 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it 209 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it
214 // once that's fixed. 210 // once that's fixed.
215 return rv.Pass(); 211 return rv.Pass();
216 } 212 }
217 213
218 } // namespace edk 214 } // namespace edk
219 } // namespace mojo 215 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698