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

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

Issue 1346383004: EDK: Remove MOJO_SYSTEM_IMPL_EXPORT, system_impl_export.h, etc. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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/memory.cc ('k') | mojo/edk/system/message_in_transit_queue.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_MESSAGE_IN_TRANSIT_H_ 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_IN_TRANSIT_H_
6 #define MOJO_EDK_SYSTEM_MESSAGE_IN_TRANSIT_H_ 6 #define MOJO_EDK_SYSTEM_MESSAGE_IN_TRANSIT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <ostream> 12 #include <ostream>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/memory/aligned_memory.h" 15 #include "base/memory/aligned_memory.h"
16 #include "mojo/edk/system/channel_endpoint_id.h" 16 #include "mojo/edk/system/channel_endpoint_id.h"
17 #include "mojo/edk/system/dispatcher.h" 17 #include "mojo/edk/system/dispatcher.h"
18 #include "mojo/edk/system/memory.h" 18 #include "mojo/edk/system/memory.h"
19 #include "mojo/edk/system/system_impl_export.h"
20 #include "mojo/public/cpp/system/macros.h" 19 #include "mojo/public/cpp/system/macros.h"
21 20
22 namespace mojo { 21 namespace mojo {
23 namespace system { 22 namespace system {
24 23
25 class Channel; 24 class Channel;
26 class TransportData; 25 class TransportData;
27 26
28 // This class is used to represent data in transit. It is thread-unsafe. 27 // This class is used to represent data in transit. It is thread-unsafe.
29 // 28 //
30 // |MessageInTransit| buffers: 29 // |MessageInTransit| buffers:
31 // 30 //
32 // A |MessageInTransit| can be serialized by writing the main buffer and then, 31 // A |MessageInTransit| can be serialized by writing the main buffer and then,
33 // if it has one, the transport data buffer. Both buffers are 32 // if it has one, the transport data buffer. Both buffers are
34 // |kMessageAlignment|-byte aligned and a multiple of |kMessageAlignment| bytes 33 // |kMessageAlignment|-byte aligned and a multiple of |kMessageAlignment| bytes
35 // in size. 34 // in size.
36 // 35 //
37 // The main buffer consists of the header (of type |Header|, which is an 36 // The main buffer consists of the header (of type |Header|, which is an
38 // internal detail of this class) followed immediately by the message data 37 // internal detail of this class) followed immediately by the message data
39 // (accessed by |bytes()| and of size |num_bytes()|, and also 38 // (accessed by |bytes()| and of size |num_bytes()|, and also
40 // |kMessageAlignment|-byte aligned), and then any padding needed to make the 39 // |kMessageAlignment|-byte aligned), and then any padding needed to make the
41 // main buffer a multiple of |kMessageAlignment| bytes in size. 40 // main buffer a multiple of |kMessageAlignment| bytes in size.
42 // 41 //
43 // See |TransportData| for a description of the (serialized) transport data 42 // See |TransportData| for a description of the (serialized) transport data
44 // buffer. 43 // buffer.
45 class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit { 44 class MessageInTransit {
46 public: 45 public:
47 enum class Type : uint16_t { 46 enum class Type : uint16_t {
48 // Messages that are forwarded to endpoint clients. 47 // Messages that are forwarded to endpoint clients.
49 ENDPOINT_CLIENT = 0, 48 ENDPOINT_CLIENT = 0,
50 // Messages that are consumed by the |ChannelEndpoint|. 49 // Messages that are consumed by the |ChannelEndpoint|.
51 ENDPOINT = 1, 50 ENDPOINT = 1,
52 // Messages that are consumed by the |Channel|. 51 // Messages that are consumed by the |Channel|.
53 CHANNEL = 2, 52 CHANNEL = 2,
54 // Messages that are consumed by the |RawChannel| (implementation). 53 // Messages that are consumed by the |RawChannel| (implementation).
55 RAW_CHANNEL = 3, 54 RAW_CHANNEL = 3,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Messages (the header and data) must always be aligned to a multiple of this 94 // Messages (the header and data) must always be aligned to a multiple of this
96 // quantity (which must be a power of 2). 95 // quantity (which must be a power of 2).
97 static const size_t kMessageAlignment = 8; 96 static const size_t kMessageAlignment = 8;
98 97
99 // Forward-declare |Header| so that |View| can use it: 98 // Forward-declare |Header| so that |View| can use it:
100 private: 99 private:
101 struct Header; 100 struct Header;
102 101
103 public: 102 public:
104 // This represents a view of serialized message data in a raw buffer. 103 // This represents a view of serialized message data in a raw buffer.
105 class MOJO_SYSTEM_IMPL_EXPORT View { 104 class View {
106 public: 105 public:
107 // Constructs a view from the given buffer of the given size. (The size must 106 // Constructs a view from the given buffer of the given size. (The size must
108 // be as provided by |MessageInTransit::GetNextMessageSize()|.) The buffer 107 // be as provided by |MessageInTransit::GetNextMessageSize()|.) The buffer
109 // must remain alive/unmodified through the lifetime of this object. 108 // must remain alive/unmodified through the lifetime of this object.
110 // |buffer| should be |kMessageAlignment|-byte aligned. 109 // |buffer| should be |kMessageAlignment|-byte aligned.
111 View(size_t message_size, const void* buffer); 110 View(size_t message_size, const void* buffer);
112 111
113 // Checks that the given |View| appears to be for a valid message, within 112 // Checks that the given |View| appears to be for a valid message, within
114 // predetermined limits (e.g., |num_bytes()| and |main_buffer_size()|, that 113 // predetermined limits (e.g., |num_bytes()| and |main_buffer_size()|, that
115 // |transport_data_buffer()|/|transport_data_buffer_size()| is for valid 114 // |transport_data_buffer()|/|transport_data_buffer_size()| is for valid
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Any dispatchers that may be attached to this message. These dispatchers 283 // Any dispatchers that may be attached to this message. These dispatchers
285 // should be "owned" by this message, i.e., have a ref count of exactly 1. (We 284 // should be "owned" by this message, i.e., have a ref count of exactly 1. (We
286 // allow a dispatcher entry to be null, in case it couldn't be duplicated for 285 // allow a dispatcher entry to be null, in case it couldn't be duplicated for
287 // some reason.) 286 // some reason.)
288 std::unique_ptr<DispatcherVector> dispatchers_; 287 std::unique_ptr<DispatcherVector> dispatchers_;
289 288
290 MOJO_DISALLOW_COPY_AND_ASSIGN(MessageInTransit); 289 MOJO_DISALLOW_COPY_AND_ASSIGN(MessageInTransit);
291 }; 290 };
292 291
293 // So logging macros and |DCHECK_EQ()|, etc. work. 292 // So logging macros and |DCHECK_EQ()|, etc. work.
294 MOJO_SYSTEM_IMPL_EXPORT inline std::ostream& operator<<( 293 inline std::ostream& operator<<(std::ostream& out,
295 std::ostream& out, 294 MessageInTransit::Type type) {
296 MessageInTransit::Type type) {
297 return out << static_cast<uint16_t>(type); 295 return out << static_cast<uint16_t>(type);
298 } 296 }
299 297
300 // So logging macros and |DCHECK_EQ()|, etc. work. 298 // So logging macros and |DCHECK_EQ()|, etc. work.
301 MOJO_SYSTEM_IMPL_EXPORT inline std::ostream& operator<<( 299 inline std::ostream& operator<<(std::ostream& out,
302 std::ostream& out, 300 MessageInTransit::Subtype subtype) {
303 MessageInTransit::Subtype subtype) {
304 return out << static_cast<uint16_t>(subtype); 301 return out << static_cast<uint16_t>(subtype);
305 } 302 }
306 303
307 } // namespace system 304 } // namespace system
308 } // namespace mojo 305 } // namespace mojo
309 306
310 #endif // MOJO_EDK_SYSTEM_MESSAGE_IN_TRANSIT_H_ 307 #endif // MOJO_EDK_SYSTEM_MESSAGE_IN_TRANSIT_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/memory.cc ('k') | mojo/edk/system/message_in_transit_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698