OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/node_controller.h" | 5 #include "mojo/edk/system/node_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
17 #include "crypto/random.h" | 17 #include "crypto/random.h" |
18 #include "mojo/edk/embedder/embedder_internal.h" | 18 #include "mojo/edk/embedder/embedder_internal.h" |
19 #include "mojo/edk/embedder/platform_channel_pair.h" | 19 #include "mojo/edk/embedder/platform_channel_pair.h" |
20 #include "mojo/edk/system/broker.h" | 20 #include "mojo/edk/system/broker.h" |
21 #include "mojo/edk/system/broker_host.h" | 21 #include "mojo/edk/system/broker_host.h" |
22 #include "mojo/edk/system/core.h" | 22 #include "mojo/edk/system/core.h" |
23 #include "mojo/edk/system/ports_message.h" | 23 #include "mojo/edk/system/ports_message.h" |
| 24 #include "mojo/edk/system/request_context.h" |
24 | 25 |
25 namespace mojo { | 26 namespace mojo { |
26 namespace edk { | 27 namespace edk { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 template <typename T> | 31 template <typename T> |
31 void GenerateRandomName(T* out) { crypto::RandBytes(out, sizeof(T)); } | 32 void GenerateRandomName(T* out) { crypto::RandBytes(out, sizeof(T)); } |
32 | 33 |
33 ports::NodeName GetRandomNodeName() { | 34 ports::NodeName GetRandomNodeName() { |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 } | 710 } |
710 } | 711 } |
711 #endif | 712 #endif |
712 | 713 |
713 DVLOG(1) << "Child " << name_ << " accepted by broker " << broker_name; | 714 DVLOG(1) << "Child " << name_ << " accepted by broker " << broker_name; |
714 } | 715 } |
715 | 716 |
716 void NodeController::OnPortsMessage(Channel::MessagePtr channel_message) { | 717 void NodeController::OnPortsMessage(Channel::MessagePtr channel_message) { |
717 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 718 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
718 | 719 |
| 720 // This is a singular chokepoint through which dispatcher port statuses may |
| 721 // be changed without an explicit call to some Mojo system API. We need to |
| 722 // ensure that a RequestContext exists in case a dispatcher has any watchers |
| 723 // to notify. |
| 724 RequestContext request_context; |
| 725 |
719 void* data; | 726 void* data; |
720 size_t num_data_bytes; | 727 size_t num_data_bytes; |
721 NodeChannel::GetPortsMessageData( | 728 NodeChannel::GetPortsMessageData( |
722 channel_message.get(), &data, &num_data_bytes); | 729 channel_message.get(), &data, &num_data_bytes); |
723 | 730 |
724 size_t num_header_bytes, num_payload_bytes, num_ports_bytes; | 731 size_t num_header_bytes, num_payload_bytes, num_ports_bytes; |
725 ports::Message::Parse(data, | 732 ports::Message::Parse(data, |
726 num_data_bytes, | 733 num_data_bytes, |
727 &num_header_bytes, | 734 &num_header_bytes, |
728 &num_payload_bytes, | 735 &num_payload_bytes, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 shutdown_callback_.Reset(); | 885 shutdown_callback_.Reset(); |
879 } | 886 } |
880 | 887 |
881 DCHECK(!callback.is_null()); | 888 DCHECK(!callback.is_null()); |
882 | 889 |
883 callback.Run(); | 890 callback.Run(); |
884 } | 891 } |
885 | 892 |
886 } // namespace edk | 893 } // namespace edk |
887 } // namespace mojo | 894 } // namespace mojo |
OLD | NEW |