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

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

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « base/memory/shared_memory_unittest.cc ('k') | base/message_loop/incoming_task_queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 mapped_size_(0), 64 mapped_size_(0),
65 lock_(NULL) { 65 lock_(NULL) {
66 ::DuplicateHandle(process, handle, 66 ::DuplicateHandle(process, handle,
67 GetCurrentProcess(), &mapped_file_, 67 GetCurrentProcess(), &mapped_file_,
68 read_only_ ? FILE_MAP_READ : FILE_MAP_READ | 68 read_only_ ? FILE_MAP_READ : FILE_MAP_READ |
69 FILE_MAP_WRITE, 69 FILE_MAP_WRITE,
70 FALSE, 0); 70 FALSE, 0);
71 } 71 }
72 72
73 SharedMemory::~SharedMemory() { 73 SharedMemory::~SharedMemory() {
74 Unmap();
74 Close(); 75 Close();
75 if (lock_ != NULL) 76 if (lock_ != NULL)
76 CloseHandle(lock_); 77 CloseHandle(lock_);
77 } 78 }
78 79
79 // static 80 // static
80 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { 81 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) {
81 return handle != NULL; 82 return handle != NULL;
82 } 83 }
83 84
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 243
243 if (!DuplicateHandle(GetCurrentProcess(), mapped_file, process, 244 if (!DuplicateHandle(GetCurrentProcess(), mapped_file, process,
244 &result, access, FALSE, options)) 245 &result, access, FALSE, options))
245 return false; 246 return false;
246 *new_handle = result; 247 *new_handle = result;
247 return true; 248 return true;
248 } 249 }
249 250
250 251
251 void SharedMemory::Close() { 252 void SharedMemory::Close() {
252 if (memory_ != NULL) {
253 UnmapViewOfFile(memory_);
254 memory_ = NULL;
255 }
256
257 if (mapped_file_ != NULL) { 253 if (mapped_file_ != NULL) {
258 CloseHandle(mapped_file_); 254 CloseHandle(mapped_file_);
259 mapped_file_ = NULL; 255 mapped_file_ = NULL;
260 } 256 }
261 } 257 }
262 258
263 void SharedMemory::LockDeprecated() { 259 void SharedMemory::LockDeprecated() {
264 if (lock_ == NULL) { 260 if (lock_ == NULL) {
265 std::wstring name = name_; 261 std::wstring name = name_;
266 name.append(L"lock"); 262 name.append(L"lock");
(...skipping 11 matching lines...) Expand all
278 void SharedMemory::UnlockDeprecated() { 274 void SharedMemory::UnlockDeprecated() {
279 DCHECK(lock_ != NULL); 275 DCHECK(lock_ != NULL);
280 ReleaseMutex(lock_); 276 ReleaseMutex(lock_);
281 } 277 }
282 278
283 SharedMemoryHandle SharedMemory::handle() const { 279 SharedMemoryHandle SharedMemory::handle() const {
284 return mapped_file_; 280 return mapped_file_;
285 } 281 }
286 282
287 } // namespace base 283 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_unittest.cc ('k') | base/message_loop/incoming_task_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698