blob: b704750c15625cf2ce1889f3d51b48f42acaf81d [file] [log] [blame]
morrita98b7aaa2015-01-26 22:42:541// Copyright (c) 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.
4
morrita1aa788c2015-01-31 05:45:425#include "ipc/ipc_platform_file_attachment_posix.h"
morrita98b7aaa2015-01-26 22:42:546
7namespace IPC {
8namespace internal {
9
10PlatformFileAttachment::PlatformFileAttachment(base::PlatformFile file)
11 : file_(file) {
12}
13
morrita1aa788c2015-01-31 05:45:4214PlatformFileAttachment::PlatformFileAttachment(base::ScopedFD file)
15 : file_(file.get()), owning_(file.Pass()) {
16}
17
morrita98b7aaa2015-01-26 22:42:5418PlatformFileAttachment::~PlatformFileAttachment() {
19}
20
21MessageAttachment::Type PlatformFileAttachment::GetType() const {
22 return TYPE_PLATFORM_FILE;
23}
24
morrita1aa788c2015-01-31 05:45:4225base::PlatformFile PlatformFileAttachment::TakePlatformFile() {
26 ignore_result(owning_.release());
27 return file_;
28}
29
morrita98b7aaa2015-01-26 22:42:5430base::PlatformFile GetPlatformFile(
31 scoped_refptr<MessageAttachment> attachment) {
32 DCHECK_EQ(attachment->GetType(), MessageAttachment::TYPE_PLATFORM_FILE);
33 return static_cast<PlatformFileAttachment*>(attachment.get())->file();
34}
35
36} // namespace internal
37} // namespace IPC