OLD | NEW |
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 <algorithm> |
| 11 |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "ipc/ipc_export.h" | 13 #include "ipc/ipc_export.h" |
12 #include "ipc/ipc_message_attachment.h" | 14 #include "ipc/ipc_message_attachment.h" |
13 | 15 |
14 namespace IPC { | 16 namespace IPC { |
15 | 17 |
16 // This subclass of MessageAttachment requires an AttachmentBroker to be | 18 // This subclass of MessageAttachment requires an AttachmentBroker to be |
17 // attached to a Chrome IPC message. | 19 // attached to a Chrome IPC message. |
18 class IPC_EXPORT BrokerableAttachment : public MessageAttachment { | 20 class IPC_EXPORT BrokerableAttachment : public MessageAttachment { |
19 public: | 21 public: |
(...skipping 10 matching lines...) Expand all Loading... |
30 // constructor. | 32 // constructor. |
31 AttachmentId(); | 33 AttachmentId(); |
32 | 34 |
33 // Constructs an AttachmentId from a buffer. | 35 // Constructs an AttachmentId from a buffer. |
34 AttachmentId(const char* start_address, size_t size); | 36 AttachmentId(const char* start_address, size_t size); |
35 | 37 |
36 // Writes the nonce into a buffer. | 38 // Writes the nonce into a buffer. |
37 void SerializeToBuffer(char* start_address, size_t size); | 39 void SerializeToBuffer(char* start_address, size_t size); |
38 | 40 |
39 bool operator==(const AttachmentId& rhs) const { | 41 bool operator==(const AttachmentId& rhs) const { |
40 for (size_t i = 0; i < kNonceSize; ++i) { | 42 return std::equal(nonce, nonce + kNonceSize, rhs.nonce); |
41 if (nonce[i] != rhs.nonce[i]) | |
42 return false; | |
43 } | |
44 return true; | |
45 } | 43 } |
46 | 44 |
47 bool operator<(const AttachmentId& rhs) const { | 45 bool operator<(const AttachmentId& rhs) const { |
48 for (size_t i = 0; i < kNonceSize; ++i) { | 46 return std::lexicographical_compare(nonce, nonce + kNonceSize, rhs.nonce, |
49 if (nonce[i] < rhs.nonce[i]) | 47 rhs.nonce + kNonceSize); |
50 return true; | |
51 if (nonce[i] > rhs.nonce[i]) | |
52 return false; | |
53 } | |
54 return false; | |
55 } | 48 } |
56 }; | 49 }; |
57 | 50 |
58 enum BrokerableType { | 51 enum BrokerableType { |
59 PLACEHOLDER, | 52 PLACEHOLDER, |
60 WIN_HANDLE, | 53 WIN_HANDLE, |
61 MACH_PORT, | 54 MACH_PORT, |
62 }; | 55 }; |
63 | 56 |
64 // The identifier is unique across all Chrome processes. | 57 // The identifier is unique across all Chrome processes. |
(...skipping 22 matching lines...) Expand all Loading... |
87 // This member uniquely identifies a BrokerableAttachment across all Chrome | 80 // This member uniquely identifies a BrokerableAttachment across all Chrome |
88 // processes. | 81 // processes. |
89 const AttachmentId id_; | 82 const AttachmentId id_; |
90 | 83 |
91 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment); | 84 DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment); |
92 }; | 85 }; |
93 | 86 |
94 } // namespace IPC | 87 } // namespace IPC |
95 | 88 |
96 #endif // IPC_BROKERABLE_ATTACHMENT_H_ | 89 #endif // IPC_BROKERABLE_ATTACHMENT_H_ |
OLD | NEW |