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

Side by Side Diff: ipc/brokerable_attachment.h

Issue 1345633002: ipc: Move //crypto dependency into a Windows-only file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
25 bool operator==(const AttachmentId& rhs) const { 34 bool operator==(const AttachmentId& rhs) const {
26 for (size_t i = 0; i < kNonceSize; ++i) { 35 for (size_t i = 0; i < kNonceSize; ++i) {
27 if (nonce[i] != rhs.nonce[i]) 36 if (nonce[i] != rhs.nonce[i])
28 return false; 37 return false;
29 } 38 }
30 return true; 39 return true;
31 } 40 }
32 41
33 bool operator<(const AttachmentId& rhs) const { 42 bool operator<(const AttachmentId& rhs) const {
34 for (size_t i = 0; i < kNonceSize; ++i) { 43 for (size_t i = 0; i < kNonceSize; ++i) {
(...skipping 22 matching lines...) Expand all
57 // both instances must have the same identifier. 66 // both instances must have the same identifier.
58 virtual void PopulateWithAttachment( 67 virtual void PopulateWithAttachment(
59 const BrokerableAttachment* attachment) = 0; 68 const BrokerableAttachment* attachment) = 0;
60 69
61 // Returns TYPE_BROKERABLE_ATTACHMENT 70 // Returns TYPE_BROKERABLE_ATTACHMENT
62 Type GetType() const override; 71 Type GetType() const override;
63 72
64 virtual BrokerableType GetBrokerableType() const = 0; 73 virtual BrokerableType GetBrokerableType() const = 0;
65 74
66 protected: 75 protected:
76 BrokerableAttachment();
67 BrokerableAttachment(const AttachmentId& id, bool needs_brokering); 77 BrokerableAttachment(const AttachmentId& id, bool needs_brokering);
68 ~BrokerableAttachment() override; 78 ~BrokerableAttachment() override;
69 79
70 void SetNeedsBrokering(bool needs_brokering); 80 void SetNeedsBrokering(bool needs_brokering);
71 81
72 private: 82 private:
73 // This member uniquely identifies a BrokerableAttachment across all Chrome 83 // This member uniquely identifies a BrokerableAttachment across all Chrome
74 // processes. 84 // processes.
75 const AttachmentId id_; 85 const AttachmentId id_;
76 86
77 // Whether the attachment still needs to be filled in by an AttachmentBroker. 87 // Whether the attachment still needs to be filled in by an AttachmentBroker.
78 bool needs_brokering_; 88 bool needs_brokering_;
79 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment); 89 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment);
80 }; 90 };
81 91
82 } // namespace IPC 92 } // namespace IPC
83 93
84 #endif // IPC_BROKERABLE_ATTACHMENT_H_ 94 #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