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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 memset(&data, 0, sizeof(data)); | 98 memset(&data, 0, sizeof(data)); |
99 data.type = PEER_PIPE_CONNECTED; | 99 data.type = PEER_PIPE_CONNECTED; |
100 data.pipe_id = pipe_id; | 100 data.pipe_id = pipe_id; |
101 data.process_id = process_id; | 101 data.process_id = process_id; |
102 scoped_ptr<MessageInTransit> message(new MessageInTransit( | 102 scoped_ptr<MessageInTransit> message(new MessageInTransit( |
103 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); | 103 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); |
104 message->set_route_id(kBrokerRouteId); | 104 message->set_route_id(kBrokerRouteId); |
105 child_channel_->channel()->WriteMessage(std::move(message)); | 105 child_channel_->channel()->WriteMessage(std::move(message)); |
106 } | 106 } |
107 | 107 |
| 108 void ChildBrokerHost::PeerDied(uint64_t pipe_id) { |
| 109 if (!child_channel_) |
| 110 return; // Can happen at process shutdown on Windows. |
| 111 PeerDiedMessage data; |
| 112 memset(&data, 0, sizeof(data)); |
| 113 data.type = PEER_DIED; |
| 114 data.pipe_id = pipe_id; |
| 115 scoped_ptr<MessageInTransit> message(new MessageInTransit( |
| 116 MessageInTransit::Type::MESSAGE, sizeof(data), &data)); |
| 117 message->set_route_id(kBrokerRouteId); |
| 118 child_channel_->channel()->WriteMessage(std::move(message)); |
| 119 } |
| 120 |
108 ChildBrokerHost::~ChildBrokerHost() { | 121 ChildBrokerHost::~ChildBrokerHost() { |
109 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); | 122 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); |
110 BrokerState::GetInstance()->ChildBrokerHostDestructed(this); | 123 BrokerState::GetInstance()->ChildBrokerHostDestructed(this); |
111 if (child_channel_) | 124 if (child_channel_) |
112 child_channel_->RemoveRoute(kBrokerRouteId); | 125 child_channel_->RemoveRoute(kBrokerRouteId); |
113 } | 126 } |
114 | 127 |
115 void ChildBrokerHost::InitOnIO( | 128 void ChildBrokerHost::InitOnIO( |
116 ScopedPlatformHandle parent_async_channel_handle) { | 129 ScopedPlatformHandle parent_async_channel_handle) { |
117 child_channel_ = new RoutedRawChannel( | 130 child_channel_ = new RoutedRawChannel( |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 BOOL result = DuplicateHandle(child_process_.Handle(), handle, | 320 BOOL result = DuplicateHandle(child_process_.Handle(), handle, |
308 base::GetCurrentProcessHandle(), &rv, 0, FALSE, | 321 base::GetCurrentProcessHandle(), &rv, 0, FALSE, |
309 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); | 322 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); |
310 DCHECK(result); | 323 DCHECK(result); |
311 return rv; | 324 return rv; |
312 } | 325 } |
313 #endif | 326 #endif |
314 | 327 |
315 } // namespace edk | 328 } // namespace edk |
316 } // namespace mojo | 329 } // namespace mojo |
OLD | NEW |