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

Side by Side Diff: ipc/brokerable_attachment.h

Issue 2473993003: Delete IPC::ChannelPosix, IPC::ChannelWin and IPC::AttachmentBroker. (Closed)
Patch Set: Created 4 years, 1 month 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.cc ('k') | ipc/brokerable_attachment.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_BROKERABLE_ATTACHMENT_H_ 5 #ifndef IPC_BROKERABLE_ATTACHMENT_H_
6 #define IPC_BROKERABLE_ATTACHMENT_H_ 6 #define IPC_BROKERABLE_ATTACHMENT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "ipc/ipc_export.h" 15 #include "ipc/ipc_export.h"
16 #include "ipc/ipc_message_attachment.h" 16 #include "ipc/ipc_message_attachment.h"
17 17
18 namespace IPC { 18 namespace IPC {
19 19
20 // This subclass of MessageAttachment requires an AttachmentBroker to be 20 // This subclass of MessageAttachment requires an AttachmentBroker to be
21 // attached to a Chrome IPC message. 21 // attached to a Chrome IPC message.
22 class IPC_EXPORT BrokerableAttachment : public MessageAttachment { 22 class IPC_EXPORT BrokerableAttachment : public MessageAttachment {
23 public: 23 public:
24 static const size_t kNonceSize = 16;
25 // An id uniquely identifies an attachment sent via a broker.
26 struct IPC_EXPORT AttachmentId {
27 uint8_t nonce[kNonceSize];
28
29 // Generates an AttachmentId with an unguessable, random nonce.
30 static AttachmentId CreateIdWithRandomNonce();
31
32 // Creates an AttachmentId with a zeroed nonce. This should only be used by
33 // the IPC translation system, which requires that classes have a default
34 // constructor.
35 AttachmentId();
36
37 // Constructs an AttachmentId from a buffer.
38 AttachmentId(const char* start_address, size_t size);
39
40 // Writes the nonce into a buffer.
41 void SerializeToBuffer(char* start_address, size_t size);
42
43 bool operator==(const AttachmentId& rhs) const {
44 return std::equal(nonce, nonce + kNonceSize, rhs.nonce);
45 }
46
47 bool operator<(const AttachmentId& rhs) const {
48 return std::lexicographical_compare(nonce, nonce + kNonceSize, rhs.nonce,
49 rhs.nonce + kNonceSize);
50 }
51 };
52
53 enum BrokerableType { 24 enum BrokerableType {
54 PLACEHOLDER, 25 PLACEHOLDER,
55 WIN_HANDLE, 26 WIN_HANDLE,
56 MACH_PORT, 27 MACH_PORT,
57 }; 28 };
58 29
59 // The identifier is unique across all Chrome processes.
60 AttachmentId GetIdentifier() const;
61
62 // Whether the attachment still needs information from the broker before it 30 // Whether the attachment still needs information from the broker before it
63 // can be used. 31 // can be used.
64 bool NeedsBrokering() const; 32 bool NeedsBrokering() const;
65 33
66 // Returns TYPE_BROKERABLE_ATTACHMENT 34 // Returns TYPE_BROKERABLE_ATTACHMENT
67 Type GetType() const override; 35 Type GetType() const override;
68 36
69 virtual BrokerableType GetBrokerableType() const = 0; 37 virtual BrokerableType GetBrokerableType() const = 0;
70 38
71 // MessageAttachment override. 39 // MessageAttachment override.
72 #if defined(OS_POSIX) 40 #if defined(OS_POSIX)
73 base::PlatformFile TakePlatformFile() override; 41 base::PlatformFile TakePlatformFile() override;
74 #endif // OS_POSIX 42 #endif // OS_POSIX
75 43
76 protected: 44 protected:
77 BrokerableAttachment(); 45 BrokerableAttachment();
78 BrokerableAttachment(const AttachmentId& id);
79 ~BrokerableAttachment() override; 46 ~BrokerableAttachment() override;
80 47
81 private: 48 private:
82 // This member uniquely identifies a BrokerableAttachment across all Chrome
83 // processes.
84 const AttachmentId id_;
85
86 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment); 49 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment);
87 }; 50 };
88 51
89 } // namespace IPC 52 } // namespace IPC
90 53
91 #endif // IPC_BROKERABLE_ATTACHMENT_H_ 54 #endif // IPC_BROKERABLE_ATTACHMENT_H_
OLDNEW
« no previous file with comments | « ipc/attachment_broker_unprivileged_win.cc ('k') | ipc/brokerable_attachment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698