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

Side by Side Diff: ipc/brokerable_attachment.h

Issue 1321253011: Remove dependency on //crypto in //ipc, except on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fallback_clean
Patch Set: Created 5 years, 3 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/BUILD.gn ('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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "ipc/ipc_export.h" 11 #include "ipc/ipc_export.h"
12 #include "ipc/ipc_message_attachment.h" 12 #include "ipc/ipc_message_attachment.h"
13 13
14 namespace IPC { 14 namespace IPC {
15 15
16 // This subclass of MessageAttachment requires an AttachmentBroker to be 16 // This subclass of MessageAttachment requires an AttachmentBroker to be
17 // attached to a Chrome IPC message. 17 // attached to a Chrome IPC message.
18 class IPC_EXPORT BrokerableAttachment : public MessageAttachment { 18 class IPC_EXPORT BrokerableAttachment : public MessageAttachment {
19 public: 19 public:
20 static const size_t kNonceSize = 16; 20 static const size_t kNonceSize = 16;
21 // An id uniquely identifies an attachment sent via a broker. 21 // An id uniquely identifies an attachment sent via a broker.
22 struct IPC_EXPORT AttachmentId { 22 struct IPC_EXPORT AttachmentId {
23 uint8_t nonce[kNonceSize]; 23 uint8_t nonce[kNonceSize];
24 24
25 // Default constructor returns an unguessable random nonce.
26 AttachmentId();
27
28 // Constructs an AttachmentId from a buffer.
29 AttachmentId(const char* start_address, size_t size);
30
31 // Writes the nonce into a buffer.
32 void SerializeToBuffer(char* start_address, size_t size);
33
34 bool operator==(const AttachmentId& rhs) const { 25 bool operator==(const AttachmentId& rhs) const {
35 for (size_t i = 0; i < kNonceSize; ++i) { 26 for (size_t i = 0; i < kNonceSize; ++i) {
36 if (nonce[i] != rhs.nonce[i]) 27 if (nonce[i] != rhs.nonce[i])
37 return false; 28 return false;
38 } 29 }
39 return true; 30 return true;
40 } 31 }
41 32
42 bool operator<(const AttachmentId& rhs) const { 33 bool operator<(const AttachmentId& rhs) const {
43 for (size_t i = 0; i < kNonceSize; ++i) { 34 for (size_t i = 0; i < kNonceSize; ++i) {
(...skipping 22 matching lines...) Expand all
66 // both instances must have the same identifier. 57 // both instances must have the same identifier.
67 virtual void PopulateWithAttachment( 58 virtual void PopulateWithAttachment(
68 const BrokerableAttachment* attachment) = 0; 59 const BrokerableAttachment* attachment) = 0;
69 60
70 // Returns TYPE_BROKERABLE_ATTACHMENT 61 // Returns TYPE_BROKERABLE_ATTACHMENT
71 Type GetType() const override; 62 Type GetType() const override;
72 63
73 virtual BrokerableType GetBrokerableType() const = 0; 64 virtual BrokerableType GetBrokerableType() const = 0;
74 65
75 protected: 66 protected:
76 BrokerableAttachment();
77 BrokerableAttachment(const AttachmentId& id, bool needs_brokering); 67 BrokerableAttachment(const AttachmentId& id, bool needs_brokering);
78 ~BrokerableAttachment() override; 68 ~BrokerableAttachment() override;
79 69
80 void SetNeedsBrokering(bool needs_brokering); 70 void SetNeedsBrokering(bool needs_brokering);
81 71
82 private: 72 private:
83 // This member uniquely identifies a BrokerableAttachment across all Chrome 73 // This member uniquely identifies a BrokerableAttachment across all Chrome
84 // processes. 74 // processes.
85 const AttachmentId id_; 75 const AttachmentId id_;
86 76
87 // Whether the attachment still needs to be filled in by an AttachmentBroker. 77 // Whether the attachment still needs to be filled in by an AttachmentBroker.
88 bool needs_brokering_; 78 bool needs_brokering_;
89 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment); 79 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment);
90 }; 80 };
91 81
92 } // namespace IPC 82 } // namespace IPC
93 83
94 #endif // IPC_BROKERABLE_ATTACHMENT_H_ 84 #endif // IPC_BROKERABLE_ATTACHMENT_H_
OLDNEW
« no previous file with comments | « ipc/BUILD.gn ('k') | ipc/brokerable_attachment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698