| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "components/arc/video_accelerator/arc_video_accelerator_util.h" |
| |
| #include "base/files/platform_file.h" |
| #include "mojo/public/cpp/system/platform_handle.h" |
| |
| #define VLOGF(level) VLOG(level) << __func__ << "(): " |
| |
| namespace arc { |
| |
| base::ScopedFD UnwrapFdFromMojoHandle(mojo::ScopedHandle handle) { |
| if (!handle.is_valid()) { |
| VLOGF(1) << "Handle is invalid."; |
| return base::ScopedFD(); |
| } |
| |
| base::PlatformFile platform_file; |
| MojoResult mojo_result = |
| mojo::UnwrapPlatformFile(std::move(handle), &platform_file); |
| if (mojo_result != MOJO_RESULT_OK) { |
| VLOGF(1) << "UnwrapPlatformFile failed: " << mojo_result; |
| return base::ScopedFD(); |
| } |
| |
| return base::ScopedFD(platform_file); |
| } |
| } // namespace arc |