| 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/edk/system/shared_buffer_dispatcher.h" | 5 #include "mojo/edk/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" | |
| 11 #include "mojo/edk/embedder/platform_support.h" | 10 #include "mojo/edk/embedder/platform_support.h" |
| 12 #include "mojo/edk/system/channel.h" | 11 #include "mojo/edk/system/channel.h" |
| 13 #include "mojo/edk/system/configuration.h" | 12 #include "mojo/edk/system/configuration.h" |
| 14 #include "mojo/edk/system/memory.h" | 13 #include "mojo/edk/system/memory.h" |
| 15 #include "mojo/edk/system/options_validation.h" | 14 #include "mojo/edk/system/options_validation.h" |
| 16 #include "mojo/public/c/system/macros.h" | 15 #include "mojo/public/c/system/macros.h" |
| 17 | 16 |
| 18 namespace mojo { | 17 namespace mojo { |
| 19 namespace system { | 18 namespace system { |
| 20 | 19 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 200 |
| 202 // Note: Since this is "duplicate", we keep our ref to |shared_buffer_|. | 201 // Note: Since this is "duplicate", we keep our ref to |shared_buffer_|. |
| 203 *new_dispatcher = CreateInternal(shared_buffer_); | 202 *new_dispatcher = CreateInternal(shared_buffer_); |
| 204 return MOJO_RESULT_OK; | 203 return MOJO_RESULT_OK; |
| 205 } | 204 } |
| 206 | 205 |
| 207 MojoResult SharedBufferDispatcher::MapBufferImplNoLock( | 206 MojoResult SharedBufferDispatcher::MapBufferImplNoLock( |
| 208 uint64_t offset, | 207 uint64_t offset, |
| 209 uint64_t num_bytes, | 208 uint64_t num_bytes, |
| 210 MojoMapBufferFlags flags, | 209 MojoMapBufferFlags flags, |
| 211 scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping) { | 210 std::unique_ptr<embedder::PlatformSharedBufferMapping>* mapping) { |
| 212 mutex().AssertHeld(); | 211 mutex().AssertHeld(); |
| 213 DCHECK(shared_buffer_); | 212 DCHECK(shared_buffer_); |
| 214 | 213 |
| 215 if (offset > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) | 214 if (offset > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) |
| 216 return MOJO_RESULT_INVALID_ARGUMENT; | 215 return MOJO_RESULT_INVALID_ARGUMENT; |
| 217 if (num_bytes > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) | 216 if (num_bytes > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) |
| 218 return MOJO_RESULT_INVALID_ARGUMENT; | 217 return MOJO_RESULT_INVALID_ARGUMENT; |
| 219 | 218 |
| 220 if (!shared_buffer_->IsValidMap(static_cast<size_t>(offset), | 219 if (!shared_buffer_->IsValidMap(static_cast<size_t>(offset), |
| 221 static_cast<size_t>(num_bytes))) | 220 static_cast<size_t>(num_bytes))) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 platform_handles->push_back(platform_handle.release()); | 264 platform_handles->push_back(platform_handle.release()); |
| 266 *actual_size = sizeof(SerializedSharedBufferDispatcher); | 265 *actual_size = sizeof(SerializedSharedBufferDispatcher); |
| 267 | 266 |
| 268 shared_buffer_ = nullptr; | 267 shared_buffer_ = nullptr; |
| 269 | 268 |
| 270 return true; | 269 return true; |
| 271 } | 270 } |
| 272 | 271 |
| 273 } // namespace system | 272 } // namespace system |
| 274 } // namespace mojo | 273 } // namespace mojo |
| OLD | NEW |