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

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
« no previous file with comments | « mojo/public/cpp/bindings/lib/message.cc ('k') | mojo/public/cpp/bindings/message.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 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>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 14 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
11 15
12 namespace mojo { 16 namespace mojo {
17
18 class Message;
19
13 namespace internal { 20 namespace internal {
14 21
15 #pragma pack(push, 1) 22 #pragma pack(push, 1)
16 23
17 struct MessageHeader : internal::StructHeader { 24 struct MessageHeader : internal::StructHeader {
18 // Interface ID for identifying multiple interfaces running on the same 25 // Interface ID for identifying multiple interfaces running on the same
19 // message pipe. 26 // message pipe.
20 uint32_t interface_id; 27 uint32_t interface_id;
21 // Message name, which is scoped to the interface that the message belongs to. 28 // Message name, which is scoped to the interface that the message belongs to.
22 uint32_t name; 29 uint32_t name;
23 // 0 or either of the enum values defined above. 30 // 0 or either of the enum values defined above.
24 uint32_t flags; 31 uint32_t flags;
25 // Unused padding to make the struct size a multiple of 8 bytes. 32 // Unused padding to make the struct size a multiple of 8 bytes.
26 uint32_t padding; 33 uint32_t padding;
27 }; 34 };
28 static_assert(sizeof(MessageHeader) == 24, "Bad sizeof(MessageHeader)"); 35 static_assert(sizeof(MessageHeader) == 24, "Bad sizeof(MessageHeader)");
29 36
30 struct MessageHeaderWithRequestID : MessageHeader { 37 struct MessageHeaderWithRequestID : MessageHeader {
31 // Only used if either kFlagExpectsResponse or kFlagIsResponse is set in 38 // Only used if either kFlagExpectsResponse or kFlagIsResponse is set in
32 // order to match responses with corresponding requests. 39 // order to match responses with corresponding requests.
33 uint64_t request_id; 40 uint64_t request_id;
34 }; 41 };
35 static_assert(sizeof(MessageHeaderWithRequestID) == 32, 42 static_assert(sizeof(MessageHeaderWithRequestID) == 32,
36 "Bad sizeof(MessageHeaderWithRequestID)"); 43 "Bad sizeof(MessageHeaderWithRequestID)");
37 44
38 #pragma pack(pop) 45 #pragma pack(pop)
39 46
47 class MessageDispatchContext {
48 public:
49 explicit MessageDispatchContext(Message* message);
50 ~MessageDispatchContext();
51
52 static MessageDispatchContext* current();
53
54 const base::Callback<void(const std::string&)>& GetBadMessageCallback();
55
56 private:
57 MessageDispatchContext* outer_context_;
58 Message* message_;
59 base::Callback<void(const std::string&)> bad_message_callback_;
60
61 DISALLOW_COPY_AND_ASSIGN(MessageDispatchContext);
62 };
63
64 class SyncMessageResponseSetup {
65 public:
66 static void SetCurrentSyncResponseMessage(Message* message);
67 };
68
40 } // namespace internal 69 } // namespace internal
41 } // namespace mojo 70 } // namespace mojo
42 71
43 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_ 72 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/message.cc ('k') | mojo/public/cpp/bindings/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698