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

Side by Side 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 unified diff | Download patch
OLDNEW
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 #include "ipc/brokerable_attachment.h" 5 #include "ipc/brokerable_attachment.h"
6 6
7 #include <limits>
8
9 #include "base/rand_util.h"
10
7 namespace IPC { 11 namespace IPC {
8 12
9 BrokerableAttachment::BrokerableAttachment() { 13 namespace {
14
15 BrokerableAttachment::AttachmentId GetRandomId() {
16 BrokerableAttachment::AttachmentId id;
17 for (int i = 0; i < 4; ++i) {
18 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.
19 std::numeric_limits<int>::max());
20 }
21 return id;
22 }
23
24 } // namespace
25
26 BrokerableAttachment::BrokerableAttachment() : id_(GetRandomId()) {
10 } 27 }
11 28
12 BrokerableAttachment::~BrokerableAttachment() { 29 BrokerableAttachment::~BrokerableAttachment() {
13 } 30 }
14 31
15 BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const { 32 BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const {
16 return id_; 33 return id_;
17 } 34 }
18 35
36 BrokerableAttachment::Type BrokerableAttachment::GetType() const {
37 return TYPE_BROKERABLE_ATTACHMENT;
38 }
39
19 } // namespace IPC 40 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698