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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 #endif | 203 #endif |
204 | 204 |
205 shared_memory_.reset(new base::SharedMemory(handle, false)); | 205 shared_memory_.reset(new base::SharedMemory(handle, false)); |
206 return true; | 206 return true; |
207 } | 207 } |
208 | 208 |
209 void PlatformSharedBuffer::InitFromSharedMemoryHandle( | 209 void PlatformSharedBuffer::InitFromSharedMemoryHandle( |
210 base::SharedMemoryHandle handle) { | 210 base::SharedMemoryHandle handle) { |
211 DCHECK(!shared_memory_); | 211 DCHECK(!shared_memory_); |
212 | 212 |
213 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
214 // TODO(crbug.com/582468): Support Mach shared memory. | |
215 CHECK(handle.GetType() == base::SharedMemoryHandle::POSIX); | |
216 #endif | |
217 | |
218 // TODO(crbug.com/556587): Support read-only handles. | 213 // TODO(crbug.com/556587): Support read-only handles. |
219 shared_memory_.reset(new base::SharedMemory(handle, false)); | 214 shared_memory_.reset(new base::SharedMemory(handle, false)); |
220 } | 215 } |
221 | 216 |
222 PlatformSharedBufferMapping::~PlatformSharedBufferMapping() { | 217 PlatformSharedBufferMapping::~PlatformSharedBufferMapping() { |
223 Unmap(); | 218 Unmap(); |
224 } | 219 } |
225 | 220 |
226 void* PlatformSharedBufferMapping::GetBase() const { | 221 void* PlatformSharedBufferMapping::GetBase() const { |
227 return base_; | 222 return base_; |
(...skipping 17 matching lines...) Expand all Loading... |
245 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding; | 240 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding; |
246 return true; | 241 return true; |
247 } | 242 } |
248 | 243 |
249 void PlatformSharedBufferMapping::Unmap() { | 244 void PlatformSharedBufferMapping::Unmap() { |
250 shared_memory_.Unmap(); | 245 shared_memory_.Unmap(); |
251 } | 246 } |
252 | 247 |
253 } // namespace edk | 248 } // namespace edk |
254 } // namespace mojo | 249 } // namespace mojo |
OLD | NEW |