blob: bd6e7b5cac3704a4a0669f718fc3299f078b39e6 [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
Chris Watkins2d879af2017-11-30 02:11:5919PlatformFileAttachment::~PlatformFileAttachment() = default;
morrita98b7aaa2015-01-26 22:42:5420
21MessageAttachment::Type PlatformFileAttachment::GetType() const {
sammc6ed3efb2016-11-23 03:17:3522 return Type::PLATFORM_FILE;
morrita98b7aaa2015-01-26 22:42:5423}
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) {
sammc6ed3efb2016-11-23 03:17:3532 DCHECK_EQ(attachment->GetType(), MessageAttachment::Type::PLATFORM_FILE);
morrita98b7aaa2015-01-26 22:42:5433 return static_cast<PlatformFileAttachment*>(attachment.get())->file();
34}
35
36} // namespace internal
37} // namespace IPC