OLD | NEW |
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 28 matching lines...) Expand all Loading... |
39 SharedMemory::SharedMemory(const std::wstring& name) | 39 SharedMemory::SharedMemory(const std::wstring& name) |
40 : mapped_file_(NULL), | 40 : mapped_file_(NULL), |
41 memory_(NULL), | 41 memory_(NULL), |
42 read_only_(false), | 42 read_only_(false), |
43 requested_size_(0), | 43 requested_size_(0), |
44 mapped_size_(0), | 44 mapped_size_(0), |
45 lock_(NULL), | 45 lock_(NULL), |
46 name_(name) { | 46 name_(name) { |
47 } | 47 } |
48 | 48 |
49 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only) | 49 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) |
50 : mapped_file_(handle), | 50 : mapped_file_(handle), |
51 memory_(NULL), | 51 memory_(NULL), |
52 read_only_(read_only), | 52 read_only_(read_only), |
53 requested_size_(0), | 53 requested_size_(0), |
54 mapped_size_(0), | 54 mapped_size_(0), |
55 lock_(NULL) { | 55 lock_(NULL) { |
56 } | 56 } |
57 | 57 |
58 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only, | 58 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, |
| 59 bool read_only, |
59 ProcessHandle process) | 60 ProcessHandle process) |
60 : mapped_file_(NULL), | 61 : mapped_file_(NULL), |
61 memory_(NULL), | 62 memory_(NULL), |
62 read_only_(read_only), | 63 read_only_(read_only), |
63 requested_size_(0), | 64 requested_size_(0), |
64 mapped_size_(0), | 65 mapped_size_(0), |
65 lock_(NULL) { | 66 lock_(NULL) { |
66 ::DuplicateHandle(process, handle, | 67 ::DuplicateHandle(process, handle, |
67 GetCurrentProcess(), &mapped_file_, | 68 GetCurrentProcess(), &mapped_file_, |
68 read_only_ ? FILE_MAP_READ : FILE_MAP_READ | | 69 read_only_ ? FILE_MAP_READ : FILE_MAP_READ | |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 void SharedMemory::UnlockDeprecated() { | 289 void SharedMemory::UnlockDeprecated() { |
289 DCHECK(lock_ != NULL); | 290 DCHECK(lock_ != NULL); |
290 ReleaseMutex(lock_); | 291 ReleaseMutex(lock_); |
291 } | 292 } |
292 | 293 |
293 SharedMemoryHandle SharedMemory::handle() const { | 294 SharedMemoryHandle SharedMemory::handle() const { |
294 return mapped_file_; | 295 return mapped_file_; |
295 } | 296 } |
296 | 297 |
297 } // namespace base | 298 } // namespace base |
OLD | NEW |