| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "mojo/edk/system/message_in_transit.h" | 5 #include "mojo/edk/system/message_in_transit.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 DCHECK_EQ(main_buffer_size_, | 109 DCHECK_EQ(main_buffer_size_, |
| 110 RoundUpMessageAlignment(sizeof(Header) + num_bytes())); | 110 RoundUpMessageAlignment(sizeof(Header) + num_bytes())); |
| 111 } | 111 } |
| 112 | 112 |
| 113 MessageInTransit::~MessageInTransit() { | 113 MessageInTransit::~MessageInTransit() { |
| 114 if (dispatchers_) { | 114 if (dispatchers_) { |
| 115 for (size_t i = 0; i < dispatchers_->size(); i++) { | 115 for (size_t i = 0; i < dispatchers_->size(); i++) { |
| 116 if (!(*dispatchers_)[i]) | 116 if (!(*dispatchers_)[i]) |
| 117 continue; | 117 continue; |
| 118 | 118 |
| 119 DCHECK((*dispatchers_)[i]->HasOneRef()); | 119 (*dispatchers_)[i]->AssertHasOneRef(); |
| 120 (*dispatchers_)[i]->Close(); | 120 (*dispatchers_)[i]->Close(); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 // static | 125 // static |
| 126 bool MessageInTransit::GetNextMessageSize(const void* buffer, | 126 bool MessageInTransit::GetNextMessageSize(const void* buffer, |
| 127 size_t buffer_size, | 127 size_t buffer_size, |
| 128 size_t* next_message_size) { | 128 size_t* next_message_size) { |
| 129 DCHECK(next_message_size); | 129 DCHECK(next_message_size); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 144 } | 144 } |
| 145 | 145 |
| 146 void MessageInTransit::SetDispatchers( | 146 void MessageInTransit::SetDispatchers( |
| 147 std::unique_ptr<DispatcherVector> dispatchers) { | 147 std::unique_ptr<DispatcherVector> dispatchers) { |
| 148 DCHECK(dispatchers); | 148 DCHECK(dispatchers); |
| 149 DCHECK(!dispatchers_); | 149 DCHECK(!dispatchers_); |
| 150 DCHECK(!transport_data_); | 150 DCHECK(!transport_data_); |
| 151 | 151 |
| 152 dispatchers_ = std::move(dispatchers); | 152 dispatchers_ = std::move(dispatchers); |
| 153 #ifndef NDEBUG | 153 #ifndef NDEBUG |
| 154 for (size_t i = 0; i < dispatchers_->size(); i++) | 154 for (size_t i = 0; i < dispatchers_->size(); i++) { |
| 155 DCHECK(!(*dispatchers_)[i] || (*dispatchers_)[i]->HasOneRef()); | 155 if ((*dispatchers_)[i]) |
| 156 (*dispatchers_)[i]->AssertHasOneRef(); |
| 157 } |
| 156 #endif | 158 #endif |
| 157 } | 159 } |
| 158 | 160 |
| 159 void MessageInTransit::SetTransportData( | 161 void MessageInTransit::SetTransportData( |
| 160 std::unique_ptr<TransportData> transport_data) { | 162 std::unique_ptr<TransportData> transport_data) { |
| 161 DCHECK(transport_data); | 163 DCHECK(transport_data); |
| 162 DCHECK(!transport_data_); | 164 DCHECK(!transport_data_); |
| 163 DCHECK(!dispatchers_); | 165 DCHECK(!dispatchers_); |
| 164 | 166 |
| 165 transport_data_ = std::move(transport_data); | 167 transport_data_ = std::move(transport_data); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); | 202 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); |
| 201 header()->total_size = static_cast<uint32_t>(main_buffer_size_); | 203 header()->total_size = static_cast<uint32_t>(main_buffer_size_); |
| 202 if (transport_data_) { | 204 if (transport_data_) { |
| 203 header()->total_size += | 205 header()->total_size += |
| 204 static_cast<uint32_t>(transport_data_->buffer_size()); | 206 static_cast<uint32_t>(transport_data_->buffer_size()); |
| 205 } | 207 } |
| 206 } | 208 } |
| 207 | 209 |
| 208 } // namespace system | 210 } // namespace system |
| 209 } // namespace mojo | 211 } // namespace mojo |
| OLD | NEW |