Commit 18812437 authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Migrate engine_file_requests.mojom to the new Mojo types

Convert the implementation and all users of the
chrome_cleaner::mojom::EngineFileRequests interface.

Bug: 955171
Change-Id: Ia3c314bb521e11a60c3562b976f4a70870977a1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1852248Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarJoe Mason <joenotcharles@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#707956}
parent d0188884
...@@ -290,10 +290,10 @@ void EngineClient::InitializeAsync(InitializeCallback result_callback) { ...@@ -290,10 +290,10 @@ void EngineClient::InitializeAsync(InitializeCallback result_callback) {
if (interface_metadata_observer_) if (interface_metadata_observer_)
interface_metadata_observer_->ObserveCall(CURRENT_FILE_AND_METHOD); interface_metadata_observer_->ObserveCall(CURRENT_FILE_AND_METHOD);
// Create a binding to the EngineFileRequests interface that will receive file // Create a receiver to the EngineFileRequests interface that will receive
// reading requests from Initialize. // file reading requests from Initialize.
mojom::EngineFileRequestsAssociatedPtrInfo file_requests_info; mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests;
sandbox_file_requests_->Bind(&file_requests_info); sandbox_file_requests_->Bind(&file_requests);
// Expose the logging directory for writing debug logs. // Expose the logging directory for writing debug logs.
base::FilePath logging_path; base::FilePath logging_path;
...@@ -303,7 +303,7 @@ void EngineClient::InitializeAsync(InitializeCallback result_callback) { ...@@ -303,7 +303,7 @@ void EngineClient::InitializeAsync(InitializeCallback result_callback) {
#endif #endif
(*engine_commands_) (*engine_commands_)
->Initialize(std::move(file_requests_info), logging_path, ->Initialize(std::move(file_requests), logging_path,
CallbackWithErrorHandling(std::move(result_callback))); CallbackWithErrorHandling(std::move(result_callback)));
} }
...@@ -345,15 +345,14 @@ void EngineClient::StartScanAsync( ...@@ -345,15 +345,14 @@ void EngineClient::StartScanAsync(
EngineClient::FoundUwSCallback found_callback, EngineClient::FoundUwSCallback found_callback,
EngineClient::DoneCallback done_callback, EngineClient::DoneCallback done_callback,
StartScanCallback result_callback) { StartScanCallback result_callback) {
// Create bindings to receive the requests sent from the sandboxed // Create receiver to receive the requests sent from the sandboxed code.
// code. mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests;
mojom::EngineFileRequestsAssociatedPtrInfo file_requests_info; sandbox_file_requests_->Bind(&file_requests);
sandbox_file_requests_->Bind(&file_requests_info);
mojom::EngineRequestsAssociatedPtrInfo engine_requests_info; mojom::EngineRequestsAssociatedPtrInfo engine_requests_info;
sandbox_requests_->Bind(&engine_requests_info); sandbox_requests_->Bind(&engine_requests_info);
// Create a binding to the EngineScanResults interface that will receive // Create a receiver to the EngineScanResults interface that will receive
// results and pass them on to |found_callback| and |done_callback|. // results and pass them on to |found_callback| and |done_callback|.
mojo::PendingAssociatedRemote<mojom::EngineScanResults> scan_results; mojo::PendingAssociatedRemote<mojom::EngineScanResults> scan_results;
...@@ -369,8 +368,8 @@ void EngineClient::StartScanAsync( ...@@ -369,8 +368,8 @@ void EngineClient::StartScanAsync(
// |done_callback|) with further results. // |done_callback|) with further results.
(*engine_commands_) (*engine_commands_)
->StartScan(enabled_uws, enabled_locations, include_details, ->StartScan(enabled_uws, enabled_locations, include_details,
std::move(file_requests_info), std::move(file_requests), std::move(engine_requests_info),
std::move(engine_requests_info), std::move(scan_results), std::move(scan_results),
CallbackWithErrorHandling(std::move(result_callback))); CallbackWithErrorHandling(std::move(result_callback)));
} }
...@@ -408,10 +407,9 @@ uint32_t EngineClient::StartCleanup(const std::vector<UwSId>& enabled_uws, ...@@ -408,10 +407,9 @@ uint32_t EngineClient::StartCleanup(const std::vector<UwSId>& enabled_uws,
void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws, void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws,
EngineClient::DoneCallback done_callback, EngineClient::DoneCallback done_callback,
StartCleanupCallback result_callback) { StartCleanupCallback result_callback) {
// Create bindings to receive the requests sent from the sandboxed // Create receiver to receive the requests sent from the sandboxed code.
// code. mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests;
mojom::EngineFileRequestsAssociatedPtrInfo file_requests_info; sandbox_file_requests_->Bind(&file_requests);
sandbox_file_requests_->Bind(&file_requests_info);
mojom::EngineRequestsAssociatedPtrInfo engine_requests_info; mojom::EngineRequestsAssociatedPtrInfo engine_requests_info;
sandbox_requests_->Bind(&engine_requests_info); sandbox_requests_->Bind(&engine_requests_info);
...@@ -419,8 +417,8 @@ void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws, ...@@ -419,8 +417,8 @@ void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws,
mojom::CleanerEngineRequestsAssociatedPtrInfo cleaner_engine_requests_info; mojom::CleanerEngineRequestsAssociatedPtrInfo cleaner_engine_requests_info;
sandbox_cleaner_requests_->Bind(&cleaner_engine_requests_info); sandbox_cleaner_requests_->Bind(&cleaner_engine_requests_info);
// Create a binding to the EngineCleanupResults interface that will // Create a receiver to the EngineCleanupResults interface that will receive
// receive results and pass them on to |done_callback|. // results and pass them on to |done_callback|.
mojo::PendingAssociatedRemote<mojom::EngineCleanupResults> cleanup_results; mojo::PendingAssociatedRemote<mojom::EngineCleanupResults> cleanup_results;
cleanup_results_impl_->BindToCallbacks(&cleanup_results, cleanup_results_impl_->BindToCallbacks(&cleanup_results,
std::move(done_callback)); std::move(done_callback));
...@@ -429,7 +427,7 @@ void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws, ...@@ -429,7 +427,7 @@ void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws,
interface_metadata_observer_->ObserveCall(CURRENT_FILE_AND_METHOD); interface_metadata_observer_->ObserveCall(CURRENT_FILE_AND_METHOD);
(*engine_commands_) (*engine_commands_)
->StartCleanup(enabled_uws, std::move(file_requests_info), ->StartCleanup(enabled_uws, std::move(file_requests),
std::move(engine_requests_info), std::move(engine_requests_info),
std::move(cleaner_engine_requests_info), std::move(cleaner_engine_requests_info),
std::move(cleanup_results), std::move(cleanup_results),
......
...@@ -34,16 +34,14 @@ EngineFileRequestsImpl::EngineFileRequestsImpl( ...@@ -34,16 +34,14 @@ EngineFileRequestsImpl::EngineFileRequestsImpl(
scoped_refptr<MojoTaskRunner> mojo_task_runner, scoped_refptr<MojoTaskRunner> mojo_task_runner,
InterfaceMetadataObserver* metadata_observer) InterfaceMetadataObserver* metadata_observer)
: mojo_task_runner_(mojo_task_runner), : mojo_task_runner_(mojo_task_runner),
metadata_observer_(metadata_observer), metadata_observer_(metadata_observer) {}
binding_(this) {}
void EngineFileRequestsImpl::Bind( void EngineFileRequestsImpl::Bind(
mojom::EngineFileRequestsAssociatedPtrInfo* ptr_info) { mojo::PendingAssociatedRemote<mojom::EngineFileRequests>* remote) {
if (binding_.is_bound()) receiver_.reset();
binding_.Unbind();
binding_.Bind(mojo::MakeRequest(ptr_info)); receiver_.Bind(remote->InitWithNewEndpointAndPassReceiver());
// There's no need to call set_connection_error_handler on this since it's an // There's no need to call set_disconnect_handler on this since it's an
// associated interface. Any errors will be handled on the main EngineCommands // associated interface. Any errors will be handled on the main EngineCommands
// interface. // interface.
} }
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
#define CHROME_CHROME_CLEANER_ENGINES_BROKER_ENGINE_FILE_REQUESTS_IMPL_H_ #define CHROME_CHROME_CLEANER_ENGINES_BROKER_ENGINE_FILE_REQUESTS_IMPL_H_
#include "chrome/chrome_cleaner/engines/broker/interface_metadata_observer.h" #include "chrome/chrome_cleaner/engines/broker/interface_metadata_observer.h"
#include "chrome/chrome_cleaner/mojom/engine_file_requests.mojom.h"
#include "chrome/chrome_cleaner/ipc/mojo_task_runner.h" #include "chrome/chrome_cleaner/ipc/mojo_task_runner.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "chrome/chrome_cleaner/mojom/engine_file_requests.mojom.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
namespace chrome_cleaner { namespace chrome_cleaner {
...@@ -19,7 +20,7 @@ class EngineFileRequestsImpl : public mojom::EngineFileRequests { ...@@ -19,7 +20,7 @@ class EngineFileRequestsImpl : public mojom::EngineFileRequests {
InterfaceMetadataObserver* metadata_observer = nullptr); InterfaceMetadataObserver* metadata_observer = nullptr);
~EngineFileRequestsImpl() override; ~EngineFileRequestsImpl() override;
void Bind(mojom::EngineFileRequestsAssociatedPtrInfo* ptr_info); void Bind(mojo::PendingAssociatedRemote<mojom::EngineFileRequests>* remote);
// mojom::EngineFileRequests // mojom::EngineFileRequests
void SandboxFindFirstFile( void SandboxFindFirstFile(
...@@ -48,7 +49,7 @@ class EngineFileRequestsImpl : public mojom::EngineFileRequests { ...@@ -48,7 +49,7 @@ class EngineFileRequestsImpl : public mojom::EngineFileRequests {
scoped_refptr<MojoTaskRunner> mojo_task_runner_; scoped_refptr<MojoTaskRunner> mojo_task_runner_;
InterfaceMetadataObserver* metadata_observer_ = nullptr; InterfaceMetadataObserver* metadata_observer_ = nullptr;
mojo::AssociatedBinding<mojom::EngineFileRequests> binding_; mojo::AssociatedReceiver<mojom::EngineFileRequests> receiver_{this};
}; };
} // namespace chrome_cleaner } // namespace chrome_cleaner
......
...@@ -20,8 +20,6 @@ namespace chrome_cleaner { ...@@ -20,8 +20,6 @@ namespace chrome_cleaner {
using mojom::CleanerEngineRequestsAssociatedPtr; using mojom::CleanerEngineRequestsAssociatedPtr;
using mojom::CleanerEngineRequestsAssociatedPtrInfo; using mojom::CleanerEngineRequestsAssociatedPtrInfo;
using mojom::EngineFileRequestsAssociatedPtr;
using mojom::EngineFileRequestsAssociatedPtrInfo;
using mojom::EngineRequestsAssociatedPtr; using mojom::EngineRequestsAssociatedPtr;
using mojom::EngineRequestsAssociatedPtrInfo; using mojom::EngineRequestsAssociatedPtrInfo;
...@@ -62,17 +60,15 @@ EngineCommandsImpl::EngineCommandsImpl( ...@@ -62,17 +60,15 @@ EngineCommandsImpl::EngineCommandsImpl(
EngineCommandsImpl::~EngineCommandsImpl() = default; EngineCommandsImpl::~EngineCommandsImpl() = default;
void EngineCommandsImpl::Initialize( void EngineCommandsImpl::Initialize(
mojom::EngineFileRequestsAssociatedPtrInfo file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
const base::FilePath& log_directory_path, const base::FilePath& log_directory_path,
InitializeCallback callback) { InitializeCallback callback) {
ScopedCrashStageRecorder crash_stage(__func__); ScopedCrashStageRecorder crash_stage(__func__);
// Create proxies to pass requests to the broker process over Mojo. // Create proxies to pass requests to the broker process over Mojo.
mojom::EngineFileRequestsAssociatedPtr file_requests_ptr;
file_requests_ptr.Bind(std::move(file_requests));
scoped_refptr<EngineFileRequestsProxy> file_requests_proxy = scoped_refptr<EngineFileRequestsProxy> file_requests_proxy =
base::MakeRefCounted<EngineFileRequestsProxy>( base::MakeRefCounted<EngineFileRequestsProxy>(std::move(file_requests),
std::move(file_requests_ptr), task_runner_); task_runner_);
// This object is not retained because it outlives the callback: it's // This object is not retained because it outlives the callback: it's
// destroyed on this sequence, once the main thread returns, which should only // destroyed on this sequence, once the main thread returns, which should only
...@@ -89,18 +85,16 @@ void EngineCommandsImpl::StartScan( ...@@ -89,18 +85,16 @@ void EngineCommandsImpl::StartScan(
const std::vector<UwSId>& enabled_uws, const std::vector<UwSId>& enabled_uws,
const std::vector<UwS::TraceLocation>& enabled_trace_locations, const std::vector<UwS::TraceLocation>& enabled_trace_locations,
bool include_details, bool include_details,
mojom::EngineFileRequestsAssociatedPtrInfo file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests,
mojo::PendingAssociatedRemote<mojom::EngineScanResults> scan_results, mojo::PendingAssociatedRemote<mojom::EngineScanResults> scan_results,
StartScanCallback callback) { StartScanCallback callback) {
ScopedCrashStageRecorder crash_stage(__func__); ScopedCrashStageRecorder crash_stage(__func__);
// Create proxies to pass requests to the broker process over Mojo. // Create proxies to pass requests to the broker process over Mojo.
EngineFileRequestsAssociatedPtr file_requests_ptr;
file_requests_ptr.Bind(std::move(file_requests));
scoped_refptr<EngineFileRequestsProxy> file_requests_proxy = scoped_refptr<EngineFileRequestsProxy> file_requests_proxy =
base::MakeRefCounted<EngineFileRequestsProxy>( base::MakeRefCounted<EngineFileRequestsProxy>(std::move(file_requests),
std::move(file_requests_ptr), task_runner_); task_runner_);
EngineRequestsAssociatedPtr engine_requests_ptr; EngineRequestsAssociatedPtr engine_requests_ptr;
engine_requests_ptr.Bind(std::move(sandboxed_engine_requests)); engine_requests_ptr.Bind(std::move(sandboxed_engine_requests));
...@@ -122,7 +116,7 @@ void EngineCommandsImpl::StartScan( ...@@ -122,7 +116,7 @@ void EngineCommandsImpl::StartScan(
void EngineCommandsImpl::StartCleanup( void EngineCommandsImpl::StartCleanup(
const std::vector<UwSId>& enabled_uws, const std::vector<UwSId>& enabled_uws,
mojom::EngineFileRequestsAssociatedPtrInfo file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests,
mojom::CleanerEngineRequestsAssociatedPtrInfo mojom::CleanerEngineRequestsAssociatedPtrInfo
sandboxed_cleaner_engine_requests, sandboxed_cleaner_engine_requests,
...@@ -131,11 +125,9 @@ void EngineCommandsImpl::StartCleanup( ...@@ -131,11 +125,9 @@ void EngineCommandsImpl::StartCleanup(
ScopedCrashStageRecorder crash_stage(__func__); ScopedCrashStageRecorder crash_stage(__func__);
// Create proxies to pass requests to the broker process over Mojo. // Create proxies to pass requests to the broker process over Mojo.
EngineFileRequestsAssociatedPtr file_requests_ptr;
file_requests_ptr.Bind(std::move(file_requests));
scoped_refptr<EngineFileRequestsProxy> file_requests_proxy = scoped_refptr<EngineFileRequestsProxy> file_requests_proxy =
base::MakeRefCounted<EngineFileRequestsProxy>( base::MakeRefCounted<EngineFileRequestsProxy>(std::move(file_requests),
std::move(file_requests_ptr), task_runner_); task_runner_);
EngineRequestsAssociatedPtr engine_requests_ptr; EngineRequestsAssociatedPtr engine_requests_ptr;
engine_requests_ptr.Bind(std::move(sandboxed_engine_requests)); engine_requests_ptr.Bind(std::move(sandboxed_engine_requests));
......
...@@ -32,20 +32,21 @@ class EngineCommandsImpl : public mojom::EngineCommands { ...@@ -32,20 +32,21 @@ class EngineCommandsImpl : public mojom::EngineCommands {
// mojom::EngineCommands // mojom::EngineCommands
void Initialize(mojom::EngineFileRequestsAssociatedPtrInfo file_requests, void Initialize(
const base::FilePath& log_directory, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
InitializeCallback callback) override; const base::FilePath& log_directory,
InitializeCallback callback) override;
void StartScan( void StartScan(
const std::vector<UwSId>& enabled_uws, const std::vector<UwSId>& enabled_uws,
const std::vector<UwS::TraceLocation>& enabled_trace_locations, const std::vector<UwS::TraceLocation>& enabled_trace_locations,
bool include_details, bool include_details,
mojom::EngineFileRequestsAssociatedPtrInfo file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests,
mojo::PendingAssociatedRemote<mojom::EngineScanResults> scan_results, mojo::PendingAssociatedRemote<mojom::EngineScanResults> scan_results,
StartScanCallback callback) override; StartScanCallback callback) override;
void StartCleanup( void StartCleanup(
const std::vector<UwSId>& enabled_uws, const std::vector<UwSId>& enabled_uws,
mojom::EngineFileRequestsAssociatedPtrInfo file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests,
mojom::CleanerEngineRequestsAssociatedPtrInfo mojom::CleanerEngineRequestsAssociatedPtrInfo
sandboxed_cleaner_engine_requests, sandboxed_cleaner_engine_requests,
......
...@@ -64,10 +64,9 @@ void SaveOpenReadOnlyFileCallback(base::win::ScopedHandle* result_holder, ...@@ -64,10 +64,9 @@ void SaveOpenReadOnlyFileCallback(base::win::ScopedHandle* result_holder,
} // namespace } // namespace
EngineFileRequestsProxy::EngineFileRequestsProxy( EngineFileRequestsProxy::EngineFileRequestsProxy(
mojom::EngineFileRequestsAssociatedPtr file_requests_ptr, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: file_requests_ptr_(std::move(file_requests_ptr)), : file_requests_(std::move(file_requests)), task_runner_(task_runner) {}
task_runner_(task_runner) {}
EngineFileRequestsProxy::~EngineFileRequestsProxy() = default; EngineFileRequestsProxy::~EngineFileRequestsProxy() = default;
...@@ -144,19 +143,19 @@ base::win::ScopedHandle EngineFileRequestsProxy::OpenReadOnlyFile( ...@@ -144,19 +143,19 @@ base::win::ScopedHandle EngineFileRequestsProxy::OpenReadOnlyFile(
return handle; return handle;
} }
void EngineFileRequestsProxy::UnbindRequestsPtr() { void EngineFileRequestsProxy::UnbindRequestsRemote() {
file_requests_ptr_.reset(); file_requests_.reset();
} }
MojoCallStatus EngineFileRequestsProxy::SandboxFindFirstFile( MojoCallStatus EngineFileRequestsProxy::SandboxFindFirstFile(
const base::FilePath& path, const base::FilePath& path,
mojom::EngineFileRequests::SandboxFindFirstFileCallback result_callback) { mojom::EngineFileRequests::SandboxFindFirstFileCallback result_callback) {
if (!file_requests_ptr_.is_bound()) { if (!file_requests_.is_bound()) {
LOG(ERROR) << "SandboxFindFirstFile called without bound pointer"; LOG(ERROR) << "SandboxFindFirstFile called without bound pointer";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
file_requests_ptr_->SandboxFindFirstFile(path, std::move(result_callback)); file_requests_->SandboxFindFirstFile(path, std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -164,15 +163,15 @@ MojoCallStatus EngineFileRequestsProxy::SandboxFindFirstFile( ...@@ -164,15 +163,15 @@ MojoCallStatus EngineFileRequestsProxy::SandboxFindFirstFile(
MojoCallStatus EngineFileRequestsProxy::SandboxFindNextFile( MojoCallStatus EngineFileRequestsProxy::SandboxFindNextFile(
FindFileHandle handle, FindFileHandle handle,
mojom::EngineFileRequests::SandboxFindNextFileCallback result_callback) { mojom::EngineFileRequests::SandboxFindNextFileCallback result_callback) {
if (!file_requests_ptr_.is_bound()) { if (!file_requests_.is_bound()) {
LOG(ERROR) << "SandboxFindNextFile called without bound pointer"; LOG(ERROR) << "SandboxFindNextFile called without bound pointer";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
auto find_handle = mojom::FindHandle::New(); auto find_handle = mojom::FindHandle::New();
find_handle->find_handle = handle; find_handle->find_handle = handle;
file_requests_ptr_->SandboxFindNextFile(std::move(find_handle), file_requests_->SandboxFindNextFile(std::move(find_handle),
std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -180,15 +179,15 @@ MojoCallStatus EngineFileRequestsProxy::SandboxFindNextFile( ...@@ -180,15 +179,15 @@ MojoCallStatus EngineFileRequestsProxy::SandboxFindNextFile(
MojoCallStatus EngineFileRequestsProxy::SandboxFindClose( MojoCallStatus EngineFileRequestsProxy::SandboxFindClose(
FindFileHandle handle, FindFileHandle handle,
mojom::EngineFileRequests::SandboxFindCloseCallback result_callback) { mojom::EngineFileRequests::SandboxFindCloseCallback result_callback) {
if (!file_requests_ptr_.is_bound()) { if (!file_requests_.is_bound()) {
LOG(ERROR) << "SandboxFindClose called without bound pointer"; LOG(ERROR) << "SandboxFindClose called without bound pointer";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
auto find_handle = mojom::FindHandle::New(); auto find_handle = mojom::FindHandle::New();
find_handle->find_handle = handle; find_handle->find_handle = handle;
file_requests_ptr_->SandboxFindClose(std::move(find_handle), file_requests_->SandboxFindClose(std::move(find_handle),
std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -198,13 +197,13 @@ MojoCallStatus EngineFileRequestsProxy::SandboxOpenReadOnlyFile( ...@@ -198,13 +197,13 @@ MojoCallStatus EngineFileRequestsProxy::SandboxOpenReadOnlyFile(
uint32_t dwFlagsAndAttributes, uint32_t dwFlagsAndAttributes,
mojom::EngineFileRequests::SandboxOpenReadOnlyFileCallback mojom::EngineFileRequests::SandboxOpenReadOnlyFileCallback
result_callback) { result_callback) {
if (!file_requests_ptr_.is_bound()) { if (!file_requests_.is_bound()) {
LOG(ERROR) << "SandboxOpenReadOnlyFile called without bound pointer"; LOG(ERROR) << "SandboxOpenReadOnlyFile called without bound pointer";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
file_requests_ptr_->SandboxOpenReadOnlyFile(path, dwFlagsAndAttributes, file_requests_->SandboxOpenReadOnlyFile(path, dwFlagsAndAttributes,
std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
#include "chrome/chrome_cleaner/engines/target/sandbox_request_helper.h" #include "chrome/chrome_cleaner/engines/target/sandbox_request_helper.h"
#include "chrome/chrome_cleaner/mojom/engine_file_requests.mojom.h" #include "chrome/chrome_cleaner/mojom/engine_file_requests.mojom.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
namespace chrome_cleaner { namespace chrome_cleaner {
...@@ -24,7 +26,7 @@ class EngineFileRequestsProxy ...@@ -24,7 +26,7 @@ class EngineFileRequestsProxy
: public base::RefCountedThreadSafe<EngineFileRequestsProxy> { : public base::RefCountedThreadSafe<EngineFileRequestsProxy> {
public: public:
EngineFileRequestsProxy( EngineFileRequestsProxy(
mojom::EngineFileRequestsAssociatedPtr file_requests_ptr, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
scoped_refptr<base::SingleThreadTaskRunner> task_runner); scoped_refptr<base::SingleThreadTaskRunner> task_runner);
// Implements synchronous callbacks to be called on arbitrary threads from the // Implements synchronous callbacks to be called on arbitrary threads from the
...@@ -43,7 +45,7 @@ class EngineFileRequestsProxy ...@@ -43,7 +45,7 @@ class EngineFileRequestsProxy
return task_runner_; return task_runner_;
} }
void UnbindRequestsPtr(); void UnbindRequestsRemote();
protected: protected:
virtual ~EngineFileRequestsProxy(); virtual ~EngineFileRequestsProxy();
...@@ -70,7 +72,7 @@ class EngineFileRequestsProxy ...@@ -70,7 +72,7 @@ class EngineFileRequestsProxy
// A EngineFileRequests that will send the requests over the Mojo // A EngineFileRequests that will send the requests over the Mojo
// connection. // connection.
mojom::EngineFileRequestsAssociatedPtr file_requests_ptr_; mojo::AssociatedRemote<mojom::EngineFileRequests> file_requests_;
// A task runner for the IPC thread. // A task runner for the IPC thread.
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
......
...@@ -82,7 +82,7 @@ class SandboxChildProcess::FakeEngineDelegate : public EngineDelegate { ...@@ -82,7 +82,7 @@ class SandboxChildProcess::FakeEngineDelegate : public EngineDelegate {
privileged_scan_calls_->UnbindRequestsPtr(); privileged_scan_calls_->UnbindRequestsPtr();
} }
if (privileged_file_calls_) { if (privileged_file_calls_) {
privileged_file_calls_->UnbindRequestsPtr(); privileged_file_calls_->UnbindRequestsRemote();
} }
} }
......
...@@ -85,8 +85,8 @@ class MaybeSandboxedParentProcess : public BaseClass { ...@@ -85,8 +85,8 @@ class MaybeSandboxedParentProcess : public BaseClass {
engine_commands_->Bind( engine_commands_->Bind(
mojo::PendingRemote<mojom::EngineCommands>(std::move(mojo_pipe), 0)); mojo::PendingRemote<mojom::EngineCommands>(std::move(mojo_pipe), 0));
mojom::EngineFileRequestsAssociatedPtrInfo file_requests_info; mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests;
file_requests_impl_->Bind(&file_requests_info); file_requests_impl_->Bind(&file_requests);
// Bind to empty callbacks as we don't care about the result. // Bind to empty callbacks as we don't care about the result.
mojom::EngineRequestsAssociatedPtrInfo scanner_info; mojom::EngineRequestsAssociatedPtrInfo scanner_info;
...@@ -113,7 +113,7 @@ class MaybeSandboxedParentProcess : public BaseClass { ...@@ -113,7 +113,7 @@ class MaybeSandboxedParentProcess : public BaseClass {
auto operation_started = base::BindOnce([](uint32_t unused_result_code) {}); auto operation_started = base::BindOnce([](uint32_t unused_result_code) {});
if (requests_to_setup_ == CallbacksToSetup::kFileRequests) { if (requests_to_setup_ == CallbacksToSetup::kFileRequests) {
(*engine_commands_) (*engine_commands_)
->Initialize(std::move(file_requests_info), base::FilePath(), ->Initialize(std::move(file_requests), base::FilePath(),
std::move(operation_started)); std::move(operation_started));
} else if (requests_to_setup_ == } else if (requests_to_setup_ ==
...@@ -121,14 +121,14 @@ class MaybeSandboxedParentProcess : public BaseClass { ...@@ -121,14 +121,14 @@ class MaybeSandboxedParentProcess : public BaseClass {
(*engine_commands_) (*engine_commands_)
->StartScan(/*enabled_uws=*/std::vector<UwSId>{}, ->StartScan(/*enabled_uws=*/std::vector<UwSId>{},
/*enabled_locations=*/std::vector<UwS::TraceLocation>{}, /*enabled_locations=*/std::vector<UwS::TraceLocation>{},
/*include_details=*/false, std::move(file_requests_info), /*include_details=*/false, std::move(file_requests),
std::move(scanner_info), std::move(scanner_results), std::move(scanner_info), std::move(scanner_results),
std::move(operation_started)); std::move(operation_started));
} else if (requests_to_setup_ == CallbacksToSetup::kCleanupRequests) { } else if (requests_to_setup_ == CallbacksToSetup::kCleanupRequests) {
(*engine_commands_) (*engine_commands_)
->StartCleanup(/*enabled_uws=*/std::vector<UwSId>(), ->StartCleanup(/*enabled_uws=*/std::vector<UwSId>(),
std::move(file_requests_info), std::move(scanner_info), std::move(file_requests), std::move(scanner_info),
std::move(cleaner_info), std::move(cleanup_results), std::move(cleaner_info), std::move(cleanup_results),
std::move(operation_started)); std::move(operation_started));
} }
......
...@@ -35,7 +35,7 @@ interface EngineCleanupResults { ...@@ -35,7 +35,7 @@ interface EngineCleanupResults {
// target process. // target process.
interface EngineCommands { interface EngineCommands {
// Runs the engine's initialization routine. // Runs the engine's initialization routine.
Initialize(associated EngineFileRequests file_requests, Initialize(pending_associated_remote<EngineFileRequests> file_requests,
FilePath log_directory) => (uint32 result_code); FilePath log_directory) => (uint32 result_code);
// Starts scanning the user's system. // Starts scanning the user's system.
...@@ -56,7 +56,7 @@ interface EngineCommands { ...@@ -56,7 +56,7 @@ interface EngineCommands {
array<uint32> enabled_uws, array<uint32> enabled_uws,
array<TraceLocation> enabled_trace_locations, array<TraceLocation> enabled_trace_locations,
bool include_details, bool include_details,
associated EngineFileRequests file_requests, pending_associated_remote<EngineFileRequests> file_requests,
associated EngineRequests sandboxed_engine_requests, associated EngineRequests sandboxed_engine_requests,
pending_associated_remote<EngineScanResults> results) => pending_associated_remote<EngineScanResults> results) =>
(uint32 result_code); (uint32 result_code);
...@@ -70,7 +70,7 @@ interface EngineCommands { ...@@ -70,7 +70,7 @@ interface EngineCommands {
// interface. // interface.
StartCleanup( StartCleanup(
array<uint32> enabled_uws, array<uint32> enabled_uws,
associated EngineFileRequests file_requests, pending_associated_remote<EngineFileRequests> file_requests,
associated EngineRequests sandboxed_engine_requests, associated EngineRequests sandboxed_engine_requests,
associated CleanerEngineRequests sandboxed_cleaner_engine_requests, associated CleanerEngineRequests sandboxed_cleaner_engine_requests,
pending_associated_remote<EngineCleanupResults> results) => pending_associated_remote<EngineCleanupResults> results) =>
......
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