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

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

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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_MESSAGE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <limits> 11 #include <limits>
12 #include <memory> 12 #include <memory>
13 #include <string>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "mojo/public/cpp/bindings/lib/message_buffer.h" 17 #include "mojo/public/cpp/bindings/lib/message_buffer.h"
17 #include "mojo/public/cpp/bindings/lib/message_internal.h" 18 #include "mojo/public/cpp/bindings/lib/message_internal.h"
18 #include "mojo/public/cpp/system/message.h" 19 #include "mojo/public/cpp/system/message.h"
19 20
20 namespace mojo { 21 namespace mojo {
21 22
22 // Message is a holder for the data and handles to be sent over a MessagePipe. 23 // Message is a holder for the data and handles to be sent over a MessagePipe.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 std::vector<Handle>* mutable_handles() { return &handles_; } 93 std::vector<Handle>* mutable_handles() { return &handles_; }
93 94
94 // Access the underlying Buffer interface. 95 // Access the underlying Buffer interface.
95 internal::Buffer* buffer() { return buffer_.get(); } 96 internal::Buffer* buffer() { return buffer_.get(); }
96 97
97 // Takes a scoped MessageHandle which may be passed to |WriteMessageNew()| for 98 // Takes a scoped MessageHandle which may be passed to |WriteMessageNew()| for
98 // transmission. Note that this invalidates this Message object, taking 99 // transmission. Note that this invalidates this Message object, taking
99 // ownership of its internal storage and any attached handles. 100 // ownership of its internal storage and any attached handles.
100 ScopedMessageHandle TakeMojoMessage(); 101 ScopedMessageHandle TakeMojoMessage();
101 102
103 // Notifies the system that this message is "bad," in this case meaning it was
104 // rejected by bindings validation code.
105 void NotifyBadMessage(const std::string& error);
106
102 private: 107 private:
103 void CloseHandles(); 108 void CloseHandles();
104 109
105 std::unique_ptr<internal::MessageBuffer> buffer_; 110 std::unique_ptr<internal::MessageBuffer> buffer_;
106 std::vector<Handle> handles_; 111 std::vector<Handle> handles_;
107 112
108 DISALLOW_COPY_AND_ASSIGN(Message); 113 DISALLOW_COPY_AND_ASSIGN(Message);
109 }; 114 };
110 115
111 class MessageReceiver { 116 class MessageReceiver {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // the caller should wait on the handle to become readable. Returns 187 // the caller should wait on the handle to become readable. Returns
183 // MOJO_RESULT_OK if the message was read successfully and should be 188 // MOJO_RESULT_OK if the message was read successfully and should be
184 // dispatched, otherwise returns an error code if something went wrong. 189 // dispatched, otherwise returns an error code if something went wrong.
185 // 190 //
186 // NOTE: The message hasn't been validated and may be malformed! 191 // NOTE: The message hasn't been validated and may be malformed!
187 MojoResult ReadMessage(MessagePipeHandle handle, Message* message); 192 MojoResult ReadMessage(MessagePipeHandle handle, Message* message);
188 193
189 } // namespace mojo 194 } // namespace mojo
190 195
191 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 196 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_util.cc ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698