Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 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 struct Message { |
| 31 Message(); | 31 Message(); |
| 32 ~Message(); | 32 ~Message(); |
| 33 | 33 |
| 34 void Swap(Message* other); | |
| 35 | |
| 34 MessageData* data; // Heap-allocated. | 36 MessageData* data; // Heap-allocated. |
| 35 std::vector<Handle> handles; | 37 std::vector<Handle> handles; |
| 36 }; | 38 }; |
|
viettrungluu
2013/11/05 22:45:29
Probably we want to make Message noncopyable, righ
| |
| 37 | 39 |
| 38 class MessageReceiver { | 40 class MessageReceiver { |
| 39 public: | 41 public: |
| 40 // The receiver may mutate the given message or take ownership of its | 42 // The receiver may mutate the given message or take ownership of its |
| 41 // |message->data| member by setting it to NULL. | 43 // |message->data| member by setting it to NULL. Returns true if the message |
| 44 // was accepted and false otherwise, indicating that the message was invalid | |
| 45 // or malformed. | |
| 42 virtual bool Accept(Message* message) = 0; | 46 virtual bool Accept(Message* message) = 0; |
| 43 }; | 47 }; |
| 44 | 48 |
| 45 } // namespace mojo | 49 } // namespace mojo |
| 46 | 50 |
| 47 #endif // MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_H_ | 51 #endif // MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_H_ |
| OLD | NEW |