| OLD | NEW |
| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/lib/message_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/message_internal.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 uint8_t* mutable_data() { return reinterpret_cast<uint8_t*>(data_); } | 37 uint8_t* mutable_data() { return reinterpret_cast<uint8_t*>(data_); } |
| 38 | 38 |
| 39 // Access the header. | 39 // Access the header. |
| 40 const internal::MessageHeader* header() const { return &data_->header; } | 40 const internal::MessageHeader* header() const { return &data_->header; } |
| 41 | 41 |
| 42 uint32_t name() const { return data_->header.name; } | 42 uint32_t name() const { return data_->header.name; } |
| 43 bool has_flag(uint32_t flag) const { return !!(data_->header.flags & flag); } | 43 bool has_flag(uint32_t flag) const { return !!(data_->header.flags & flag); } |
| 44 | 44 |
| 45 // Access the request_id field (if present). | 45 // Access the request_id field (if present). |
| 46 bool has_request_id() const { return data_->header.num_fields >= 3; } | 46 bool has_request_id() const { return data_->header.version >= 3; } |
| 47 uint64_t request_id() const { | 47 uint64_t request_id() const { |
| 48 MOJO_DCHECK(has_request_id()); | 48 MOJO_DCHECK(has_request_id()); |
| 49 return static_cast<const internal::MessageHeaderWithRequestID*>( | 49 return static_cast<const internal::MessageHeaderWithRequestID*>( |
| 50 &data_->header)->request_id; | 50 &data_->header)->request_id; |
| 51 } | 51 } |
| 52 void set_request_id(uint64_t request_id) { | 52 void set_request_id(uint64_t request_id) { |
| 53 MOJO_DCHECK(has_request_id()); | 53 MOJO_DCHECK(has_request_id()); |
| 54 static_cast<internal::MessageHeaderWithRequestID*>(&data_->header) | 54 static_cast<internal::MessageHeaderWithRequestID*>(&data_->header) |
| 55 ->request_id = request_id; | 55 ->request_id = request_id; |
| 56 } | 56 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // otherwise returns an error code if something went wrong. | 113 // otherwise returns an error code if something went wrong. |
| 114 // | 114 // |
| 115 // NOTE: The message hasn't been validated and may be malformed! | 115 // NOTE: The message hasn't been validated and may be malformed! |
| 116 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, | 116 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, |
| 117 MessageReceiver* receiver, | 117 MessageReceiver* receiver, |
| 118 bool* receiver_result); | 118 bool* receiver_result); |
| 119 | 119 |
| 120 } // namespace mojo | 120 } // namespace mojo |
| 121 | 121 |
| 122 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ | 122 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ |
| OLD | NEW |