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

Unified Diff: ipc/brokerable_attachment.cc

Issue 1286253002: IPC: Add attachment brokering support to the message header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error. 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
« no previous file with comments | « ipc/brokerable_attachment.h ('k') | ipc/handle_attachment_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/brokerable_attachment.cc
diff --git a/ipc/brokerable_attachment.cc b/ipc/brokerable_attachment.cc
index f1cc9b2afaa624b7b61d33b9f83539c159b33779..4a1becc218f57823e9e88af3d9a03a609689cef0 100644
--- a/ipc/brokerable_attachment.cc
+++ b/ipc/brokerable_attachment.cc
@@ -4,47 +4,65 @@
#include "ipc/brokerable_attachment.h"
+#include "ipc/attachment_broker.h"
+
+#if USE_ATTACHMENT_BROKER
#include "crypto/random.h"
+#endif
namespace IPC {
-namespace {
+#if USE_ATTACHMENT_BROKER
+BrokerableAttachment::AttachmentId::AttachmentId() {
+ // In order to prevent mutually untrusted processes from stealing resources
+ // from one another, the nonce must be secret. This generates a 128-bit,
+ // cryptographicaly-strong random number.
+ crypto::RandBytes(nonce, BrokerableAttachment::kNonceSize);
+}
+#else
+BrokerableAttachment::AttachmentId::AttachmentId() {
+ CHECK(false) << "Not allowed to construct an attachment id if the platform "
+ "does not support attachment brokering.";
+}
+#endif
-// In order to prevent mutually untrusted processes from stealing resources from
-// one another, the nonce must be secret. This generates a 128-bit,
-// cryptographicaly-strong random number.
-BrokerableAttachment::AttachmentId GetRandomId() {
- BrokerableAttachment::AttachmentId id;
- crypto::RandBytes(id.nonce, BrokerableAttachment::kNonceSize);
- return id;
+BrokerableAttachment::AttachmentId::AttachmentId(const char* start_address,
+ size_t size) {
+ DCHECK(size == BrokerableAttachment::kNonceSize);
+ for (size_t i = 0; i < BrokerableAttachment::kNonceSize; ++i)
+ nonce[i] = start_address[i];
}
-} // namespace
+void BrokerableAttachment::AttachmentId::SerializeToBuffer(char* start_address,
+ size_t size) {
+ DCHECK(size == BrokerableAttachment::kNonceSize);
+ for (size_t i = 0; i < BrokerableAttachment::kNonceSize; ++i)
+ start_address[i] = nonce[i];
+}
-BrokerableAttachment::BrokerableAttachment()
- : id_(GetRandomId()), needs_brokering_(false) {}
+BrokerableAttachment::BrokerableAttachment() {}
-BrokerableAttachment::BrokerableAttachment(const AttachmentId& id,
- bool needs_brokering)
- : id_(id), needs_brokering_(needs_brokering) {}
+BrokerableAttachment::BrokerableAttachment(const AttachmentId& id) : id_(id) {}
-BrokerableAttachment::~BrokerableAttachment() {
-}
+BrokerableAttachment::~BrokerableAttachment() {}
BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const {
return id_;
}
bool BrokerableAttachment::NeedsBrokering() const {
- return needs_brokering_;
-}
-
-void BrokerableAttachment::SetNeedsBrokering(bool needs_brokering) {
- needs_brokering_ = needs_brokering;
+ return GetBrokerableType() == PLACEHOLDER;
}
BrokerableAttachment::Type BrokerableAttachment::GetType() const {
return TYPE_BROKERABLE_ATTACHMENT;
}
+#if defined(OS_POSIX)
+base::PlatformFile BrokerableAttachment::TakePlatformFile() {
+ NOTREACHED();
+ return base::PlatformFile();
+}
+#endif // OS_POSIX
+
} // namespace IPC
« no previous file with comments | « ipc/brokerable_attachment.h ('k') | ipc/handle_attachment_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698