| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/system/child_broker_host.h" | 5 #include "mojo/edk/system/child_broker_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 base::ProcessId ChildBrokerHost::GetProcessId() { | 68 base::ProcessId ChildBrokerHost::GetProcessId() { |
| 69 return process_id_; | 69 return process_id_; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ChildBrokerHost::ConnectToProcess(base::ProcessId process_id, | 72 void ChildBrokerHost::ConnectToProcess(base::ProcessId process_id, |
| 73 ScopedPlatformHandle pipe) { | 73 ScopedPlatformHandle pipe) { |
| 74 if (!child_channel_) | 74 if (!child_channel_) |
| 75 return; // Can happen at process shutdown on Windows. | 75 return; // Can happen at process shutdown on Windows. |
| 76 ConnectToProcessMessage data; | 76 ConnectToProcessMessage data; |
| 77 memset(&data, 0, sizeof(data)); |
| 77 data.type = CONNECT_TO_PROCESS; | 78 data.type = CONNECT_TO_PROCESS; |
| 78 data.process_id = process_id; | 79 data.process_id = process_id; |
| 79 scoped_ptr<MessageInTransit> message(new MessageInTransit( | 80 scoped_ptr<MessageInTransit> message(new MessageInTransit( |
| 80 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); | 81 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); |
| 81 scoped_refptr<Dispatcher> dispatcher = | 82 scoped_refptr<Dispatcher> dispatcher = |
| 82 PlatformHandleDispatcher::Create(std::move(pipe)); | 83 PlatformHandleDispatcher::Create(std::move(pipe)); |
| 83 internal::g_core->AddDispatcher(dispatcher); | 84 internal::g_core->AddDispatcher(dispatcher); |
| 84 scoped_ptr<DispatcherVector> dispatchers(new DispatcherVector); | 85 scoped_ptr<DispatcherVector> dispatchers(new DispatcherVector); |
| 85 dispatchers->push_back(dispatcher); | 86 dispatchers->push_back(dispatcher); |
| 86 message->SetDispatchers(std::move(dispatchers)); | 87 message->SetDispatchers(std::move(dispatchers)); |
| 87 message->SerializeAndCloseDispatchers(); | 88 message->SerializeAndCloseDispatchers(); |
| 88 message->set_route_id(kBrokerRouteId); | 89 message->set_route_id(kBrokerRouteId); |
| 89 child_channel_->channel()->WriteMessage(std::move(message)); | 90 child_channel_->channel()->WriteMessage(std::move(message)); |
| 90 } | 91 } |
| 91 | 92 |
| 92 void ChildBrokerHost::ConnectMessagePipe(uint64_t pipe_id, | 93 void ChildBrokerHost::ConnectMessagePipe(uint64_t pipe_id, |
| 93 base::ProcessId process_id) { | 94 base::ProcessId process_id) { |
| 94 if (!child_channel_) | 95 if (!child_channel_) |
| 95 return; // Can happen at process shutdown on Windows. | 96 return; // Can happen at process shutdown on Windows. |
| 96 PeerPipeConnectedMessage data; | 97 PeerPipeConnectedMessage data; |
| 98 memset(&data, 0, sizeof(data)); |
| 97 data.type = PEER_PIPE_CONNECTED; | 99 data.type = PEER_PIPE_CONNECTED; |
| 98 data.pipe_id = pipe_id; | 100 data.pipe_id = pipe_id; |
| 99 data.process_id = process_id; | 101 data.process_id = process_id; |
| 100 scoped_ptr<MessageInTransit> message(new MessageInTransit( | 102 scoped_ptr<MessageInTransit> message(new MessageInTransit( |
| 101 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); | 103 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); |
| 102 message->set_route_id(kBrokerRouteId); | 104 message->set_route_id(kBrokerRouteId); |
| 103 child_channel_->channel()->WriteMessage(std::move(message)); | 105 child_channel_->channel()->WriteMessage(std::move(message)); |
| 104 } | 106 } |
| 105 | 107 |
| 106 ChildBrokerHost::~ChildBrokerHost() { | 108 ChildBrokerHost::~ChildBrokerHost() { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 BOOL result = DuplicateHandle(child_process_.Handle(), handle, | 307 BOOL result = DuplicateHandle(child_process_.Handle(), handle, |
| 306 base::GetCurrentProcessHandle(), &rv, 0, FALSE, | 308 base::GetCurrentProcessHandle(), &rv, 0, FALSE, |
| 307 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); | 309 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); |
| 308 DCHECK(result); | 310 DCHECK(result); |
| 309 return rv; | 311 return rv; |
| 310 } | 312 } |
| 311 #endif | 313 #endif |
| 312 | 314 |
| 313 } // namespace edk | 315 } // namespace edk |
| 314 } // namespace mojo | 316 } // namespace mojo |
| OLD | NEW |