Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: mojo/edk/system/ports_message.h

Issue 2008953003: [mojo-edk] Explicitly serialise HANDLEs into messages instead of PlatformHandles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cast2 Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/node_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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__
OLDNEW
« no previous file with comments | « mojo/edk/system/node_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698