| 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 #ifndef IPC_HANDLE_ATTACHMENT_WIN_H_ | 5 #ifndef IPC_HANDLE_ATTACHMENT_WIN_H_ |
| 6 #define IPC_HANDLE_ATTACHMENT_WIN_H_ | 6 #define IPC_HANDLE_ATTACHMENT_WIN_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // The permissions to use when duplicating the handle. | 51 // The permissions to use when duplicating the handle. |
| 52 HandleWin::Permissions permissions; | 52 HandleWin::Permissions permissions; |
| 53 | 53 |
| 54 AttachmentId attachment_id; | 54 AttachmentId attachment_id; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // This constructor makes a copy of |handle| and takes ownership of the | 57 // This constructor makes a copy of |handle| and takes ownership of the |
| 58 // result. Should only be called by the sender of a Chrome IPC message. | 58 // result. Should only be called by the sender of a Chrome IPC message. |
| 59 HandleAttachmentWin(const HANDLE& handle, HandleWin::Permissions permissions); | 59 HandleAttachmentWin(const HANDLE& handle, HandleWin::Permissions permissions); |
| 60 | 60 |
| 61 // These constructors do not take ownership of the HANDLE, and should only be | 61 // This constructor takes ownership of |wire_format.handle| without making a |
| 62 // called by the receiver of a Chrome IPC message. | 62 // copy. Should only be called by the receiver of a Chrome IPC message. |
| 63 explicit HandleAttachmentWin(const WireFormat& wire_format); | 63 explicit HandleAttachmentWin(const WireFormat& wire_format); |
| 64 explicit HandleAttachmentWin(const BrokerableAttachment::AttachmentId& id); | |
| 65 | 64 |
| 66 BrokerableType GetBrokerableType() const override; | 65 BrokerableType GetBrokerableType() const override; |
| 67 | 66 |
| 68 // Returns the wire format of this attachment. | 67 // Returns the wire format of this attachment. |
| 69 WireFormat GetWireFormat(const base::ProcessId& destination) const; | 68 WireFormat GetWireFormat(const base::ProcessId& destination) const; |
| 70 | 69 |
| 71 HANDLE get_handle() const { return handle_; } | 70 HANDLE get_handle() const { return handle_; } |
| 72 | 71 |
| 73 // The caller of this method has taken ownership of |handle_|. | 72 // The caller of this method has taken ownership of |handle_|. |
| 74 void reset_handle_ownership() { owns_handle_ = false; } | 73 void reset_handle_ownership() { |
| 74 owns_handle_ = false; |
| 75 handle_ = INVALID_HANDLE_VALUE; |
| 76 } |
| 75 | 77 |
| 76 private: | 78 private: |
| 77 ~HandleAttachmentWin() override; | 79 ~HandleAttachmentWin() override; |
| 78 HANDLE handle_; | 80 HANDLE handle_; |
| 79 HandleWin::Permissions permissions_; | 81 HandleWin::Permissions permissions_; |
| 80 | 82 |
| 81 // In the sender process, the attachment owns the HANDLE of a newly created | 83 // In the sender process, the attachment owns the HANDLE of a newly created |
| 82 // message. The attachment broker will eventually take ownership, and set | 84 // message. The attachment broker will eventually take ownership, and set |
| 83 // this member to |false|. | 85 // this member to |false|. |
| 84 // In the destination process, the attachment never owns the Mach port. The | 86 // In the destination process, the attachment owns the Mach port until a call |
| 85 // client code that receives the Chrome IPC message is always expected to take | 87 // to ParamTraits<HandleWin>::Read() takes ownership. |
| 86 // ownership. | |
| 87 bool owns_handle_; | 88 bool owns_handle_; |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 } // namespace internal | 91 } // namespace internal |
| 91 } // namespace IPC | 92 } // namespace IPC |
| 92 | 93 |
| 93 #endif // IPC_HANDLE_ATTACHMENT_WIN_H_ | 94 #endif // IPC_HANDLE_ATTACHMENT_WIN_H_ |
| OLD | NEW |