| OLD | NEW |
| 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 "crypto/random.h" | 7 #include "crypto/random.h" |
| 8 | 8 |
| 9 namespace IPC { | 9 namespace IPC { |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 BrokerableAttachment::AttachmentId GetRandomId() { | 13 BrokerableAttachment::AttachmentId GetRandomId() { |
| 14 BrokerableAttachment::AttachmentId id; | 14 BrokerableAttachment::AttachmentId id; |
| 15 crypto::RandBytes(id.nonce, BrokerableAttachment::kNonceSize); | 15 crypto::RandBytes(id.nonce, BrokerableAttachment::kNonceSize); |
| 16 return id; | 16 return id; |
| 17 } | 17 } |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 BrokerableAttachment::BrokerableAttachment() : id_(GetRandomId()) { | 21 BrokerableAttachment::BrokerableAttachment() : id_(GetRandomId()) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 BrokerableAttachment::BrokerableAttachment(const AttachmentId& id) : id_(id) { |
| 25 } |
| 26 |
| 24 BrokerableAttachment::~BrokerableAttachment() { | 27 BrokerableAttachment::~BrokerableAttachment() { |
| 25 } | 28 } |
| 26 | 29 |
| 27 BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const { | 30 BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const { |
| 28 return id_; | 31 return id_; |
| 29 } | 32 } |
| 30 | 33 |
| 31 BrokerableAttachment::Type BrokerableAttachment::GetType() const { | 34 BrokerableAttachment::Type BrokerableAttachment::GetType() const { |
| 32 return TYPE_BROKERABLE_ATTACHMENT; | 35 return TYPE_BROKERABLE_ATTACHMENT; |
| 33 } | 36 } |
| 34 | 37 |
| 35 } // namespace IPC | 38 } // namespace IPC |
| OLD | NEW |