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 "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); | 120 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); |
121 | 121 |
122 memcpy(main_buffer_.get(), message_view.main_buffer(), main_buffer_size_); | 122 memcpy(main_buffer_.get(), message_view.main_buffer(), main_buffer_size_); |
123 DCHECK_EQ(main_buffer_size_, | 123 DCHECK_EQ(main_buffer_size_, |
124 RoundUpMessageAlignment(sizeof(Header) + num_bytes())); | 124 RoundUpMessageAlignment(sizeof(Header) + num_bytes())); |
125 } | 125 } |
126 | 126 |
127 MessageInTransit::~MessageInTransit() { | 127 MessageInTransit::~MessageInTransit() { |
128 if (dispatchers_) { | 128 if (dispatchers_) { |
129 for (size_t i = 0; i < dispatchers_->size(); i++) { | 129 for (size_t i = 0; i < dispatchers_->size(); i++) { |
130 if (!(*dispatchers_)[i].get()) | 130 if (!(*dispatchers_)[i]) |
131 continue; | 131 continue; |
132 | 132 |
133 DCHECK((*dispatchers_)[i]->HasOneRef()); | 133 DCHECK((*dispatchers_)[i]->HasOneRef()); |
134 (*dispatchers_)[i]->Close(); | 134 (*dispatchers_)[i]->Close(); |
135 } | 135 } |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 // static | 139 // static |
140 bool MessageInTransit::GetNextMessageSize(const void* buffer, | 140 bool MessageInTransit::GetNextMessageSize(const void* buffer, |
(...skipping 18 matching lines...) Expand all Loading... |
159 | 159 |
160 void MessageInTransit::SetDispatchers( | 160 void MessageInTransit::SetDispatchers( |
161 scoped_ptr<DispatcherVector> dispatchers) { | 161 scoped_ptr<DispatcherVector> dispatchers) { |
162 DCHECK(dispatchers); | 162 DCHECK(dispatchers); |
163 DCHECK(!dispatchers_); | 163 DCHECK(!dispatchers_); |
164 DCHECK(!transport_data_); | 164 DCHECK(!transport_data_); |
165 | 165 |
166 dispatchers_ = dispatchers.Pass(); | 166 dispatchers_ = dispatchers.Pass(); |
167 #ifndef NDEBUG | 167 #ifndef NDEBUG |
168 for (size_t i = 0; i < dispatchers_->size(); i++) | 168 for (size_t i = 0; i < dispatchers_->size(); i++) |
169 DCHECK(!(*dispatchers_)[i].get() || (*dispatchers_)[i]->HasOneRef()); | 169 DCHECK(!(*dispatchers_)[i] || (*dispatchers_)[i]->HasOneRef()); |
170 #endif | 170 #endif |
171 } | 171 } |
172 | 172 |
173 void MessageInTransit::SetTransportData( | 173 void MessageInTransit::SetTransportData( |
174 scoped_ptr<TransportData> transport_data) { | 174 scoped_ptr<TransportData> transport_data) { |
175 DCHECK(transport_data); | 175 DCHECK(transport_data); |
176 DCHECK(!transport_data_); | 176 DCHECK(!transport_data_); |
177 DCHECK(!dispatchers_); | 177 DCHECK(!dispatchers_); |
178 | 178 |
179 transport_data_ = transport_data.Pass(); | 179 transport_data_ = transport_data.Pass(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); | 213 DCHECK_EQ(main_buffer_size_ % kMessageAlignment, 0u); |
214 header()->total_size = static_cast<uint32_t>(main_buffer_size_); | 214 header()->total_size = static_cast<uint32_t>(main_buffer_size_); |
215 if (transport_data_) { | 215 if (transport_data_) { |
216 header()->total_size += | 216 header()->total_size += |
217 static_cast<uint32_t>(transport_data_->buffer_size()); | 217 static_cast<uint32_t>(transport_data_->buffer_size()); |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 } // namespace system | 221 } // namespace system |
222 } // namespace mojo | 222 } // namespace mojo |
OLD | NEW |