| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_EDK_SYSTEM_MESSAGE_FOR_TRANSIT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_FOR_TRANSIT_H_ |
| 6 #define MOJO_EDK_SYSTEM_MESSAGE_FOR_TRANSIT_H_ | 6 #define MOJO_EDK_SYSTEM_MESSAGE_FOR_TRANSIT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 size_t num_bytes() const { | 84 size_t num_bytes() const { |
| 85 size_t header_size = header()->header_size; | 85 size_t header_size = header()->header_size; |
| 86 DCHECK_GE(message_->num_payload_bytes(), header_size); | 86 DCHECK_GE(message_->num_payload_bytes(), header_size); |
| 87 return message_->num_payload_bytes() - header_size; | 87 return message_->num_payload_bytes() - header_size; |
| 88 } | 88 } |
| 89 | 89 |
| 90 size_t num_handles() const { return header()->num_dispatchers; } | 90 size_t num_handles() const { return header()->num_dispatchers; } |
| 91 | 91 |
| 92 const PortsMessage& ports_message() const { return *message_; } |
| 93 |
| 92 std::unique_ptr<PortsMessage> TakePortsMessage() { | 94 std::unique_ptr<PortsMessage> TakePortsMessage() { |
| 93 return std::move(message_); | 95 return std::move(message_); |
| 94 } | 96 } |
| 95 | 97 |
| 96 private: | 98 private: |
| 97 explicit MessageForTransit(std::unique_ptr<PortsMessage> message); | 99 explicit MessageForTransit(std::unique_ptr<PortsMessage> message); |
| 98 | 100 |
| 99 const MessageForTransit::MessageHeader* header() const { | 101 const MessageForTransit::MessageHeader* header() const { |
| 100 DCHECK(message_); | 102 DCHECK(message_); |
| 101 return static_cast<const MessageForTransit::MessageHeader*>( | 103 return static_cast<const MessageForTransit::MessageHeader*>( |
| 102 message_->payload_bytes()); | 104 message_->payload_bytes()); |
| 103 } | 105 } |
| 104 | 106 |
| 105 std::unique_ptr<PortsMessage> message_; | 107 std::unique_ptr<PortsMessage> message_; |
| 106 | 108 |
| 107 DISALLOW_COPY_AND_ASSIGN(MessageForTransit); | 109 DISALLOW_COPY_AND_ASSIGN(MessageForTransit); |
| 108 }; | 110 }; |
| 109 | 111 |
| 110 } // namespace edk | 112 } // namespace edk |
| 111 } // namespace mojo | 113 } // namespace mojo |
| 112 | 114 |
| 113 #endif // MOJO_EDK_SYSTEM_MESSAGE_FOR_TRANSIT_H_ | 115 #endif // MOJO_EDK_SYSTEM_MESSAGE_FOR_TRANSIT_H_ |
| OLD | NEW |