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 #ifndef MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__ | 5 #ifndef MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__ |
6 #define MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__ | 6 #define MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "mojo/edk/embedder/platform_handle_vector.h" | 11 #include "mojo/edk/embedder/platform_handle_vector.h" |
12 #include "mojo/edk/system/channel.h" | 12 #include "mojo/edk/system/channel.h" |
13 #include "mojo/edk/system/ports/message.h" | 13 #include "mojo/edk/system/ports/message.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace edk { | 16 namespace edk { |
17 | 17 |
18 class NodeController; | 18 class NodeController; |
19 | 19 |
20 class PortsMessage : public ports::Message { | 20 class PortsMessage : public ports::Message { |
21 public: | 21 public: |
22 static std::unique_ptr<PortsMessage> NewUserMessage(size_t num_payload_bytes, | 22 static std::unique_ptr<PortsMessage> NewUserMessage(size_t num_payload_bytes, |
23 size_t num_ports, | 23 size_t num_ports, |
24 size_t num_handles); | 24 size_t num_handles); |
25 | 25 |
26 ~PortsMessage() override; | 26 ~PortsMessage() override; |
27 | 27 |
28 PlatformHandle* handles() { return channel_message_->handles(); } | |
29 size_t num_handles() const { return channel_message_->num_handles(); } | 28 size_t num_handles() const { return channel_message_->num_handles(); } |
30 bool has_handles() const { return channel_message_->has_handles(); } | 29 bool has_handles() const { return channel_message_->has_handles(); } |
31 | 30 |
32 void SetHandles(ScopedPlatformHandleVectorPtr handles) { | 31 void SetHandles(ScopedPlatformHandleVectorPtr handles) { |
33 channel_message_->SetHandles(std::move(handles)); | 32 channel_message_->SetHandles(std::move(handles)); |
34 } | 33 } |
35 | 34 |
| 35 ScopedPlatformHandleVectorPtr TakeHandles() { |
| 36 return channel_message_->TakeHandles(); |
| 37 } |
| 38 |
36 Channel::MessagePtr TakeChannelMessage() { | 39 Channel::MessagePtr TakeChannelMessage() { |
37 return std::move(channel_message_); | 40 return std::move(channel_message_); |
38 } | 41 } |
39 | 42 |
40 private: | 43 private: |
41 friend class NodeController; | 44 friend class NodeController; |
42 | 45 |
43 // Construct a new user PortsMessage backed by a new Channel::Message. | 46 // Construct a new user PortsMessage backed by a new Channel::Message. |
44 PortsMessage(size_t num_payload_bytes, size_t num_ports, size_t num_handles); | 47 PortsMessage(size_t num_payload_bytes, size_t num_ports, size_t num_handles); |
45 | 48 |
46 // Construct a new PortsMessage backed by a Channel::Message. If | 49 // Construct a new PortsMessage backed by a Channel::Message. If |
47 // |channel_message| is null, a new one is allocated internally. | 50 // |channel_message| is null, a new one is allocated internally. |
48 PortsMessage(size_t num_header_bytes, | 51 PortsMessage(size_t num_header_bytes, |
49 size_t num_payload_bytes, | 52 size_t num_payload_bytes, |
50 size_t num_ports_bytes, | 53 size_t num_ports_bytes, |
51 Channel::MessagePtr channel_message); | 54 Channel::MessagePtr channel_message); |
52 | 55 |
53 Channel::MessagePtr channel_message_; | 56 Channel::MessagePtr channel_message_; |
54 }; | 57 }; |
55 | 58 |
56 } // namespace edk | 59 } // namespace edk |
57 } // namespace mojo | 60 } // namespace mojo |
58 | 61 |
59 #endif // MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__ | 62 #endif // MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__ |
OLD | NEW |