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

Side by Side Diff: ipc/handle_attachment_win.h

Issue 1493413004: ipc: Allow attachment brokering for shared memory handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp1
Patch Set: Fix more tests. Created 4 years, 11 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
« no previous file with comments | « ipc/attachment_broker_unprivileged_win_unittest.cc ('k') | ipc/handle_attachment_win.cc » ('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 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
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_
OLDNEW
« no previous file with comments | « ipc/attachment_broker_unprivileged_win_unittest.cc ('k') | ipc/handle_attachment_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698