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

Unified Diff: ipc/brokerable_attachment.cc

Issue 1188923003: Stub in more IPC attachment brokering functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing files. Created 5 years, 6 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.cc
diff --git a/ipc/brokerable_attachment.cc b/ipc/brokerable_attachment.cc
index be5d51b2069451e25eb1ff987fb48bfd32e9b166..005fe31b14ab3f862c79a5a5a81f1d065b85c322 100644
--- a/ipc/brokerable_attachment.cc
+++ b/ipc/brokerable_attachment.cc
@@ -4,9 +4,26 @@
#include "ipc/brokerable_attachment.h"
+#include <limits>
+
+#include "base/rand_util.h"
+
namespace IPC {
-BrokerableAttachment::BrokerableAttachment() {
+namespace {
+
+BrokerableAttachment::AttachmentId GetRandomId() {
+ BrokerableAttachment::AttachmentId id;
+ for (int i = 0; i < 4; ++i) {
+ id.nonce[i] = base::RandInt(std::numeric_limits<int>::min(),
Tom Sepez 2015/06/19 18:04:10 Does this need to be unguessable? If so, you need
Tom Sepez 2015/06/19 18:04:11 nit: signed to unsigned assignment. Maybe the non
erikchen 2015/06/23 22:37:00 Yes it does. I've switched to crypto::RandBytes.
erikchen 2015/06/23 22:37:00 Good suggestion, done.
+ std::numeric_limits<int>::max());
+ }
+ return id;
+}
+
+} // namespace
+
+BrokerableAttachment::BrokerableAttachment() : id_(GetRandomId()) {
}
BrokerableAttachment::~BrokerableAttachment() {
@@ -16,4 +33,8 @@ BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const {
return id_;
}
+BrokerableAttachment::Type BrokerableAttachment::GetType() const {
+ return TYPE_BROKERABLE_ATTACHMENT;
+}
+
} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698