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

Side by Side Diff: ipc/handle_attachment_win.h

Issue 1281083004: ipc: Add the class HandleWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add logging. Created 5 years, 4 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"
11 #include "ipc/brokerable_attachment.h" 11 #include "ipc/brokerable_attachment.h"
12 #include "ipc/handle_win.h"
12 #include "ipc/ipc_export.h" 13 #include "ipc/ipc_export.h"
13 14
14 namespace IPC { 15 namespace IPC {
15 namespace internal { 16 namespace internal {
16 17
17 // This class represents a Windows HANDLE attached to a Chrome IPC message. 18 // This class represents a Windows HANDLE attached to a Chrome IPC message.
18 class IPC_EXPORT HandleAttachmentWin : public BrokerableAttachment { 19 class IPC_EXPORT HandleAttachmentWin : public BrokerableAttachment {
19 public: 20 public:
20 // The wire format for this handle. 21 // The wire format for this handle.
21 struct IPC_EXPORT WireFormat { 22 struct IPC_EXPORT WireFormat {
22 // The HANDLE that is intended for duplication, or the HANDLE that has been 23 // The HANDLE that is intended for duplication, or the HANDLE that has been
23 // duplicated, depending on context. 24 // duplicated, depending on context.
24 // The type is int32_t instead of HANDLE because HANDLE gets typedefed to 25 // The type is int32_t instead of HANDLE because HANDLE gets typedefed to
25 // void*, whose size varies between 32 and 64-bit processes. Using a 26 // void*, whose size varies between 32 and 64-bit processes. Using a
26 // int32_t means that 64-bit processes will need to perform both up-casting 27 // int32_t means that 64-bit processes will need to perform both up-casting
27 // and down-casting. This is performed using the appropriate Windows apis. 28 // and down-casting. This is performed using the appropriate Windows apis.
28 // A value of 0 is equivalent to an invalid handle. 29 // A value of 0 is equivalent to an invalid handle.
29 int32_t handle; 30 int32_t handle;
30 // The id of the destination process that the handle is duplicated into. 31 // The id of the destination process that the handle is duplicated into.
31 base::ProcessId destination_process; 32 base::ProcessId destination_process;
33 // The permissions to use when duplicating the handle.
34 HandleWin::Permissions permissions;
32 AttachmentId attachment_id; 35 AttachmentId attachment_id;
33 }; 36 };
34 37
35 explicit HandleAttachmentWin(const HANDLE& handle); 38 HandleAttachmentWin(const HANDLE& handle, HandleWin::Permissions permissions);
36 explicit HandleAttachmentWin(const WireFormat& wire_format); 39 explicit HandleAttachmentWin(const WireFormat& wire_format);
37 explicit HandleAttachmentWin(const BrokerableAttachment::AttachmentId& id); 40 explicit HandleAttachmentWin(const BrokerableAttachment::AttachmentId& id);
38 41
39 BrokerableType GetBrokerableType() const override; 42 BrokerableType GetBrokerableType() const override;
40 void PopulateWithAttachment(const BrokerableAttachment* attachment) override; 43 void PopulateWithAttachment(const BrokerableAttachment* attachment) override;
41 44
42 // Returns the wire format of this attachment. 45 // Returns the wire format of this attachment.
43 WireFormat GetWireFormat(const base::ProcessId& destination) const; 46 WireFormat GetWireFormat(const base::ProcessId& destination) const;
44 47
45 HANDLE get_handle() const { return handle_; } 48 HANDLE get_handle() const { return handle_; }
46 49
47 private: 50 private:
48 ~HandleAttachmentWin() override; 51 ~HandleAttachmentWin() override;
49 HANDLE handle_; 52 HANDLE handle_;
53 HandleWin::Permissions permissions_;
50 }; 54 };
51 55
52 } // namespace internal 56 } // namespace internal
53 } // namespace IPC 57 } // namespace IPC
54 58
55 #endif // IPC_HANDLE_ATTACHMENT_WIN_H_ 59 #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