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

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

Issue 2852803002: Remove base::SharedMemory::ShareToProcess. (Closed)
Patch Set: Compile error. 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <aclapi.h> 7 #include <aclapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (!::DuplicateHandle(process, mapped_file_.Get(), process, &result, 333 if (!::DuplicateHandle(process, mapped_file_.Get(), process, &result,
334 FILE_MAP_READ | SECTION_QUERY, FALSE, 0)) { 334 FILE_MAP_READ | SECTION_QUERY, FALSE, 0)) {
335 return SharedMemoryHandle(); 335 return SharedMemoryHandle();
336 } 336 }
337 SharedMemoryHandle handle = 337 SharedMemoryHandle handle =
338 SharedMemoryHandle(result, base::GetProcId(process)); 338 SharedMemoryHandle(result, base::GetProcId(process));
339 handle.SetOwnershipPassesToIPC(true); 339 handle.SetOwnershipPassesToIPC(true);
340 return handle; 340 return handle;
341 } 341 }
342 342
343 bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
344 SharedMemoryHandle* new_handle) {
345 *new_handle = SharedMemoryHandle();
346 DWORD access = FILE_MAP_READ | SECTION_QUERY;
347 DWORD options = 0;
348 HANDLE mapped_file = mapped_file_.Get();
349 HANDLE result;
350 if (!read_only_)
351 access |= FILE_MAP_WRITE;
352
353 if (!::DuplicateHandle(GetCurrentProcess(), mapped_file, process, &result,
354 access, FALSE, options)) {
355 return false;
356 }
357 *new_handle = SharedMemoryHandle(result, base::GetProcId(process));
358 new_handle->SetOwnershipPassesToIPC(true);
359 return true;
360 }
361
362
363 void SharedMemory::Close() { 343 void SharedMemory::Close() {
364 mapped_file_.Close(); 344 mapped_file_.Close();
365 } 345 }
366 346
367 SharedMemoryHandle SharedMemory::handle() const { 347 SharedMemoryHandle SharedMemory::handle() const {
368 return SharedMemoryHandle(mapped_file_.Get(), base::GetCurrentProcId()); 348 return SharedMemoryHandle(mapped_file_.Get(), base::GetCurrentProcId());
369 } 349 }
370 350
371 SharedMemoryHandle SharedMemory::TakeHandle() { 351 SharedMemoryHandle SharedMemory::TakeHandle() {
372 SharedMemoryHandle handle(mapped_file_.Take(), base::GetCurrentProcId()); 352 SharedMemoryHandle handle(mapped_file_.Take(), base::GetCurrentProcId());
373 handle.SetOwnershipPassesToIPC(true); 353 handle.SetOwnershipPassesToIPC(true);
374 memory_ = nullptr; 354 memory_ = nullptr;
375 mapped_size_ = 0; 355 mapped_size_ = 0;
376 return handle; 356 return handle;
377 } 357 }
378 358
379 } // namespace base 359 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_unittest.cc ('k') | base/metrics/persistent_memory_allocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698