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

Side by Side Diff: base/memory/shared_memory_mac.cc

Issue 2496783002: gpu: Reuse existing code for shared memory allocation. (Closed)
Patch Set: . Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <mach/mach_vm.h> 7 #include <mach/mach_vm.h>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_file.h" 10 #include "base/files/scoped_file.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 mapped_size_); 170 mapped_size_);
171 memory_ = NULL; 171 memory_ = NULL;
172 mapped_size_ = 0; 172 mapped_size_ = 0;
173 return true; 173 return true;
174 } 174 }
175 175
176 SharedMemoryHandle SharedMemory::handle() const { 176 SharedMemoryHandle SharedMemory::handle() const {
177 return shm_; 177 return shm_;
178 } 178 }
179 179
180 SharedMemoryHandle SharedMemory::TakeHandle() {
181 SharedMemoryHandle dup = DuplicateHandle(handle());
182 Close();
183 return dup;
184 }
185
180 void SharedMemory::Close() { 186 void SharedMemory::Close() {
181 shm_.Close(); 187 shm_.Close();
182 shm_ = SharedMemoryHandle(); 188 shm_ = SharedMemoryHandle();
183 } 189 }
184 190
185 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, 191 bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
186 SharedMemoryHandle* new_handle, 192 SharedMemoryHandle* new_handle,
187 bool close_self, 193 bool close_self,
188 ShareMode share_mode) { 194 ShareMode share_mode) {
189 DCHECK(shm_.IsValid()); 195 DCHECK(shm_.IsValid());
(...skipping 14 matching lines...) Expand all
204 210
205 if (close_self) { 211 if (close_self) {
206 Unmap(); 212 Unmap();
207 Close(); 213 Close();
208 } 214 }
209 215
210 return success; 216 return success;
211 } 217 }
212 218
213 } // namespace base 219 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698