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

Side by Side Diff: mojo/public/cpp/bindings/lib/message_internal.h

Issue 2660733002: Mojo C++ bindings: introduce an optional array to store transferred interface IDs in messages. (Closed)
Patch Set: . Created 3 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "mojo/public/cpp/bindings/bindings_export.h" 14 #include "mojo/public/cpp/bindings/bindings_export.h"
15 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 15 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 18
19 class Message; 19 class Message;
20 20
21 namespace internal { 21 namespace internal {
22 22
23 template <typename T>
24 class Array_Data;
25
23 #pragma pack(push, 1) 26 #pragma pack(push, 1)
24 27
25 struct MessageHeader : internal::StructHeader { 28 struct MessageHeader : internal::StructHeader {
26 // Interface ID for identifying multiple interfaces running on the same 29 // Interface ID for identifying multiple interfaces running on the same
27 // message pipe. 30 // message pipe.
28 uint32_t interface_id; 31 uint32_t interface_id;
29 // Message name, which is scoped to the interface that the message belongs to. 32 // Message name, which is scoped to the interface that the message belongs to.
30 uint32_t name; 33 uint32_t name;
31 // 0 or either of the enum values defined above. 34 // 0 or either of the enum values defined above.
32 uint32_t flags; 35 uint32_t flags;
33 // Unused padding to make the struct size a multiple of 8 bytes. 36 // Unused padding to make the struct size a multiple of 8 bytes.
34 uint32_t padding; 37 uint32_t padding;
35 }; 38 };
36 static_assert(sizeof(MessageHeader) == 24, "Bad sizeof(MessageHeader)"); 39 static_assert(sizeof(MessageHeader) == 24, "Bad sizeof(MessageHeader)");
37 40
38 struct MessageHeaderWithRequestID : MessageHeader { 41 struct MessageHeaderV1 : MessageHeader {
39 // Only used if either kFlagExpectsResponse or kFlagIsResponse is set in 42 // Only used if either kFlagExpectsResponse or kFlagIsResponse is set in
40 // order to match responses with corresponding requests. 43 // order to match responses with corresponding requests.
41 uint64_t request_id; 44 uint64_t request_id;
42 }; 45 };
43 static_assert(sizeof(MessageHeaderWithRequestID) == 32, 46 static_assert(sizeof(MessageHeaderV1) == 32, "Bad sizeof(MessageHeaderV1)");
44 "Bad sizeof(MessageHeaderWithRequestID)"); 47
48 struct MessageHeaderV2 : MessageHeaderV1 {
49 MessageHeaderV2();
50 GenericPointer payload;
51 Pointer<Array_Data<uint32_t>> payload_interface_ids;
52 };
53 static_assert(sizeof(MessageHeaderV2) == 48, "Bad sizeof(MessageHeaderV2)");
45 54
46 #pragma pack(pop) 55 #pragma pack(pop)
47 56
48 class MOJO_CPP_BINDINGS_EXPORT MessageDispatchContext { 57 class MOJO_CPP_BINDINGS_EXPORT MessageDispatchContext {
49 public: 58 public:
50 explicit MessageDispatchContext(Message* message); 59 explicit MessageDispatchContext(Message* message);
51 ~MessageDispatchContext(); 60 ~MessageDispatchContext();
52 61
53 static MessageDispatchContext* current(); 62 static MessageDispatchContext* current();
54 63
55 const base::Callback<void(const std::string&)>& GetBadMessageCallback(); 64 const base::Callback<void(const std::string&)>& GetBadMessageCallback();
56 65
57 private: 66 private:
58 MessageDispatchContext* outer_context_; 67 MessageDispatchContext* outer_context_;
59 Message* message_; 68 Message* message_;
60 base::Callback<void(const std::string&)> bad_message_callback_; 69 base::Callback<void(const std::string&)> bad_message_callback_;
61 70
62 DISALLOW_COPY_AND_ASSIGN(MessageDispatchContext); 71 DISALLOW_COPY_AND_ASSIGN(MessageDispatchContext);
63 }; 72 };
64 73
65 class MOJO_CPP_BINDINGS_EXPORT SyncMessageResponseSetup { 74 class MOJO_CPP_BINDINGS_EXPORT SyncMessageResponseSetup {
66 public: 75 public:
67 static void SetCurrentSyncResponseMessage(Message* message); 76 static void SetCurrentSyncResponseMessage(Message* message);
68 }; 77 };
69 78
70 } // namespace internal 79 } // namespace internal
71 } // namespace mojo 80 } // namespace mojo
72 81
73 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_ 82 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/message_header_validator.cc ('k') | mojo/public/cpp/bindings/lib/multiplex_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698