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

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: rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/cpp/bindings/lib/message.cc ('k') | mojo/public/cpp/bindings/string.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_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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // otherwise returns an error code if something went wrong. 114 // otherwise returns an error code if something went wrong.
111 // 115 //
112 // NOTE: The message hasn't been validated and may be malformed! 116 // NOTE: The message hasn't been validated and may be malformed!
113 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, 117 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle,
114 MessageReceiver* receiver, 118 MessageReceiver* receiver,
115 bool* receiver_result); 119 bool* receiver_result);
116 120
117 } // namespace mojo 121 } // namespace mojo
118 122
119 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 123 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/message.cc ('k') | mojo/public/cpp/bindings/string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698