blob: b130ab26eb7db62a4970b2a93ca4237915d7a339 [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
danakje3de838f2015-12-03 01:49:407#include <utility>
8
morrita98b7aaa2015-01-26 22:42:549namespace IPC {
10namespace internal {
11
12PlatformFileAttachment::PlatformFileAttachment(base::PlatformFile file)
13 : file_(file) {
14}
15
morrita1aa788c2015-01-31 05:45:4216PlatformFileAttachment::PlatformFileAttachment(base::ScopedFD file)
danakje3de838f2015-12-03 01:49:4017 : file_(file.get()), owning_(std::move(file)) {}
morrita1aa788c2015-01-31 05:45:4218
morrita98b7aaa2015-01-26 22:42:5419PlatformFileAttachment::~PlatformFileAttachment() {
20}
21
22MessageAttachment::Type PlatformFileAttachment::GetType() const {
23 return TYPE_PLATFORM_FILE;
24}
25
morrita1aa788c2015-01-31 05:45:4226base::PlatformFile PlatformFileAttachment::TakePlatformFile() {
27 ignore_result(owning_.release());
28 return file_;
29}
30
morrita98b7aaa2015-01-26 22:42:5431base::PlatformFile GetPlatformFile(
32 scoped_refptr<MessageAttachment> attachment) {
33 DCHECK_EQ(attachment->GetType(), MessageAttachment::TYPE_PLATFORM_FILE);
34 return static_cast<PlatformFileAttachment*>(attachment.get())->file();
35}
36
37} // namespace internal
38} // namespace IPC