| OLD | NEW | 
|---|
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 58 | 58 | 
| 59 void PreInitializeParentProcess() { | 59 void PreInitializeParentProcess() { | 
| 60   BrokerState::GetInstance(); | 60   BrokerState::GetInstance(); | 
| 61 } | 61 } | 
| 62 | 62 | 
| 63 void PreInitializeChildProcess() { | 63 void PreInitializeChildProcess() { | 
| 64   ChildBroker::GetInstance(); | 64   ChildBroker::GetInstance(); | 
| 65 } | 65 } | 
| 66 | 66 | 
| 67 ScopedPlatformHandle ChildProcessLaunched(base::ProcessHandle child_process) { | 67 ScopedPlatformHandle ChildProcessLaunched(base::ProcessHandle child_process) { | 
| 68 #if defined(OS_WIN) |  | 
| 69   PlatformChannelPair token_channel; | 68   PlatformChannelPair token_channel; | 
| 70   new ChildBrokerHost(child_process, token_channel.PassServerHandle()); | 69   new ChildBrokerHost(child_process, token_channel.PassServerHandle()); | 
| 71   return token_channel.PassClientHandle(); | 70   return token_channel.PassClientHandle(); | 
| 72 #else |  | 
| 73   // TODO(jam): create this for POSIX. Need to implement channel reading first |  | 
| 74   // so we don't leak handles. |  | 
| 75   return ScopedPlatformHandle(); |  | 
| 76 #endif |  | 
| 77 } | 71 } | 
| 78 | 72 | 
| 79 void ChildProcessLaunched(base::ProcessHandle child_process, | 73 void ChildProcessLaunched(base::ProcessHandle child_process, | 
| 80                           ScopedPlatformHandle server_pipe) { | 74                           ScopedPlatformHandle server_pipe) { | 
| 81   new ChildBrokerHost(child_process, server_pipe.Pass()); | 75   new ChildBrokerHost(child_process, server_pipe.Pass()); | 
| 82 } | 76 } | 
| 83 | 77 | 
| 84 void SetParentPipeHandle(ScopedPlatformHandle pipe) { | 78 void SetParentPipeHandle(ScopedPlatformHandle pipe) { | 
| 85   ChildBroker::GetInstance()->SetChildBrokerHostHandle(pipe.Pass()); | 79   ChildBroker::GetInstance()->SetChildBrokerHostHandle(pipe.Pass()); | 
| 86 } | 80 } | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 158 void ShutdownIPCSupport() { | 152 void ShutdownIPCSupport() { | 
| 159   internal::g_io_thread_task_runner->PostTaskAndReply( | 153   internal::g_io_thread_task_runner->PostTaskAndReply( | 
| 160       FROM_HERE, | 154       FROM_HERE, | 
| 161       base::Bind(&ShutdownIPCSupportHelper), | 155       base::Bind(&ShutdownIPCSupportHelper), | 
| 162       base::Bind(&ProcessDelegate::OnShutdownComplete, | 156       base::Bind(&ProcessDelegate::OnShutdownComplete, | 
| 163                  base::Unretained(internal::g_process_delegate))); | 157                  base::Unretained(internal::g_process_delegate))); | 
| 164 } | 158 } | 
| 165 | 159 | 
| 166 ScopedMessagePipeHandle CreateMessagePipe( | 160 ScopedMessagePipeHandle CreateMessagePipe( | 
| 167     ScopedPlatformHandle platform_handle) { | 161     ScopedPlatformHandle platform_handle) { | 
|  | 162   MojoCreateMessagePipeOptions options = { | 
|  | 163       static_cast<uint32_t>(sizeof(MojoCreateMessagePipeOptions)), | 
|  | 164       MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE}; | 
| 168   scoped_refptr<MessagePipeDispatcher> dispatcher = | 165   scoped_refptr<MessagePipeDispatcher> dispatcher = | 
| 169       MessagePipeDispatcher::Create( | 166       MessagePipeDispatcher::Create(options); | 
| 170           MessagePipeDispatcher::kDefaultCreateOptions); |  | 
| 171 | 167 | 
| 172   ScopedMessagePipeHandle rv( | 168   ScopedMessagePipeHandle rv( | 
| 173       MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher))); | 169       MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher))); | 
| 174   CHECK(rv.is_valid()); | 170   CHECK(rv.is_valid()); | 
| 175   dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr, | 171   dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr, | 
| 176                    nullptr); | 172                    nullptr); | 
| 177   // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it | 173   // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it | 
| 178   // once that's fixed. | 174   // once that's fixed. | 
| 179   return rv.Pass(); | 175   return rv.Pass(); | 
| 180 } | 176 } | 
| 181 | 177 | 
| 182 }  // namespace edk | 178 }  // namespace edk | 
| 183 }  // namespace mojo | 179 }  // namespace mojo | 
| OLD | NEW | 
|---|