Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: mojo/edk/embedder/platform_shared_buffer.cc

Issue 2845113005: Replace base::SharedMemory read-only methods with GetReadOnlyHandle. (Closed)
Patch Set: Comments from thakis. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/user_script_loader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (ro_shared_memory_) { 197 if (ro_shared_memory_) {
198 base::AutoLock locker(lock_); 198 base::AutoLock locker(lock_);
199 base::SharedMemoryHandle handle; 199 base::SharedMemoryHandle handle;
200 handle = base::SharedMemory::DuplicateHandle(ro_shared_memory_->handle()); 200 handle = base::SharedMemory::DuplicateHandle(ro_shared_memory_->handle());
201 if (!handle.IsValid()) 201 if (!handle.IsValid())
202 return nullptr; 202 return nullptr;
203 return CreateFromSharedMemoryHandle(num_bytes_, true, handle); 203 return CreateFromSharedMemoryHandle(num_bytes_, true, handle);
204 } 204 }
205 205
206 base::SharedMemoryHandle handle; 206 base::SharedMemoryHandle handle;
207 bool success;
208 { 207 {
209 base::AutoLock locker(lock_); 208 base::AutoLock locker(lock_);
210 success = shared_memory_->ShareReadOnlyToProcess( 209 handle = shared_memory_->GetReadOnlyHandle();
211 base::GetCurrentProcessHandle(), &handle);
212 } 210 }
213 if (!success || !handle.IsValid()) 211 if (!handle.IsValid())
214 return nullptr; 212 return nullptr;
215 213
216 return CreateFromSharedMemoryHandle(num_bytes_, true, handle); 214 return CreateFromSharedMemoryHandle(num_bytes_, true, handle);
217 } 215 }
218 216
219 PlatformSharedBuffer::PlatformSharedBuffer(size_t num_bytes, bool read_only) 217 PlatformSharedBuffer::PlatformSharedBuffer(size_t num_bytes, bool read_only)
220 : num_bytes_(num_bytes), read_only_(read_only) {} 218 : num_bytes_(num_bytes), read_only_(read_only) {}
221 219
222 PlatformSharedBuffer::~PlatformSharedBuffer() {} 220 PlatformSharedBuffer::~PlatformSharedBuffer() {}
223 221
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding; 330 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding;
333 return true; 331 return true;
334 } 332 }
335 333
336 void PlatformSharedBufferMapping::Unmap() { 334 void PlatformSharedBufferMapping::Unmap() {
337 shared_memory_.Unmap(); 335 shared_memory_.Unmap();
338 } 336 }
339 337
340 } // namespace edk 338 } // namespace edk
341 } // namespace mojo 339 } // namespace mojo
OLDNEW
« no previous file with comments | « extensions/browser/user_script_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698