Commit fa8f7938 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Remove all ARC dependencies on Mojo EDK

Replaces all EDK usage for ARC-related components with public Mojo
API calls. No functional changes.

Also cleans up relevant DEPS and GN deps.

Bug: 844763
Change-Id: I1cab5ed08bcb08049b4648e3fb4c28664fb04bf7
TBR: jcliang@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/1100041
Commit-Queue: Ken Rockot <rockot@chromium.org>
Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567334}
parent 4eab3f75
...@@ -23,7 +23,6 @@ include_rules = [ ...@@ -23,7 +23,6 @@ include_rules = [
"+media/audio/sounds", # For system sounds "+media/audio/sounds", # For system sounds
"+media/base/media_switches.h", # For media command line switches. "+media/base/media_switches.h", # For media command line switches.
"+media/mojo/interfaces", # For platform verification mojom interface. "+media/mojo/interfaces", # For platform verification mojom interface.
"+mojo/edk/embedder",
"+services/device/public", "+services/device/public",
"+services/metrics/public", "+services/metrics/public",
"+services/tracing/public", "+services/tracing/public",
......
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include "device/bluetooth/bluetooth_local_gatt_descriptor.h" #include "device/bluetooth/bluetooth_local_gatt_descriptor.h"
#include "device/bluetooth/bluez/bluetooth_device_bluez.h" #include "device/bluetooth/bluez/bluetooth_device_bluez.h"
#include "device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h" #include "device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h"
#include "mojo/edk/embedder/embedder.h" #include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/edk/embedder/scoped_platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
using device::BluetoothAdapter; using device::BluetoothAdapter;
using device::BluetoothAdapterFactory; using device::BluetoothAdapterFactory;
...@@ -1854,19 +1854,16 @@ void ArcBluetoothBridge::OpenBluetoothSocket( ...@@ -1854,19 +1854,16 @@ void ArcBluetoothBridge::OpenBluetoothSocket(
std::move(callback).Run(mojo::ScopedHandle()); std::move(callback).Run(mojo::ScopedHandle());
return; return;
} }
mojo::edk::ScopedInternalPlatformHandle platform_handle{
mojo::edk::InternalPlatformHandle(sock.release())}; mojo::ScopedHandle handle =
MojoHandle wrapped_handle; mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(sock)));
MojoResult wrap_result = mojo::edk::CreateInternalPlatformHandleWrapper( if (handle.is_valid() != MOJO_RESULT_OK) {
std::move(platform_handle), &wrapped_handle); LOG(ERROR) << "Failed to wrap socket handle. Closing";
if (wrap_result != MOJO_RESULT_OK) {
LOG(ERROR) << "Failed to wrap handles. Closing: " << wrap_result;
std::move(callback).Run(mojo::ScopedHandle()); std::move(callback).Run(mojo::ScopedHandle());
return; return;
} }
mojo::ScopedHandle scoped_handle{mojo::Handle(wrapped_handle)};
std::move(callback).Run(std::move(scoped_handle)); std::move(callback).Run(std::move(handle));
} }
bool ArcBluetoothBridge::IsGattServerAttributeHandleAvailable(int need) { bool ArcBluetoothBridge::IsGattServerAttributeHandleAvailable(int need) {
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.h" #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "mojo/edk/embedder/embedder.h" #include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
...@@ -117,14 +118,14 @@ void ArcContentFileSystemFileStreamReader::OnOpenFile( ...@@ -117,14 +118,14 @@ void ArcContentFileSystemFileStreamReader::OnOpenFile(
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
DCHECK(!file_); DCHECK(!file_);
mojo::edk::ScopedInternalPlatformHandle platform_handle; mojo::PlatformHandle platform_handle =
if (mojo::edk::PassWrappedInternalPlatformHandle( mojo::UnwrapPlatformHandle(std::move(handle));
handle.release().value(), &platform_handle) != MOJO_RESULT_OK) { if (!platform_handle.is_valid()) {
LOG(ERROR) << "PassWrappedInternalPlatformHandle failed"; LOG(ERROR) << "PassWrappedInternalPlatformHandle failed";
callback.Run(net::ERR_FAILED); callback.Run(net::ERR_FAILED);
return; return;
} }
file_.reset(new base::File(platform_handle.release().handle)); file_ = std::make_unique<base::File>(platform_handle.ReleaseFD());
if (!file_->IsValid()) { if (!file_->IsValid()) {
LOG(ERROR) << "Invalid file."; LOG(ERROR) << "Invalid file.";
callback.Run(net::ERR_FAILED); callback.Run(net::ERR_FAILED);
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "extensions/browser/api/file_handlers/mime_util.h" #include "extensions/browser/api/file_handlers/mime_util.h"
#include "mojo/edk/embedder/embedder.h" #include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/edk/embedder/scoped_platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "storage/browser/fileapi/file_system_context.h" #include "storage/browser/fileapi/file_system_context.h"
...@@ -253,17 +253,14 @@ void ArcFileSystemBridge::OnOpenFile(const GURL& url_decoded, ...@@ -253,17 +253,14 @@ void ArcFileSystemBridge::OnOpenFile(const GURL& url_decoded,
DCHECK_EQ(id_to_url_.count(id), 0u); DCHECK_EQ(id_to_url_.count(id), 0u);
id_to_url_[id] = url_decoded; id_to_url_[id] = url_decoded;
mojo::edk::ScopedInternalPlatformHandle platform_handle{ mojo::ScopedHandle wrapped_handle =
mojo::edk::InternalPlatformHandle(fd.release())}; mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(fd)));
MojoHandle wrapped_handle = MOJO_HANDLE_INVALID; if (!wrapped_handle.is_valid()) {
MojoResult result = mojo::edk::CreateInternalPlatformHandleWrapper( LOG(ERROR) << "Failed to wrap handle";
std::move(platform_handle), &wrapped_handle);
if (result != MOJO_RESULT_OK) {
LOG(ERROR) << "Failed to wrap handle: " << result;
std::move(callback).Run(mojo::ScopedHandle()); std::move(callback).Run(mojo::ScopedHandle());
return; return;
} }
std::move(callback).Run(mojo::ScopedHandle(mojo::Handle(wrapped_handle))); std::move(callback).Run(std::move(wrapped_handle));
} }
bool ArcFileSystemBridge::HandleReadRequest(const std::string& id, bool ArcFileSystemBridge::HandleReadRequest(const std::string& id,
......
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "content/public/common/child_process_host.h" #include "content/public/common/child_process_host.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "printing/backend/print_backend.h" #include "printing/backend/print_backend.h"
#include "printing/backend/print_backend_consts.h" #include "printing/backend/print_backend_consts.h"
#include "printing/pdf_metafile_skia.h" #include "printing/pdf_metafile_skia.h"
...@@ -600,16 +601,14 @@ void ArcPrintServiceImpl::Print(mojom::PrintJobInstancePtr instance, ...@@ -600,16 +601,14 @@ void ArcPrintServiceImpl::Print(mojom::PrintJobInstancePtr instance,
settings->set_color(FromArcColorMode(attr->color_mode)); settings->set_color(FromArcColorMode(attr->color_mode));
settings->set_copies(print_job->copies); settings->set_copies(print_job->copies);
settings->set_duplex_mode(FromArcDuplexMode(attr->duplex_mode)); settings->set_duplex_mode(FromArcDuplexMode(attr->duplex_mode));
mojo::edk::ScopedInternalPlatformHandle scoped_handle;
PassWrappedInternalPlatformHandle(print_job->data.release().value(),
&scoped_handle);
base::ScopedFD fd =
mojo::UnwrapPlatformHandle(std::move(print_job->data)).TakeFD();
mojom::PrintJobHostPtr host_proxy; mojom::PrintJobHostPtr host_proxy;
auto job = std::make_unique<PrintJobHostImpl>( auto job = std::make_unique<PrintJobHostImpl>(
mojo::MakeRequest(&host_proxy), std::move(instance), this, mojo::MakeRequest(&host_proxy), std::move(instance), this,
chromeos::CupsPrintJobManagerFactory::GetForBrowserContext(profile_), chromeos::CupsPrintJobManagerFactory::GetForBrowserContext(profile_),
std::move(settings), base::File(scoped_handle.release().handle), std::move(settings), base::File(fd.release()), print_job->data_size);
print_job->data_size);
PrintJobHostImpl* job_raw = job.get(); PrintJobHostImpl* job_raw = job.get();
jobs_.emplace(job_raw, std::move(job)); jobs_.emplace(job_raw, std::move(job));
std::move(callback).Run(std::move(host_proxy)); std::move(callback).Run(std::move(host_proxy));
......
...@@ -92,7 +92,6 @@ static_library("arc") { ...@@ -92,7 +92,6 @@ static_library("arc") {
"//device/usb/mojo", "//device/usb/mojo",
"//device/usb/public/mojom", "//device/usb/public/mojom",
"//google_apis", "//google_apis",
"//mojo/edk",
"//services/device/public/mojom", "//services/device/public/mojom",
"//skia", "//skia",
"//third_party/re2:re2", "//third_party/re2:re2",
...@@ -260,7 +259,7 @@ static_library("arc_test_support") { ...@@ -260,7 +259,7 @@ static_library("arc_test_support") {
"//components/prefs:test_support", "//components/prefs:test_support",
"//components/user_prefs", "//components/user_prefs",
"//content/test:test_support", "//content/test:test_support",
"//mojo/edk", "//mojo/public/cpp/platform",
"//mojo/public/cpp/system", "//mojo/public/cpp/system",
] ]
} }
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#include "components/arc/arc_bridge_host_impl.h" #include "components/arc/arc_bridge_host_impl.h"
#include "components/arc/arc_features.h" #include "components/arc/arc_features.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "mojo/edk/embedder/platform_channel_utils_posix.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/platform/named_platform_channel.h" #include "mojo/public/cpp/platform/named_platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/public/cpp/platform/socket_utils_posix.h"
#include "mojo/public/cpp/system/invitation.h" #include "mojo/public/cpp/system/invitation.h"
namespace arc { namespace arc {
...@@ -174,12 +174,10 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal( ...@@ -174,12 +174,10 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal(
return mojo::ScopedMessagePipeHandle(); return mojo::ScopedMessagePipeHandle();
} }
mojo::edk::ScopedInternalPlatformHandle server_handle( base::ScopedFD connection_fd;
mojo::edk::InternalPlatformHandle(socket_fd.release())); if (!mojo::AcceptSocketConnection(socket_fd.get(), &connection_fd,
mojo::edk::ScopedInternalPlatformHandle scoped_fd; /* check_peer_user = */ false) ||
if (!mojo::edk::ServerAcceptConnection(server_handle, &scoped_fd, !connection_fd.is_valid()) {
/* check_peer_user = */ false) ||
!scoped_fd.is_valid()) {
return mojo::ScopedMessagePipeHandle(); return mojo::ScopedMessagePipeHandle();
} }
...@@ -193,9 +191,8 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal( ...@@ -193,9 +191,8 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal(
base::kNullProcessHandle, base::kNullProcessHandle,
channel.TakeLocalEndpoint()); channel.TakeLocalEndpoint());
std::vector<mojo::edk::ScopedInternalPlatformHandle> handles; std::vector<base::ScopedFD> fds;
handles.emplace_back(mojo::edk::InternalPlatformHandle( fds.emplace_back(channel.TakeRemoteEndpoint().TakePlatformHandle().TakeFD());
channel.TakeRemoteEndpoint().TakePlatformHandle().TakeFD().release()));
// We need to send the length of the message as a single byte, so make sure it // We need to send the length of the message as a single byte, so make sure it
// fits. // fits.
...@@ -203,8 +200,8 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal( ...@@ -203,8 +200,8 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal(
uint8_t message_length = static_cast<uint8_t>(token.size()); uint8_t message_length = static_cast<uint8_t>(token.size());
struct iovec iov[] = {{&message_length, sizeof(message_length)}, struct iovec iov[] = {{&message_length, sizeof(message_length)},
{const_cast<char*>(token.c_str()), token.size()}}; {const_cast<char*>(token.c_str()), token.size()}};
ssize_t result = mojo::edk::PlatformChannelSendmsgWithHandles( ssize_t result = mojo::SendmsgWithHandles(connection_fd.get(), iov,
scoped_fd, iov, sizeof(iov) / sizeof(iov[0]), handles); sizeof(iov) / sizeof(iov[0]), fds);
if (result == -1) { if (result == -1) {
PLOG(ERROR) << "sendmsg"; PLOG(ERROR) << "sendmsg";
return mojo::ScopedMessagePipeHandle(); return mojo::ScopedMessagePipeHandle();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <utility> #include <utility>
#include "base/files/scoped_file.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/process/launch.h" #include "base/process/launch.h"
...@@ -16,7 +17,7 @@ ...@@ -16,7 +17,7 @@
#include "base/task_scheduler/task_traits.h" #include "base/task_scheduler/task_traits.h"
#include "components/arc/arc_bridge_service.h" #include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "mojo/edk/embedder/embedder.h" #include "mojo/public/cpp/system/platform_handle.h"
namespace { namespace {
...@@ -27,11 +28,9 @@ void RunCrashReporter(const std::string& crash_type, ...@@ -27,11 +28,9 @@ void RunCrashReporter(const std::string& crash_type,
const std::string& device, const std::string& device,
const std::string& board, const std::string& board,
const std::string& cpu_abi, const std::string& cpu_abi,
mojo::edk::ScopedInternalPlatformHandle pipe) { base::ScopedFD pipe) {
base::LaunchOptions options; base::LaunchOptions options;
options.fds_to_remap.push_back( options.fds_to_remap.emplace_back(pipe.get(), STDIN_FILENO);
std::make_pair(pipe.get().handle, STDIN_FILENO));
auto process = auto process =
base::LaunchProcess({kCrashReporterPath, "--arc_java_crash=" + crash_type, base::LaunchProcess({kCrashReporterPath, "--arc_java_crash=" + crash_type,
"--arc_device=" + device, "--arc_board=" + board, "--arc_device=" + device, "--arc_board=" + board,
...@@ -91,14 +90,10 @@ ArcCrashCollectorBridge::~ArcCrashCollectorBridge() { ...@@ -91,14 +90,10 @@ ArcCrashCollectorBridge::~ArcCrashCollectorBridge() {
void ArcCrashCollectorBridge::DumpCrash(const std::string& type, void ArcCrashCollectorBridge::DumpCrash(const std::string& type,
mojo::ScopedHandle pipe) { mojo::ScopedHandle pipe) {
mojo::edk::ScopedInternalPlatformHandle pipe_handle;
mojo::edk::PassWrappedInternalPlatformHandle(pipe.release().value(),
&pipe_handle);
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {base::WithBaseSyncPrimitives()}, FROM_HERE, {base::WithBaseSyncPrimitives()},
base::BindOnce(&RunCrashReporter, type, device_, board_, cpu_abi_, base::BindOnce(&RunCrashReporter, type, device_, board_, cpu_abi_,
std::move(pipe_handle))); mojo::UnwrapPlatformHandle(std::move(pipe)).TakeFD()));
} }
void ArcCrashCollectorBridge::SetBuildProperties(const std::string& device, void ArcCrashCollectorBridge::SetBuildProperties(const std::string& device,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "mojo/edk/embedder/embedder.h" #include "mojo/public/cpp/system/platform_handle.h"
namespace arc { namespace arc {
...@@ -207,16 +207,12 @@ void FakeFileSystemInstance::OpenFileToRead(const std::string& url, ...@@ -207,16 +207,12 @@ void FakeFileSystemInstance::OpenFileToRead(const std::string& url,
file.seekable == File::Seekable::YES file.seekable == File::Seekable::YES
? CreateRegularFileDescriptor(file.content, temp_dir_.GetPath()) ? CreateRegularFileDescriptor(file.content, temp_dir_.GetPath())
: CreateStreamFileDescriptor(file.content); : CreateStreamFileDescriptor(file.content);
mojo::edk::ScopedInternalPlatformHandle platform_handle( mojo::ScopedHandle wrapped_handle =
mojo::edk::InternalPlatformHandle(fd.release())); mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(fd)));
MojoHandle wrapped_handle; DCHECK(wrapped_handle.is_valid());
MojoResult result = mojo::edk::CreateInternalPlatformHandleWrapper(
std::move(platform_handle), &wrapped_handle);
DCHECK_EQ(MOJO_RESULT_OK, result);
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(std::move(callback), base::BindOnce(std::move(callback), std::move(wrapped_handle)));
mojo::ScopedHandle(mojo::Handle(wrapped_handle))));
} }
void FakeFileSystemInstance::GetDocument(const std::string& authority, void FakeFileSystemInstance::GetDocument(const std::string& authority,
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "device/usb/mojo/type_converters.h" #include "device/usb/mojo/type_converters.h"
#include "device/usb/usb_device_handle.h" #include "device/usb/usb_device_handle.h"
#include "device/usb/usb_device_linux.h" #include "device/usb/usb_device_linux.h"
#include "mojo/edk/embedder/embedder.h" #include "mojo/public/cpp/system/platform_handle.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
namespace arc { namespace arc {
namespace { namespace {
...@@ -51,18 +50,14 @@ void OnDeviceOpened(mojom::UsbHostHost::OpenDeviceCallback callback, ...@@ -51,18 +50,14 @@ void OnDeviceOpened(mojom::UsbHostHost::OpenDeviceCallback callback,
std::move(callback).Run(mojo::ScopedHandle()); std::move(callback).Run(mojo::ScopedHandle());
return; return;
} }
mojo::edk::ScopedInternalPlatformHandle platform_handle{ mojo::ScopedHandle wrapped_handle =
mojo::edk::InternalPlatformHandle(fd.release())}; mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(fd)));
MojoHandle wrapped_handle; if (!wrapped_handle.is_valid()) {
MojoResult wrap_result = mojo::edk::CreateInternalPlatformHandleWrapper( LOG(ERROR) << "Failed to wrap device FD. Closing.";
std::move(platform_handle), &wrapped_handle);
if (wrap_result != MOJO_RESULT_OK) {
LOG(ERROR) << "Failed to wrap device FD. Closing: " << wrap_result;
std::move(callback).Run(mojo::ScopedHandle()); std::move(callback).Run(mojo::ScopedHandle());
return; return;
} }
mojo::ScopedHandle scoped_handle{mojo::Handle(wrapped_handle)}; std::move(callback).Run(std::move(wrapped_handle));
std::move(callback).Run(std::move(scoped_handle));
} }
void OnDeviceOpenError(mojom::UsbHostHost::OpenDeviceCallback callback, void OnDeviceOpenError(mojom::UsbHostHost::OpenDeviceCallback callback,
......
...@@ -5,7 +5,6 @@ include_rules = [ ...@@ -5,7 +5,6 @@ include_rules = [
"+media/base/video_frame.h", "+media/base/video_frame.h",
"+media/base/video_types.h", "+media/base/video_types.h",
"+media/gpu", "+media/gpu",
"+mojo/edk/embedder",
"+services/service_manager/public/cpp", "+services/service_manager/public/cpp",
"+ui/gfx", "+ui/gfx",
"+ui/ozone/public", "+ui/ozone/public",
......
...@@ -254,7 +254,6 @@ component("capture_lib") { ...@@ -254,7 +254,6 @@ component("capture_lib") {
deps += [ deps += [
"//chromeos:chromeos", "//chromeos:chromeos",
"//media/capture/video/chromeos/mojo:cros_camera", "//media/capture/video/chromeos/mojo:cros_camera",
"//mojo/edk",
"//third_party/libdrm", "//third_party/libdrm",
"//third_party/libsync", "//third_party/libsync",
] ]
......
include_rules = [ include_rules = [
"+chromeos/dbus", "+chromeos/dbus",
"+mojo/edk/embedder",
"+third_party/libsync", "+third_party/libsync",
] ]
...@@ -18,10 +18,9 @@ ...@@ -18,10 +18,9 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "mojo/edk/embedder/platform_channel_utils_posix.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/public/cpp/platform/named_platform_channel.h" #include "mojo/public/cpp/platform/named_platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/platform/socket_utils_posix.h"
#include "mojo/public/cpp/system/invitation.h" #include "mojo/public/cpp/system/invitation.h"
namespace media { namespace media {
...@@ -277,18 +276,18 @@ void CameraHalDispatcherImpl::StartServiceLoop(base::ScopedFD socket_fd, ...@@ -277,18 +276,18 @@ void CameraHalDispatcherImpl::StartServiceLoop(base::ScopedFD socket_fd,
return; return;
} }
proxy_fd_.reset(mojo::edk::InternalPlatformHandle(socket_fd.release())); proxy_fd_ = std::move(socket_fd);
started->Signal(); started->Signal();
VLOG(1) << "CameraHalDispatcherImpl started; waiting for incoming connection"; VLOG(1) << "CameraHalDispatcherImpl started; waiting for incoming connection";
while (true) { while (true) {
if (!WaitForSocketReadable(proxy_fd_.get().handle, cancel_fd.get())) { if (!WaitForSocketReadable(proxy_fd_.get(), cancel_fd.get())) {
VLOG(1) << "Quit CameraHalDispatcherImpl IO thread"; VLOG(1) << "Quit CameraHalDispatcherImpl IO thread";
return; return;
} }
mojo::edk::ScopedInternalPlatformHandle accepted_fd; base::ScopedFD accepted_fd;
if (mojo::edk::ServerAcceptConnection(proxy_fd_, &accepted_fd, false) && if (mojo::AcceptSocketConnection(proxy_fd_.get(), &accepted_fd, false) &&
accepted_fd.is_valid()) { accepted_fd.is_valid()) {
VLOG(1) << "Accepted a connection"; VLOG(1) << "Accepted a connection";
// Hardcode pid 0 since it is unused in mojo. // Hardcode pid 0 since it is unused in mojo.
...@@ -305,13 +304,12 @@ void CameraHalDispatcherImpl::StartServiceLoop(base::ScopedFD socket_fd, ...@@ -305,13 +304,12 @@ void CameraHalDispatcherImpl::StartServiceLoop(base::ScopedFD socket_fd,
channel.TakeLocalEndpoint()); channel.TakeLocalEndpoint());
auto remote_endpoint = channel.TakeRemoteEndpoint(); auto remote_endpoint = channel.TakeRemoteEndpoint();
std::vector<mojo::edk::ScopedInternalPlatformHandle> handles; std::vector<base::ScopedFD> fds;
handles.emplace_back(mojo::edk::InternalPlatformHandle( fds.emplace_back(remote_endpoint.TakePlatformHandle().TakeFD());
remote_endpoint.TakePlatformHandle().TakeFD().release()));
struct iovec iov = {const_cast<char*>(token.c_str()), token.length()}; struct iovec iov = {const_cast<char*>(token.c_str()), token.length()};
ssize_t result = mojo::edk::PlatformChannelSendmsgWithHandles( ssize_t result =
accepted_fd, &iov, 1, handles); mojo::SendmsgWithHandles(accepted_fd.get(), &iov, 1, fds);
if (result == -1) { if (result == -1) {
PLOG(ERROR) << "sendmsg()"; PLOG(ERROR) << "sendmsg()";
} else { } else {
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include "base/files/scoped_file.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "media/capture/capture_export.h" #include "media/capture/capture_export.h"
#include "media/capture/video/chromeos/mojo/cros_camera_service.mojom.h" #include "media/capture/video/chromeos/mojo/cros_camera_service.mojom.h"
#include "media/capture/video/video_capture_device_factory.h" #include "media/capture/video/video_capture_device_factory.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h" #include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "mojo/public/cpp/platform/platform_channel_server_endpoint.h" #include "mojo/public/cpp/platform/platform_channel_server_endpoint.h"
...@@ -95,7 +95,7 @@ class CAPTURE_EXPORT CameraHalDispatcherImpl final ...@@ -95,7 +95,7 @@ class CAPTURE_EXPORT CameraHalDispatcherImpl final
void StopOnProxyThread(); void StopOnProxyThread();
mojo::edk::ScopedInternalPlatformHandle proxy_fd_; base::ScopedFD proxy_fd_;
base::ScopedFD cancel_pipe_; base::ScopedFD cancel_pipe_;
base::Thread proxy_thread_; base::Thread proxy_thread_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment