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

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

Issue 2043713004: Mojo: Add NotifyBadMessage API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no bindings 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') | mojo/edk/test/mojo_test_base.h » ('j') | 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 #include "mojo/edk/system/ports/name.h"
14 15
15 namespace mojo { 16 namespace mojo {
16 namespace edk { 17 namespace edk {
17 18
18 class NodeController; 19 class NodeController;
19 20
20 class PortsMessage : public ports::Message { 21 class PortsMessage : public ports::Message {
21 public: 22 public:
22 static std::unique_ptr<PortsMessage> NewUserMessage(size_t num_payload_bytes, 23 static std::unique_ptr<PortsMessage> NewUserMessage(size_t num_payload_bytes,
23 size_t num_ports, 24 size_t num_ports,
24 size_t num_handles); 25 size_t num_handles);
25 26
26 ~PortsMessage() override; 27 ~PortsMessage() override;
27 28
28 size_t num_handles() const { return channel_message_->num_handles(); } 29 size_t num_handles() const { return channel_message_->num_handles(); }
29 bool has_handles() const { return channel_message_->has_handles(); } 30 bool has_handles() const { return channel_message_->has_handles(); }
30 31
31 void SetHandles(ScopedPlatformHandleVectorPtr handles) { 32 void SetHandles(ScopedPlatformHandleVectorPtr handles) {
32 channel_message_->SetHandles(std::move(handles)); 33 channel_message_->SetHandles(std::move(handles));
33 } 34 }
34 35
35 ScopedPlatformHandleVectorPtr TakeHandles() { 36 ScopedPlatformHandleVectorPtr TakeHandles() {
36 return channel_message_->TakeHandles(); 37 return channel_message_->TakeHandles();
37 } 38 }
38 39
39 Channel::MessagePtr TakeChannelMessage() { 40 Channel::MessagePtr TakeChannelMessage() {
40 return std::move(channel_message_); 41 return std::move(channel_message_);
41 } 42 }
42 43
44 void set_source_node(const ports::NodeName& name) { source_node_ = name; }
45 const ports::NodeName& source_node() const { return source_node_; }
46
43 private: 47 private:
44 friend class NodeController; 48 friend class NodeController;
45 49
46 // Construct a new user PortsMessage backed by a new Channel::Message. 50 // Construct a new user PortsMessage backed by a new Channel::Message.
47 PortsMessage(size_t num_payload_bytes, size_t num_ports, size_t num_handles); 51 PortsMessage(size_t num_payload_bytes, size_t num_ports, size_t num_handles);
48 52
49 // Construct a new PortsMessage backed by a Channel::Message. If 53 // Construct a new PortsMessage backed by a Channel::Message. If
50 // |channel_message| is null, a new one is allocated internally. 54 // |channel_message| is null, a new one is allocated internally.
51 PortsMessage(size_t num_header_bytes, 55 PortsMessage(size_t num_header_bytes,
52 size_t num_payload_bytes, 56 size_t num_payload_bytes,
53 size_t num_ports_bytes, 57 size_t num_ports_bytes,
54 Channel::MessagePtr channel_message); 58 Channel::MessagePtr channel_message);
55 59
56 Channel::MessagePtr channel_message_; 60 Channel::MessagePtr channel_message_;
61
62 // The node name from which this message was received, if known.
63 ports::NodeName source_node_ = ports::kInvalidNodeName;
57 }; 64 };
58 65
59 } // namespace edk 66 } // namespace edk
60 } // namespace mojo 67 } // namespace mojo
61 68
62 #endif // MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__ 69 #endif // MOJO_EDK_SYSTEM_PORTS_MESSAGE_H__
OLDNEW
« no previous file with comments | « mojo/edk/system/node_controller.cc ('k') | mojo/edk/test/mojo_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698