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

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

Issue 289333002: Mojo cpp bindings: validation logic for incoming messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 <assert.h> 8 #include <assert.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 request_id = request_id; 56 request_id = request_id;
57 } 57 }
58 58
59 // Access the payload. 59 // Access the payload.
60 const uint8_t* payload() const { 60 const uint8_t* payload() const {
61 return reinterpret_cast<const uint8_t*>(data_) + data_->header.num_bytes; 61 return reinterpret_cast<const uint8_t*>(data_) + data_->header.num_bytes;
62 } 62 }
63 uint8_t* mutable_payload() { 63 uint8_t* mutable_payload() {
64 return reinterpret_cast<uint8_t*>(data_) + data_->header.num_bytes; 64 return reinterpret_cast<uint8_t*>(data_) + data_->header.num_bytes;
65 } 65 }
66 uint32_t payload_num_bytes() const {
67 assert(data_num_bytes_ >= data_->header.num_bytes);
68 return data_num_bytes_ - data_->header.num_bytes;
69 }
66 70
67 // Access the handles. 71 // Access the handles.
68 const std::vector<Handle>* handles() const { return &handles_; } 72 const std::vector<Handle>* handles() const { return &handles_; }
69 std::vector<Handle>* mutable_handles() { return &handles_; } 73 std::vector<Handle>* mutable_handles() { return &handles_; }
70 74
71 private: 75 private:
72 uint32_t data_num_bytes_; 76 uint32_t data_num_bytes_;
73 internal::MessageData* data_; // Heap-allocated using malloc. 77 internal::MessageData* data_; // Heap-allocated using malloc.
74 std::vector<Handle> handles_; 78 std::vector<Handle> handles_;
75 79
(...skipping 29 matching lines...) Expand all
105 // otherwise returns an error code if something went wrong. 109 // otherwise returns an error code if something went wrong.
106 // 110 //
107 // NOTE: The message hasn't been validated and may be malformed! 111 // NOTE: The message hasn't been validated and may be malformed!
108 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, 112 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle,
109 MessageReceiver* receiver, 113 MessageReceiver* receiver,
110 bool* receiver_result); 114 bool* receiver_result);
111 115
112 } // namespace mojo 116 } // namespace mojo
113 117
114 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 118 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698