Commit 2bf6c6a2 authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Migrate engine_requests.mojom to the new Mojo types

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

Bug: 955171
Change-Id: I32b6bc3f8d1e1f7c55f688c8dca5df85b9097472
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855980
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJoe Mason <joenotcharles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711526}
parent 5f161562
...@@ -349,8 +349,8 @@ void EngineClient::StartScanAsync( ...@@ -349,8 +349,8 @@ void EngineClient::StartScanAsync(
mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests; mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests;
sandbox_file_requests_->Bind(&file_requests); sandbox_file_requests_->Bind(&file_requests);
mojom::EngineRequestsAssociatedPtrInfo engine_requests_info; mojo::PendingAssociatedRemote<mojom::EngineRequests> engine_requests;
sandbox_requests_->Bind(&engine_requests_info); sandbox_requests_->Bind(&engine_requests);
// Create a receiver 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|.
...@@ -368,7 +368,7 @@ void EngineClient::StartScanAsync( ...@@ -368,7 +368,7 @@ 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), std::move(engine_requests_info), std::move(file_requests), std::move(engine_requests),
std::move(scan_results), std::move(scan_results),
CallbackWithErrorHandling(std::move(result_callback))); CallbackWithErrorHandling(std::move(result_callback)));
} }
...@@ -411,8 +411,8 @@ void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws, ...@@ -411,8 +411,8 @@ void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws,
mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests; mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests;
sandbox_file_requests_->Bind(&file_requests); sandbox_file_requests_->Bind(&file_requests);
mojom::EngineRequestsAssociatedPtrInfo engine_requests_info; mojo::PendingAssociatedRemote<mojom::EngineRequests> engine_requests;
sandbox_requests_->Bind(&engine_requests_info); sandbox_requests_->Bind(&engine_requests);
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);
...@@ -427,11 +427,10 @@ void EngineClient::StartCleanupAsync(const std::vector<UwSId>& enabled_uws, ...@@ -427,11 +427,10 @@ 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), ->StartCleanup(
std::move(engine_requests_info), enabled_uws, std::move(file_requests), std::move(engine_requests),
std::move(cleaner_engine_requests_info), std::move(cleaner_engine_requests_info), std::move(cleanup_results),
std::move(cleanup_results), CallbackWithErrorHandling(std::move(result_callback)));
CallbackWithErrorHandling(std::move(result_callback)));
} }
uint32_t EngineClient::Finalize() { uint32_t EngineClient::Finalize() {
......
...@@ -64,18 +64,17 @@ EngineRequestsImpl::EngineRequestsImpl( ...@@ -64,18 +64,17 @@ EngineRequestsImpl::EngineRequestsImpl(
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) {}
EngineRequestsImpl::~EngineRequestsImpl() = default; EngineRequestsImpl::~EngineRequestsImpl() = default;
void EngineRequestsImpl::Bind( void EngineRequestsImpl::Bind(
mojom::EngineRequestsAssociatedPtrInfo* ptr_info) { mojo::PendingAssociatedRemote<mojom::EngineRequests>* remote) {
if (binding_.is_bound()) if (receiver_.is_bound())
binding_.Unbind(); receiver_.reset();
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.
} }
......
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
#include "base/process/process_handle.h" #include "base/process/process_handle.h"
#include "base/strings/string16.h" #include "base/strings/string16.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_requests.mojom.h"
#include "chrome/chrome_cleaner/ipc/mojo_task_runner.h" #include "chrome/chrome_cleaner/ipc/mojo_task_runner.h"
#include "chrome/chrome_cleaner/mojom/engine_requests.mojom.h"
#include "chrome/chrome_cleaner/strings/string16_embedded_nulls.h" #include "chrome/chrome_cleaner/strings/string16_embedded_nulls.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
namespace chrome_cleaner { namespace chrome_cleaner {
...@@ -23,7 +24,7 @@ class EngineRequestsImpl : public mojom::EngineRequests { ...@@ -23,7 +24,7 @@ class EngineRequestsImpl : public mojom::EngineRequests {
InterfaceMetadataObserver* metadata_observer = nullptr); InterfaceMetadataObserver* metadata_observer = nullptr);
~EngineRequestsImpl() override; ~EngineRequestsImpl() override;
void Bind(mojom::EngineRequestsAssociatedPtrInfo* ptr_info); void Bind(mojo::PendingAssociatedRemote<mojom::EngineRequests>* remote);
// mojom::EngineRequests // mojom::EngineRequests
void SandboxGetFileAttributes( void SandboxGetFileAttributes(
...@@ -87,7 +88,7 @@ class EngineRequestsImpl : public mojom::EngineRequests { ...@@ -87,7 +88,7 @@ class EngineRequestsImpl : public mojom::EngineRequests {
scoped_refptr<MojoTaskRunner> mojo_task_runner_; scoped_refptr<MojoTaskRunner> mojo_task_runner_;
InterfaceMetadataObserver* metadata_observer_ = nullptr; InterfaceMetadataObserver* metadata_observer_ = nullptr;
mojo::AssociatedBinding<mojom::EngineRequests> binding_; mojo::AssociatedReceiver<mojom::EngineRequests> 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::EngineRequestsAssociatedPtr;
using mojom::EngineRequestsAssociatedPtrInfo;
namespace { namespace {
...@@ -86,7 +84,8 @@ void EngineCommandsImpl::StartScan( ...@@ -86,7 +84,8 @@ void EngineCommandsImpl::StartScan(
const std::vector<UwS::TraceLocation>& enabled_trace_locations, const std::vector<UwS::TraceLocation>& enabled_trace_locations,
bool include_details, bool include_details,
mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojo::PendingAssociatedRemote<mojom::EngineRequests>
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__);
...@@ -96,11 +95,9 @@ void EngineCommandsImpl::StartScan( ...@@ -96,11 +95,9 @@ void EngineCommandsImpl::StartScan(
base::MakeRefCounted<EngineFileRequestsProxy>(std::move(file_requests), base::MakeRefCounted<EngineFileRequestsProxy>(std::move(file_requests),
task_runner_); task_runner_);
EngineRequestsAssociatedPtr engine_requests_ptr;
engine_requests_ptr.Bind(std::move(sandboxed_engine_requests));
scoped_refptr<EngineRequestsProxy> engine_requests_proxy = scoped_refptr<EngineRequestsProxy> engine_requests_proxy =
base::MakeRefCounted<EngineRequestsProxy>(std::move(engine_requests_ptr), base::MakeRefCounted<EngineRequestsProxy>(
task_runner_); std::move(sandboxed_engine_requests), task_runner_);
// Create an EngineScanResults proxy to send results back over the // Create an EngineScanResults proxy to send results back over the
// Mojo connection. // Mojo connection.
...@@ -117,7 +114,8 @@ void EngineCommandsImpl::StartScan( ...@@ -117,7 +114,8 @@ void EngineCommandsImpl::StartScan(
void EngineCommandsImpl::StartCleanup( void EngineCommandsImpl::StartCleanup(
const std::vector<UwSId>& enabled_uws, const std::vector<UwSId>& enabled_uws,
mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojo::PendingAssociatedRemote<mojom::EngineRequests>
sandboxed_engine_requests,
mojom::CleanerEngineRequestsAssociatedPtrInfo mojom::CleanerEngineRequestsAssociatedPtrInfo
sandboxed_cleaner_engine_requests, sandboxed_cleaner_engine_requests,
mojo::PendingAssociatedRemote<mojom::EngineCleanupResults> cleanup_results, mojo::PendingAssociatedRemote<mojom::EngineCleanupResults> cleanup_results,
...@@ -129,11 +127,9 @@ void EngineCommandsImpl::StartCleanup( ...@@ -129,11 +127,9 @@ void EngineCommandsImpl::StartCleanup(
base::MakeRefCounted<EngineFileRequestsProxy>(std::move(file_requests), base::MakeRefCounted<EngineFileRequestsProxy>(std::move(file_requests),
task_runner_); task_runner_);
EngineRequestsAssociatedPtr engine_requests_ptr;
engine_requests_ptr.Bind(std::move(sandboxed_engine_requests));
scoped_refptr<EngineRequestsProxy> engine_requests_proxy = scoped_refptr<EngineRequestsProxy> engine_requests_proxy =
base::MakeRefCounted<EngineRequestsProxy>(std::move(engine_requests_ptr), base::MakeRefCounted<EngineRequestsProxy>(
task_runner_); std::move(sandboxed_engine_requests), task_runner_);
CleanerEngineRequestsAssociatedPtr cleaner_engine_requests_ptr; CleanerEngineRequestsAssociatedPtr cleaner_engine_requests_ptr;
cleaner_engine_requests_ptr.Bind( cleaner_engine_requests_ptr.Bind(
......
...@@ -41,13 +41,15 @@ class EngineCommandsImpl : public mojom::EngineCommands { ...@@ -41,13 +41,15 @@ class EngineCommandsImpl : public mojom::EngineCommands {
const std::vector<UwS::TraceLocation>& enabled_trace_locations, const std::vector<UwS::TraceLocation>& enabled_trace_locations,
bool include_details, bool include_details,
mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojo::PendingAssociatedRemote<mojom::EngineRequests>
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,
mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests, mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests,
mojom::EngineRequestsAssociatedPtrInfo sandboxed_engine_requests, mojo::PendingAssociatedRemote<mojom::EngineRequests>
sandboxed_engine_requests,
mojom::CleanerEngineRequestsAssociatedPtrInfo mojom::CleanerEngineRequestsAssociatedPtrInfo
sandboxed_cleaner_engine_requests, sandboxed_cleaner_engine_requests,
mojo::PendingAssociatedRemote<mojom::EngineCleanupResults> mojo::PendingAssociatedRemote<mojom::EngineCleanupResults>
......
...@@ -93,13 +93,12 @@ void SaveUserInformationCallback(bool* out_success, ...@@ -93,13 +93,12 @@ void SaveUserInformationCallback(bool* out_success,
} // namespace } // namespace
EngineRequestsProxy::EngineRequestsProxy( EngineRequestsProxy::EngineRequestsProxy(
mojom::EngineRequestsAssociatedPtr engine_requests_ptr, mojo::PendingAssociatedRemote<mojom::EngineRequests> engine_requests,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: engine_requests_ptr_(std::move(engine_requests_ptr)), : engine_requests_(std::move(engine_requests)), task_runner_(task_runner) {}
task_runner_(task_runner) {}
void EngineRequestsProxy::UnbindRequestsPtr() { void EngineRequestsProxy::UnbindRequestsRemote() {
engine_requests_ptr_.reset(); engine_requests_.reset();
} }
uint32_t EngineRequestsProxy::GetFileAttributes(const base::FilePath& file_path, uint32_t EngineRequestsProxy::GetFileAttributes(const base::FilePath& file_path,
...@@ -300,50 +299,50 @@ EngineRequestsProxy::~EngineRequestsProxy() = default; ...@@ -300,50 +299,50 @@ EngineRequestsProxy::~EngineRequestsProxy() = default;
MojoCallStatus EngineRequestsProxy::SandboxGetFileAttributes( MojoCallStatus EngineRequestsProxy::SandboxGetFileAttributes(
const base::FilePath& file_path, const base::FilePath& file_path,
mojom::EngineRequests::SandboxGetFileAttributesCallback result_callback) { mojom::EngineRequests::SandboxGetFileAttributesCallback result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetFileAttributes called without bound pointer"; LOG(ERROR) << "SandboxGetFileAttributes called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxGetFileAttributes(file_path, engine_requests_->SandboxGetFileAttributes(file_path,
std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
MojoCallStatus EngineRequestsProxy::SandboxGetKnownFolderPath( MojoCallStatus EngineRequestsProxy::SandboxGetKnownFolderPath(
mojom::KnownFolder folder_id, mojom::KnownFolder folder_id,
mojom::EngineRequests::SandboxGetKnownFolderPathCallback result_callback) { mojom::EngineRequests::SandboxGetKnownFolderPathCallback result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetKnownFolderPath called without bound pointer"; LOG(ERROR) << "SandboxGetKnownFolderPath called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxGetKnownFolderPath(folder_id, engine_requests_->SandboxGetKnownFolderPath(folder_id,
std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
MojoCallStatus EngineRequestsProxy::SandboxGetProcesses( MojoCallStatus EngineRequestsProxy::SandboxGetProcesses(
mojom::EngineRequests::SandboxGetProcessesCallback result_callback) { mojom::EngineRequests::SandboxGetProcessesCallback result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetProcesses called without bound pointer"; LOG(ERROR) << "SandboxGetProcesses called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxGetProcesses(std::move(result_callback)); engine_requests_->SandboxGetProcesses(std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
MojoCallStatus EngineRequestsProxy::SandboxGetTasks( MojoCallStatus EngineRequestsProxy::SandboxGetTasks(
mojom::EngineRequests::SandboxGetTasksCallback result_callback) { mojom::EngineRequests::SandboxGetTasksCallback result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetTasks called without bound pointer"; LOG(ERROR) << "SandboxGetTasks called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxGetTasks(std::move(result_callback)); engine_requests_->SandboxGetTasks(std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -351,13 +350,12 @@ MojoCallStatus EngineRequestsProxy::SandboxGetTasks( ...@@ -351,13 +350,12 @@ MojoCallStatus EngineRequestsProxy::SandboxGetTasks(
MojoCallStatus EngineRequestsProxy::SandboxGetProcessImagePath( MojoCallStatus EngineRequestsProxy::SandboxGetProcessImagePath(
base::ProcessId pid, base::ProcessId pid,
mojom::EngineRequests::SandboxGetProcessImagePathCallback result_callback) { mojom::EngineRequests::SandboxGetProcessImagePathCallback result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetProcessImagePath called without bound pointer"; LOG(ERROR) << "SandboxGetProcessImagePath called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxGetProcessImagePath(pid, engine_requests_->SandboxGetProcessImagePath(pid, std::move(result_callback));
std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -365,13 +363,12 @@ MojoCallStatus EngineRequestsProxy::SandboxGetProcessImagePath( ...@@ -365,13 +363,12 @@ MojoCallStatus EngineRequestsProxy::SandboxGetProcessImagePath(
MojoCallStatus EngineRequestsProxy::SandboxGetLoadedModules( MojoCallStatus EngineRequestsProxy::SandboxGetLoadedModules(
base::ProcessId pid, base::ProcessId pid,
mojom::EngineRequests::SandboxGetLoadedModulesCallback result_callback) { mojom::EngineRequests::SandboxGetLoadedModulesCallback result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetLoadedModules called without bound pointer"; LOG(ERROR) << "SandboxGetLoadedModules called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxGetLoadedModules(pid, engine_requests_->SandboxGetLoadedModules(pid, std::move(result_callback));
std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -380,13 +377,13 @@ MojoCallStatus EngineRequestsProxy::SandboxGetProcessCommandLine( ...@@ -380,13 +377,13 @@ MojoCallStatus EngineRequestsProxy::SandboxGetProcessCommandLine(
base::ProcessId pid, base::ProcessId pid,
mojom::EngineRequestsProxy::SandboxGetProcessCommandLineCallback mojom::EngineRequestsProxy::SandboxGetProcessCommandLineCallback
result_callback) { result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetProcessCommandLine called without bound pointer"; LOG(ERROR) << "SandboxGetProcessCommandLine called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxGetProcessCommandLine( engine_requests_->SandboxGetProcessCommandLine(pid,
pid, std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -394,8 +391,8 @@ MojoCallStatus EngineRequestsProxy::SandboxGetProcessCommandLine( ...@@ -394,8 +391,8 @@ MojoCallStatus EngineRequestsProxy::SandboxGetProcessCommandLine(
MojoCallStatus EngineRequestsProxy::SandboxGetUserInfoFromSID( MojoCallStatus EngineRequestsProxy::SandboxGetUserInfoFromSID(
const SID* const sid, const SID* const sid,
mojom::EngineRequests::SandboxGetUserInfoFromSIDCallback result_callback) { mojom::EngineRequests::SandboxGetUserInfoFromSIDCallback result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxGetUserInfoFromSID called without bound pointer"; LOG(ERROR) << "SandboxGetUserInfoFromSID called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
...@@ -408,8 +405,8 @@ MojoCallStatus EngineRequestsProxy::SandboxGetUserInfoFromSID( ...@@ -408,8 +405,8 @@ MojoCallStatus EngineRequestsProxy::SandboxGetUserInfoFromSID(
auto mojom_string_sid = mojom::StringSid::New(sid_buffer); auto mojom_string_sid = mojom::StringSid::New(sid_buffer);
LocalFree(sid_buffer); LocalFree(sid_buffer);
engine_requests_ptr_->SandboxGetUserInfoFromSID(std::move(mojom_string_sid), engine_requests_->SandboxGetUserInfoFromSID(std::move(mojom_string_sid),
std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -420,13 +417,13 @@ MojoCallStatus EngineRequestsProxy::SandboxOpenReadOnlyRegistry( ...@@ -420,13 +417,13 @@ MojoCallStatus EngineRequestsProxy::SandboxOpenReadOnlyRegistry(
uint32_t dw_access, uint32_t dw_access,
mojom::EngineRequests::SandboxOpenReadOnlyRegistryCallback mojom::EngineRequests::SandboxOpenReadOnlyRegistryCallback
result_callback) { result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxOpenReadOnlyRegistry called without bound pointer"; LOG(ERROR) << "SandboxOpenReadOnlyRegistry called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxOpenReadOnlyRegistry( engine_requests_->SandboxOpenReadOnlyRegistry(root_key, sub_key, dw_access,
root_key, sub_key, dw_access, std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
...@@ -436,13 +433,13 @@ MojoCallStatus EngineRequestsProxy::SandboxNtOpenReadOnlyRegistry( ...@@ -436,13 +433,13 @@ MojoCallStatus EngineRequestsProxy::SandboxNtOpenReadOnlyRegistry(
uint32_t dw_access, uint32_t dw_access,
mojom::EngineRequests::SandboxNtOpenReadOnlyRegistryCallback mojom::EngineRequests::SandboxNtOpenReadOnlyRegistryCallback
result_callback) { result_callback) {
if (!engine_requests_ptr_.is_bound()) { if (!engine_requests_.is_bound()) {
LOG(ERROR) << "SandboxNtOpenReadOnlyRegistry called without bound pointer"; LOG(ERROR) << "SandboxNtOpenReadOnlyRegistry called without bound remote";
return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR); return MojoCallStatus::Failure(SandboxErrorCode::INTERNAL_ERROR);
} }
engine_requests_ptr_->SandboxNtOpenReadOnlyRegistry( engine_requests_->SandboxNtOpenReadOnlyRegistry(root_key, sub_key, dw_access,
root_key, sub_key, dw_access, std::move(result_callback)); std::move(result_callback));
return MojoCallStatus::Success(); return MojoCallStatus::Success();
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#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_requests.mojom.h" #include "chrome/chrome_cleaner/mojom/engine_requests.mojom.h"
#include "chrome/chrome_cleaner/os/task_scheduler.h" #include "chrome/chrome_cleaner/os/task_scheduler.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,14 +26,15 @@ namespace chrome_cleaner { ...@@ -24,14 +26,15 @@ namespace chrome_cleaner {
class EngineRequestsProxy class EngineRequestsProxy
: public base::RefCountedThreadSafe<EngineRequestsProxy> { : public base::RefCountedThreadSafe<EngineRequestsProxy> {
public: public:
EngineRequestsProxy(mojom::EngineRequestsAssociatedPtr engine_requests_ptr, EngineRequestsProxy(
scoped_refptr<base::SingleThreadTaskRunner> task_runner); mojo::PendingAssociatedRemote<mojom::EngineRequests> engine_requests,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
scoped_refptr<base::SingleThreadTaskRunner> task_runner() const { scoped_refptr<base::SingleThreadTaskRunner> task_runner() const {
return task_runner_; return task_runner_;
} }
void UnbindRequestsPtr(); void UnbindRequestsRemote();
// Implements synchronous callbacks to be called on arbitrary threads. // Implements synchronous callbacks to be called on arbitrary threads.
virtual uint32_t GetFileAttributes(const base::FilePath& file_path, virtual uint32_t GetFileAttributes(const base::FilePath& file_path,
...@@ -104,7 +107,7 @@ class EngineRequestsProxy ...@@ -104,7 +107,7 @@ class EngineRequestsProxy
// A EngineRequests that will send the requests over the Mojo // A EngineRequests that will send the requests over the Mojo
// connection. // connection.
mojom::EngineRequestsAssociatedPtr engine_requests_ptr_; mojo::AssociatedRemote<mojom::EngineRequests> engine_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_;
......
...@@ -79,7 +79,7 @@ class SandboxChildProcess::FakeEngineDelegate : public EngineDelegate { ...@@ -79,7 +79,7 @@ class SandboxChildProcess::FakeEngineDelegate : public EngineDelegate {
void UnbindRequestsPtrs() { void UnbindRequestsPtrs() {
if (privileged_scan_calls_) { if (privileged_scan_calls_) {
privileged_scan_calls_->UnbindRequestsPtr(); privileged_scan_calls_->UnbindRequestsRemote();
} }
if (privileged_file_calls_) { if (privileged_file_calls_) {
privileged_file_calls_->UnbindRequestsRemote(); privileged_file_calls_->UnbindRequestsRemote();
......
...@@ -89,11 +89,11 @@ class MaybeSandboxedParentProcess : public BaseClass { ...@@ -89,11 +89,11 @@ class MaybeSandboxedParentProcess : public BaseClass {
file_requests_impl_->Bind(&file_requests); 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; mojo::PendingAssociatedRemote<mojom::EngineRequests> scanner;
mojo::PendingAssociatedRemote<mojom::EngineScanResults> scanner_results; mojo::PendingAssociatedRemote<mojom::EngineScanResults> scanner_results;
if (requests_to_setup_ == CallbacksToSetup::kScanAndCleanupRequests || if (requests_to_setup_ == CallbacksToSetup::kScanAndCleanupRequests ||
requests_to_setup_ == CallbacksToSetup::kCleanupRequests) { requests_to_setup_ == CallbacksToSetup::kCleanupRequests) {
scanner_impl_->Bind(&scanner_info); scanner_impl_->Bind(&scanner);
scan_results_impl_->BindToCallbacks( scan_results_impl_->BindToCallbacks(
&scanner_results, &scanner_results,
base::BindRepeating( base::BindRepeating(
...@@ -122,13 +122,13 @@ class MaybeSandboxedParentProcess : public BaseClass { ...@@ -122,13 +122,13 @@ class MaybeSandboxedParentProcess : public BaseClass {
->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), /*include_details=*/false, std::move(file_requests),
std::move(scanner_info), std::move(scanner_results), std::move(scanner), 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), std::move(scanner_info), std::move(file_requests), std::move(scanner),
std::move(cleaner_info), std::move(cleanup_results), std::move(cleaner_info), std::move(cleanup_results),
std::move(operation_started)); std::move(operation_started));
} }
......
...@@ -57,7 +57,7 @@ interface EngineCommands { ...@@ -57,7 +57,7 @@ interface EngineCommands {
array<TraceLocation> enabled_trace_locations, array<TraceLocation> enabled_trace_locations,
bool include_details, bool include_details,
pending_associated_remote<EngineFileRequests> file_requests, pending_associated_remote<EngineFileRequests> file_requests,
associated EngineRequests sandboxed_engine_requests, pending_associated_remote<EngineRequests> sandboxed_engine_requests,
pending_associated_remote<EngineScanResults> results) => pending_associated_remote<EngineScanResults> results) =>
(uint32 result_code); (uint32 result_code);
...@@ -71,7 +71,7 @@ interface EngineCommands { ...@@ -71,7 +71,7 @@ interface EngineCommands {
StartCleanup( StartCleanup(
array<uint32> enabled_uws, array<uint32> enabled_uws,
pending_associated_remote<EngineFileRequests> file_requests, pending_associated_remote<EngineFileRequests> file_requests,
associated EngineRequests sandboxed_engine_requests, pending_associated_remote<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) =>
(uint32 result_code); (uint32 result_code);
......
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