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 |