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