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

Side by Side Diff: mojo/public/bindings/lib/message.h

Issue 54743003: Mojo: bindings connector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove errant line from mojo.gyp Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/bindings/lib/connector.cc ('k') | mojo/public/bindings/lib/message.cc » ('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_PUBLIC_BINDINGS_LIB_MESSAGE_H_ 5 #ifndef MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_H_
6 #define MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_H_ 6 #define MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "mojo/public/system/core.h" 10 #include "mojo/public/system/core.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 13
14 #pragma pack(push, 1) 14 #pragma pack(push, 1)
15 15
16 struct MessageHeader { 16 struct MessageHeader {
17 uint32_t num_bytes; 17 uint32_t num_bytes;
18 uint32_t name; 18 uint32_t name;
19 }; 19 };
20 MOJO_COMPILE_ASSERT(sizeof(MessageHeader) == 8, bad_sizeof_MessageHeader); 20 MOJO_COMPILE_ASSERT(sizeof(MessageHeader) == 8, bad_sizeof_MessageHeader);
21 21
22 struct MessageData { 22 struct MessageData {
23 MessageHeader header; 23 MessageHeader header;
24 uint8_t payload[1]; 24 uint8_t payload[1];
25 }; 25 };
26 MOJO_COMPILE_ASSERT(sizeof(MessageData) == 9, bad_sizeof_MessageData); 26 MOJO_COMPILE_ASSERT(sizeof(MessageData) == 9, bad_sizeof_MessageData);
27 27
28 #pragma pack(pop) 28 #pragma pack(pop)
29 29
30 struct Message { 30 class Message {
31 public:
31 Message(); 32 Message();
32 ~Message(); 33 ~Message();
33 34
35 void Swap(Message* other);
36
34 MessageData* data; // Heap-allocated. 37 MessageData* data; // Heap-allocated.
35 std::vector<Handle> handles; 38 std::vector<Handle> handles;
39
40 private:
41 MOJO_DISALLOW_COPY_AND_ASSIGN(Message);
36 }; 42 };
37 43
38 class MessageReceiver { 44 class MessageReceiver {
39 public: 45 public:
40 // The receiver may mutate the given message or take ownership of its 46 // The receiver may mutate the given message or take ownership of its
41 // |message->data| member by setting it to NULL. 47 // |message->data| member by setting it to NULL. Returns true if the message
48 // was accepted and false otherwise, indicating that the message was invalid
49 // or malformed.
42 virtual bool Accept(Message* message) = 0; 50 virtual bool Accept(Message* message) = 0;
43 }; 51 };
44 52
45 } // namespace mojo 53 } // namespace mojo
46 54
47 #endif // MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_H_ 55 #endif // MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_H_
OLDNEW
« no previous file with comments | « mojo/public/bindings/lib/connector.cc ('k') | mojo/public/bindings/lib/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698