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

Unified Diff: ipc/brokerable_attachment.h

Issue 1286253002: IPC: Add attachment brokering support to the message header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more #ifs 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 side-by-side diff with in-line comments
Download patch
Index: ipc/brokerable_attachment.h
diff --git a/ipc/brokerable_attachment.h b/ipc/brokerable_attachment.h
index 452d1297aa9df2cfdaa173652131b5f7a944d407..72416a86a3874694d0ef20868728a05085e379b4 100644
--- a/ipc/brokerable_attachment.h
+++ b/ipc/brokerable_attachment.h
@@ -17,31 +17,28 @@ namespace IPC {
// attached to a Chrome IPC message.
class IPC_EXPORT BrokerableAttachment : public MessageAttachment {
public:
- static const size_t kNonceSize = 16;
+ static const size_t kNonceSize;
Tom Sepez 2015/08/17 18:29:39 Why did we lose the initianlizer? should be just c
erikchen 2015/08/18 05:59:46 I looked into this further...the actual problem li
// An id uniquely identifies an attachment sent via a broker.
struct IPC_EXPORT AttachmentId {
- uint8_t nonce[kNonceSize];
-
- bool operator==(const AttachmentId& rhs) const {
- for (size_t i = 0; i < kNonceSize; ++i) {
- if (nonce[i] != rhs.nonce[i])
- return false;
- }
- return true;
- }
-
- bool operator<(const AttachmentId& rhs) const {
- for (size_t i = 0; i < kNonceSize; ++i) {
- if (nonce[i] < rhs.nonce[i])
- return true;
- if (nonce[i] > rhs.nonce[i])
- return false;
- }
- return false;
- }
+ // The size of this array must match kNonceSize.
+ uint8_t nonce[16];
+
+ // Default constructor doesn't initialize nonce.
Tom Sepez 2015/08/17 18:29:39 nit: Seems like a mistake to leave it uninitizlize
erikchen 2015/08/18 05:59:46 You're right, I've changed the behavior and update
+ AttachmentId(){};
+
+ // Constructs an AttachmentId from a buffer.
+ AttachmentId(const char* start_address, size_t size);
+
+ // Writes the nonce into a buffer.
+ void SerializeToBuffer(char* start_address, size_t size);
+
+ bool operator==(const AttachmentId& rhs) const;
Tom Sepez 2015/08/17 18:29:39 probably want to put the code in here to help the
erikchen 2015/08/18 05:59:46 Done.
+
+ bool operator<(const AttachmentId& rhs) const;
};
enum BrokerableType {
+ PLACEHOLDER,
WIN_HANDLE,
};
@@ -52,31 +49,26 @@ class IPC_EXPORT BrokerableAttachment : public MessageAttachment {
// can be used.
bool NeedsBrokering() const;
- // Fills in the data of this instance with the data from |attachment|.
- // This instance must require brokering, |attachment| must be brokered, and
- // both instances must have the same identifier.
- virtual void PopulateWithAttachment(
- const BrokerableAttachment* attachment) = 0;
-
// Returns TYPE_BROKERABLE_ATTACHMENT
Type GetType() const override;
virtual BrokerableType GetBrokerableType() const = 0;
+// MessageAttachment override.
+#if defined(OS_POSIX)
+ base::PlatformFile TakePlatformFile() override;
+#endif // OS_POSIX
+
protected:
BrokerableAttachment();
- BrokerableAttachment(const AttachmentId& id, bool needs_brokering);
+ BrokerableAttachment(const AttachmentId& id);
~BrokerableAttachment() override;
- void SetNeedsBrokering(bool needs_brokering);
-
private:
// This member uniquely identifies a BrokerableAttachment across all Chrome
// processes.
const AttachmentId id_;
- // Whether the attachment still needs to be filled in by an AttachmentBroker.
- bool needs_brokering_;
DISALLOW_COPY_AND_ASSIGN(BrokerableAttachment);
};

Powered by Google App Engine
This is Rietveld 408576698