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"
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.";
18 BrokerableAttachment::AttachmentId::AttachmentId(const char* start_address
,
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
,
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 {
42 bool BrokerableAttachment::NeedsBrokering() const {
43 return GetBrokerableType() == PLACEHOLDER
;
46 BrokerableAttachment::Type
BrokerableAttachment::GetType() const {
47 return TYPE_BROKERABLE_ATTACHMENT
;
51 base::PlatformFile
BrokerableAttachment::TakePlatformFile() {
53 return base::PlatformFile();