Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / ipc / brokerable_attachment.cc
blob51096eab5202f360fbc22b2717efbf45b9f9a172
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
3 // found in the LICENSE file.
5 #include "ipc/brokerable_attachment.h"
7 #include "ipc/attachment_broker.h"
9 namespace IPC {
11 #if !USE_ATTACHMENT_BROKER
12 BrokerableAttachment::AttachmentId::AttachmentId() {
13 CHECK(false) << "Not allowed to construct an attachment id if the platform "
14 "does not support attachment brokering.";
16 #endif
18 BrokerableAttachment::AttachmentId::AttachmentId(const char* start_address,
19 size_t size) {
20 DCHECK(size == BrokerableAttachment::kNonceSize);
21 for (size_t i = 0; i < BrokerableAttachment::kNonceSize; ++i)
22 nonce[i] = start_address[i];
25 void BrokerableAttachment::AttachmentId::SerializeToBuffer(char* start_address,
26 size_t size) {
27 DCHECK(size == BrokerableAttachment::kNonceSize);
28 for (size_t i = 0; i < BrokerableAttachment::kNonceSize; ++i)
29 start_address[i] = nonce[i];
32 BrokerableAttachment::BrokerableAttachment() {}
34 BrokerableAttachment::BrokerableAttachment(const AttachmentId& id) : id_(id) {}
36 BrokerableAttachment::~BrokerableAttachment() {}
38 BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const {
39 return id_;
42 bool BrokerableAttachment::NeedsBrokering() const {
43 return GetBrokerableType() == PLACEHOLDER;
46 BrokerableAttachment::Type BrokerableAttachment::GetType() const {
47 return TYPE_BROKERABLE_ATTACHMENT;
50 #if defined(OS_POSIX)
51 base::PlatformFile BrokerableAttachment::TakePlatformFile() {
52 NOTREACHED();
53 return base::PlatformFile();
55 #endif // OS_POSIX
57 } // namespace IPC