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

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

Issue 2202893002: Mojo C++ Bindings: Add helpers for bad message reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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 "base/macros.h"
10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 11 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
11 12
12 namespace mojo { 13 namespace mojo {
14
15 class Message;
16
13 namespace internal { 17 namespace internal {
14 18
15 #pragma pack(push, 1) 19 #pragma pack(push, 1)
16 20
17 struct MessageHeader : internal::StructHeader { 21 struct MessageHeader : internal::StructHeader {
18 // Interface ID for identifying multiple interfaces running on the same 22 // Interface ID for identifying multiple interfaces running on the same
19 // message pipe. 23 // message pipe.
20 uint32_t interface_id; 24 uint32_t interface_id;
21 // Message name, which is scoped to the interface that the message belongs to. 25 // Message name, which is scoped to the interface that the message belongs to.
22 uint32_t name; 26 uint32_t name;
23 // 0 or either of the enum values defined above. 27 // 0 or either of the enum values defined above.
24 uint32_t flags; 28 uint32_t flags;
25 // Unused padding to make the struct size a multiple of 8 bytes. 29 // Unused padding to make the struct size a multiple of 8 bytes.
26 uint32_t padding; 30 uint32_t padding;
27 }; 31 };
28 static_assert(sizeof(MessageHeader) == 24, "Bad sizeof(MessageHeader)"); 32 static_assert(sizeof(MessageHeader) == 24, "Bad sizeof(MessageHeader)");
29 33
30 struct MessageHeaderWithRequestID : MessageHeader { 34 struct MessageHeaderWithRequestID : MessageHeader {
31 // Only used if either kFlagExpectsResponse or kFlagIsResponse is set in 35 // Only used if either kFlagExpectsResponse or kFlagIsResponse is set in
32 // order to match responses with corresponding requests. 36 // order to match responses with corresponding requests.
33 uint64_t request_id; 37 uint64_t request_id;
34 }; 38 };
35 static_assert(sizeof(MessageHeaderWithRequestID) == 32, 39 static_assert(sizeof(MessageHeaderWithRequestID) == 32,
36 "Bad sizeof(MessageHeaderWithRequestID)"); 40 "Bad sizeof(MessageHeaderWithRequestID)");
37 41
38 #pragma pack(pop) 42 #pragma pack(pop)
39 43
44 class MessageDispatchContext {
45 public:
46 explicit MessageDispatchContext(Message* message);
47 ~MessageDispatchContext();
48
49 static MessageDispatchContext* current();
50
51 Message* message() { return message_; }
52
53 private:
54 MessageDispatchContext* outer_context_;
55 Message* message_;
56
57 DISALLOW_COPY_AND_ASSIGN(MessageDispatchContext);
58 };
59
60 class SyncMessageResponseSetup {
61 public:
62 static void SetCurrentSyncResponseMessage(Message* message);
63 };
64
40 } // namespace internal 65 } // namespace internal
41 } // namespace mojo 66 } // namespace mojo
42 67
43 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_ 68 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698