| 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/embedder/platform_shared_buffer.h" | 5 #include "mojo/edk/embedder/platform_shared_buffer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 : num_bytes_(num_bytes) {} | 168 : num_bytes_(num_bytes) {} |
| 169 | 169 |
| 170 PlatformSharedBuffer::~PlatformSharedBuffer() {} | 170 PlatformSharedBuffer::~PlatformSharedBuffer() {} |
| 171 | 171 |
| 172 bool PlatformSharedBuffer::Init() { | 172 bool PlatformSharedBuffer::Init() { |
| 173 DCHECK(!shared_memory_); | 173 DCHECK(!shared_memory_); |
| 174 | 174 |
| 175 base::SharedMemoryCreateOptions options; | 175 base::SharedMemoryCreateOptions options; |
| 176 options.size = num_bytes_; | 176 options.size = num_bytes_; |
| 177 #if defined(OS_MACOSX) && !defined(OS_IOS) | 177 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 178 // TODO(crbug.com/582468): Support Mach shared memory. | 178 options.type = base::SharedMemoryHandle::MACH; |
| 179 options.type = base::SharedMemoryHandle::POSIX; | |
| 180 #endif | 179 #endif |
| 181 | 180 |
| 182 shared_memory_.reset(new base::SharedMemory); | 181 shared_memory_.reset(new base::SharedMemory); |
| 183 return shared_memory_->Create(options); | 182 return shared_memory_->Create(options); |
| 184 } | 183 } |
| 185 | 184 |
| 186 bool PlatformSharedBuffer::InitFromPlatformHandle( | 185 bool PlatformSharedBuffer::InitFromPlatformHandle( |
| 187 ScopedPlatformHandle platform_handle) { | 186 ScopedPlatformHandle platform_handle) { |
| 188 DCHECK(!shared_memory_); | 187 DCHECK(!shared_memory_); |
| 189 | 188 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding; | 239 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding; |
| 241 return true; | 240 return true; |
| 242 } | 241 } |
| 243 | 242 |
| 244 void PlatformSharedBufferMapping::Unmap() { | 243 void PlatformSharedBufferMapping::Unmap() { |
| 245 shared_memory_.Unmap(); | 244 shared_memory_.Unmap(); |
| 246 } | 245 } |
| 247 | 246 |
| 248 } // namespace edk | 247 } // namespace edk |
| 249 } // namespace mojo | 248 } // namespace mojo |
| OLD | NEW |