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 #include "mojo/system/shared_buffer_dispatcher.h" | 5 #include "mojo/system/shared_buffer_dispatcher.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // Checks for fields beyond |flags|: | 173 // Checks for fields beyond |flags|: |
174 | 174 |
175 // (Nothing here yet.) | 175 // (Nothing here yet.) |
176 | 176 |
177 return MOJO_RESULT_OK; | 177 return MOJO_RESULT_OK; |
178 } | 178 } |
179 | 179 |
180 void SharedBufferDispatcher::CloseImplNoLock() { | 180 void SharedBufferDispatcher::CloseImplNoLock() { |
181 lock().AssertAcquired(); | 181 lock().AssertAcquired(); |
182 DCHECK(shared_buffer_.get()); | 182 DCHECK(shared_buffer_.get()); |
183 shared_buffer_ = NULL; | 183 shared_buffer_ = nullptr; |
184 } | 184 } |
185 | 185 |
186 scoped_refptr<Dispatcher> | 186 scoped_refptr<Dispatcher> |
187 SharedBufferDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { | 187 SharedBufferDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
188 lock().AssertAcquired(); | 188 lock().AssertAcquired(); |
189 DCHECK(shared_buffer_.get()); | 189 DCHECK(shared_buffer_.get()); |
190 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer; | 190 scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer; |
191 shared_buffer.swap(shared_buffer_); | 191 shared_buffer.swap(shared_buffer_); |
192 return scoped_refptr<Dispatcher>(new SharedBufferDispatcher(shared_buffer)); | 192 return scoped_refptr<Dispatcher>(new SharedBufferDispatcher(shared_buffer)); |
193 } | 193 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 SerializedSharedBufferDispatcher* serialization = | 252 SerializedSharedBufferDispatcher* serialization = |
253 static_cast<SerializedSharedBufferDispatcher*>(destination); | 253 static_cast<SerializedSharedBufferDispatcher*>(destination); |
254 // If there's only one reference to |shared_buffer_|, then it's ours (and no | 254 // If there's only one reference to |shared_buffer_|, then it's ours (and no |
255 // one else can make any more references to it), so we can just take its | 255 // one else can make any more references to it), so we can just take its |
256 // handle. | 256 // handle. |
257 embedder::ScopedPlatformHandle platform_handle( | 257 embedder::ScopedPlatformHandle platform_handle( |
258 shared_buffer_->HasOneRef() ? shared_buffer_->PassPlatformHandle() | 258 shared_buffer_->HasOneRef() ? shared_buffer_->PassPlatformHandle() |
259 : shared_buffer_->DuplicatePlatformHandle()); | 259 : shared_buffer_->DuplicatePlatformHandle()); |
260 if (!platform_handle.is_valid()) { | 260 if (!platform_handle.is_valid()) { |
261 shared_buffer_ = NULL; | 261 shared_buffer_ = nullptr; |
262 return false; | 262 return false; |
263 } | 263 } |
264 | 264 |
265 serialization->num_bytes = shared_buffer_->GetNumBytes(); | 265 serialization->num_bytes = shared_buffer_->GetNumBytes(); |
266 serialization->platform_handle_index = platform_handles->size(); | 266 serialization->platform_handle_index = platform_handles->size(); |
267 platform_handles->push_back(platform_handle.release()); | 267 platform_handles->push_back(platform_handle.release()); |
268 *actual_size = sizeof(SerializedSharedBufferDispatcher); | 268 *actual_size = sizeof(SerializedSharedBufferDispatcher); |
269 | 269 |
270 shared_buffer_ = NULL; | 270 shared_buffer_ = nullptr; |
271 | 271 |
272 return true; | 272 return true; |
273 } | 273 } |
274 | 274 |
275 } // namespace system | 275 } // namespace system |
276 } // namespace mojo | 276 } // namespace mojo |
OLD | NEW |