OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_handle.h" | 5 #include "base/memory/shared_memory_handle.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 | 10 |
11 SharedMemoryHandle::SharedMemoryHandle() | 11 SharedMemoryHandle::SharedMemoryHandle() |
12 : handle_(nullptr), pid_(kNullProcessId) {} | 12 : handle_(nullptr), pid_(kNullProcessId), ownership_passes_to_ipc_(false) {} |
13 | 13 |
14 SharedMemoryHandle::SharedMemoryHandle(HANDLE h, base::ProcessId pid) | 14 SharedMemoryHandle::SharedMemoryHandle(HANDLE h, base::ProcessId pid) |
15 : handle_(h), pid_(pid) {} | 15 : handle_(h), pid_(pid), ownership_passes_to_ipc_(false) {} |
16 | 16 |
17 SharedMemoryHandle::SharedMemoryHandle(const SharedMemoryHandle& handle) | 17 SharedMemoryHandle::SharedMemoryHandle(const SharedMemoryHandle& handle) |
18 : handle_(handle.handle_), pid_(handle.pid_) {} | 18 : handle_(handle.handle_), |
| 19 pid_(handle.pid_), |
| 20 ownership_passes_to_ipc_(false) {} |
19 | 21 |
20 SharedMemoryHandle& SharedMemoryHandle::operator=( | 22 SharedMemoryHandle& SharedMemoryHandle::operator=( |
21 const SharedMemoryHandle& handle) { | 23 const SharedMemoryHandle& handle) { |
22 if (this == &handle) | 24 if (this == &handle) |
23 return *this; | 25 return *this; |
24 | 26 |
25 handle_ = handle.handle_; | 27 handle_ = handle.handle_; |
26 pid_ = handle.pid_; | 28 pid_ = handle.pid_; |
| 29 ownership_passes_to_ipc_ = handle.ownership_passes_to_ipc_; |
27 return *this; | 30 return *this; |
28 } | 31 } |
29 | 32 |
30 bool SharedMemoryHandle::operator==(const SharedMemoryHandle& handle) const { | 33 bool SharedMemoryHandle::operator==(const SharedMemoryHandle& handle) const { |
31 // Invalid handles are always equal. | 34 // Invalid handles are always equal. |
32 if (!IsValid() && !handle.IsValid()) | 35 if (!IsValid() && !handle.IsValid()) |
33 return true; | 36 return true; |
34 | 37 |
35 return handle_ == handle.handle_ && pid_ == handle.pid_; | 38 return handle_ == handle.handle_ && pid_ == handle.pid_; |
36 } | 39 } |
(...skipping 21 matching lines...) Expand all Loading... |
58 } | 61 } |
59 | 62 |
60 HANDLE SharedMemoryHandle::GetHandle() const { | 63 HANDLE SharedMemoryHandle::GetHandle() const { |
61 return handle_; | 64 return handle_; |
62 } | 65 } |
63 | 66 |
64 base::ProcessId SharedMemoryHandle::GetPID() const { | 67 base::ProcessId SharedMemoryHandle::GetPID() const { |
65 return pid_; | 68 return pid_; |
66 } | 69 } |
67 | 70 |
| 71 void SharedMemoryHandle::SetOwnershipPassesToIPC(bool ownership_passes) { |
| 72 ownership_passes_to_ipc_ = ownership_passes; |
| 73 } |
| 74 |
| 75 bool SharedMemoryHandle::OwnershipPassesToIPC() const { |
| 76 return ownership_passes_to_ipc_; |
| 77 } |
| 78 |
68 } // namespace base | 79 } // namespace base |
OLD | NEW |