Commit 3279d13e authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Migrate drivefs.mojom to the new Mojo types

Convert the implementation and all users of the
drivefs::mojom::DriveFsBootstrap, DriveFs, DriveFsDelegate and
SearchQuery interfaces.

Bug: 955171
Change-Id: I3881ee40feba2aaae7659398cd100dd90bbfd53b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847332Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#705921}
parent 342530e6
......@@ -15,10 +15,13 @@
#include "chrome/browser/chromeos/file_manager/file_tasks_observer.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom-test-utils.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "components/drive/file_errors.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/fake_download_item.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "storage/browser/fileapi/external_mount_points.h"
#include "storage/browser/fileapi/file_system_url.h"
#include "storage/common/fileapi/file_system_types.h"
......@@ -97,7 +100,8 @@ class MockFileTasksObserver : public file_tasks::FileTasksObserver {
class FileTasksNotifierForTest : public FileTasksNotifier {
public:
FileTasksNotifierForTest(Profile* profile, drivefs::mojom::DriveFsPtr drivefs)
FileTasksNotifierForTest(Profile* profile,
mojo::PendingRemote<drivefs::mojom::DriveFs> drivefs)
: FileTasksNotifier(profile), drivefs_(std::move(drivefs)) {}
drivefs::mojom::DriveFs* GetDriveFsInterface() override {
......@@ -115,21 +119,19 @@ class FileTasksNotifierForTest : public FileTasksNotifier {
void set_is_offline(bool is_offline) { is_offline_ = is_offline; }
private:
const drivefs::mojom::DriveFsPtr drivefs_;
const mojo::Remote<drivefs::mojom::DriveFs> drivefs_;
bool is_offline_ = false;
};
class FileTasksNotifierTest : public testing::Test {
protected:
FileTasksNotifierTest() : drivefs_binding_(&fake_drivefs_) {}
FileTasksNotifierTest() = default;
void SetUp() override {
profile_ = std::make_unique<TestingProfile>();
drivefs::mojom::DriveFsPtr fake_drivefs_ptr;
drivefs_binding_.Bind(mojo::MakeRequest(&fake_drivefs_ptr));
notifier_ = std::make_unique<FileTasksNotifierForTest>(
profile_.get(), std::move(fake_drivefs_ptr));
profile_.get(), drivefs_receiver_.BindNewPipeAndPassRemote());
observer_ = std::make_unique<MockFileTasksObserver>(notifier_.get());
auto* mount_points = storage::ExternalMountPoints::GetSystemInstance();
......@@ -175,7 +177,7 @@ class FileTasksNotifierTest : public testing::Test {
private:
content::BrowserTaskEnvironment task_environment_;
FakeDriveFs fake_drivefs_;
mojo::Binding<drivefs::mojom::DriveFs> drivefs_binding_;
mojo::Receiver<drivefs::mojom::DriveFs> drivefs_receiver_{&fake_drivefs_};
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<FileTasksNotifierForTest> notifier_;
std::unique_ptr<MockFileTasksObserver> observer_;
......
......@@ -65,7 +65,7 @@ void RecentDriveSource::GetRecentFiles(Params params) {
query_params->sort_direction =
drivefs::mojom::QueryParameters::SortDirection::kDescending;
integration_service->GetDriveFsInterface()->StartSearchQuery(
mojo::MakeRequest(&search_query_), std::move(query_params));
search_query_.BindNewPipeAndPassReceiver(), std::move(query_params));
search_query_->GetNextPage(base::BindOnce(
&RecentDriveSource::GotSearchResults, weak_ptr_factory_.GetWeakPtr()));
}
......
......@@ -17,6 +17,7 @@
#include "chrome/browser/chromeos/fileapi/recent_source.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "components/drive/file_errors.h"
#include "mojo/public/cpp/bindings/remote.h"
class Profile;
......@@ -55,7 +56,7 @@ class RecentDriveSource : public RecentSource {
std::vector<RecentFile> files_;
drivefs::mojom::SearchQueryPtr search_query_;
mojo::Remote<drivefs::mojom::SearchQuery> search_query_;
base::WeakPtrFactory<RecentDriveSource> weak_ptr_factory_{this};
......
......@@ -7,16 +7,18 @@
#include <utility>
#include "base/bind.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "chromeos/components/drivefs/pending_connection_manager.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "mojo/public/cpp/system/invitation.h"
namespace drivefs {
DriveFsBootstrapListener::DriveFsBootstrapListener()
: bootstrap_(mojo::MakeProxy(mojom::DriveFsBootstrapPtrInfo(
invitation_.AttachMessagePipe("drivefs-bootstrap"),
mojom::DriveFsBootstrap::Version_))),
: bootstrap_(invitation_.AttachMessagePipe("drivefs-bootstrap"),
mojom::DriveFsBootstrap::Version_),
pending_token_(base::UnguessableToken::Create()) {
PendingConnectionManager::Get().ExpectOpenIpcChannel(
pending_token_,
......@@ -32,7 +34,8 @@ DriveFsBootstrapListener::~DriveFsBootstrapListener() {
}
}
mojom::DriveFsBootstrapPtr DriveFsBootstrapListener::bootstrap() {
mojo::PendingRemote<mojom::DriveFsBootstrap>
DriveFsBootstrapListener::bootstrap() {
return std::move(bootstrap_);
}
......@@ -61,22 +64,20 @@ class DriveFsConnectionImpl : public DriveFsConnection {
base::UnguessableToken Connect(mojom::DriveFsDelegate* delegate,
base::OnceClosure on_disconnected) override {
delegate_binding_ =
std::make_unique<mojo::Binding<mojom::DriveFsDelegate>>(delegate);
delegate_receiver_ =
std::make_unique<mojo::Receiver<mojom::DriveFsDelegate>>(delegate);
on_disconnected_ = std::move(on_disconnected);
auto bootstrap = bootstrap_listener_->bootstrap();
auto bootstrap =
mojo::Remote<mojom::DriveFsBootstrap>(bootstrap_listener_->bootstrap());
auto token = bootstrap_listener_->pending_token();
mojom::DriveFsDelegatePtr delegate_ptr;
delegate_binding_->Bind(mojo::MakeRequest(&delegate_ptr));
delegate_binding_->set_connection_error_handler(base::BindOnce(
&DriveFsConnectionImpl::OnMojoConnectionError, base::Unretained(this)));
bootstrap->Init(std::move(config_), mojo::MakeRequest(&drivefs_),
std::move(delegate_ptr));
bootstrap->Init(std::move(config_), drivefs_.BindNewPipeAndPassReceiver(),
delegate_receiver_->BindNewPipeAndPassRemote());
drivefs_.set_connection_error_handler(base::BindOnce(
delegate_receiver_->set_disconnect_handler(base::BindOnce(
&DriveFsConnectionImpl::OnMojoConnectionError, base::Unretained(this)));
drivefs_.set_disconnect_handler(base::BindOnce(
&DriveFsConnectionImpl::OnMojoConnectionError, base::Unretained(this)));
return token;
......@@ -97,8 +98,8 @@ class DriveFsConnectionImpl : public DriveFsConnection {
const std::unique_ptr<DriveFsBootstrapListener> bootstrap_listener_;
mojom::DriveFsConfigurationPtr config_;
std::unique_ptr<mojo::Binding<mojom::DriveFsDelegate>> delegate_binding_;
mojom::DriveFsPtr drivefs_;
std::unique_ptr<mojo::Receiver<mojom::DriveFsDelegate>> delegate_receiver_;
mojo::Remote<mojom::DriveFs> drivefs_;
base::OnceClosure on_disconnected_;
......
......@@ -12,7 +12,7 @@
#include "base/macros.h"
#include "base/unguessable_token.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/system/invitation.h"
namespace drivefs {
......@@ -24,7 +24,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsBootstrapListener {
virtual ~DriveFsBootstrapListener();
const base::UnguessableToken& pending_token() const { return pending_token_; }
virtual mojom::DriveFsBootstrapPtr bootstrap();
virtual mojo::PendingRemote<mojom::DriveFsBootstrap> bootstrap();
bool is_connected() const { return connected_; }
protected:
......@@ -35,7 +35,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsBootstrapListener {
void AcceptMojoConnection(base::ScopedFD handle);
mojo::OutgoingInvitation invitation_;
mojom::DriveFsBootstrapPtr bootstrap_;
mojo::PendingRemote<mojom::DriveFsBootstrap> bootstrap_;
// The token passed to DriveFS as part of 'source path' used to match it to
// this instance.
......
......@@ -5,12 +5,18 @@
#include "chromeos/components/drivefs/drivefs_bootstrap.h"
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom-test-utils.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "chromeos/components/drivefs/pending_connection_manager.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -38,17 +44,17 @@ class MockDriveFsDelegate : public mojom::DriveFsDelegateInterceptorForTesting {
class DriveFsBootstrapListenerForTest : public DriveFsBootstrapListener {
public:
DriveFsBootstrapListenerForTest(
mojom::DriveFsBootstrapPtrInfo available_bootstrap)
mojo::PendingRemote<mojom::DriveFsBootstrap> available_bootstrap)
: available_bootstrap_(std::move(available_bootstrap)) {}
mojom::DriveFsBootstrapPtr bootstrap() override {
return mojo::MakeProxy(std::move(available_bootstrap_));
mojo::PendingRemote<mojom::DriveFsBootstrap> bootstrap() override {
return std::move(available_bootstrap_);
}
void SendInvitationOverPipe(base::ScopedFD) override {}
private:
mojom::DriveFsBootstrapPtrInfo available_bootstrap_;
mojo::PendingRemote<mojom::DriveFsBootstrap> available_bootstrap_;
DISALLOW_COPY_AND_ASSIGN(DriveFsBootstrapListenerForTest);
};
......@@ -56,27 +62,24 @@ class DriveFsBootstrapListenerForTest : public DriveFsBootstrapListener {
class DriveFsBootstrapTest : public testing::Test,
public mojom::DriveFsBootstrap {
public:
DriveFsBootstrapTest() : bootstrap_binding_(this), binding_(&mock_drivefs_) {}
DriveFsBootstrapTest() = default;
protected:
MOCK_CONST_METHOD0(OnDisconnect, void());
MOCK_CONST_METHOD0(OnInit, void());
void Init(mojom::DriveFsConfigurationPtr config,
mojom::DriveFsRequest drive_fs_request,
mojom::DriveFsDelegatePtr delegate) override {
binding_.Bind(std::move(drive_fs_request));
mojo::FuseInterface(std::move(pending_delegate_request_),
delegate.PassInterface());
mojo::PendingReceiver<mojom::DriveFs> drive_fs_receiver,
mojo::PendingRemote<mojom::DriveFsDelegate> delegate) override {
receiver_.Bind(std::move(drive_fs_receiver));
mojo::FusePipes(std::move(pending_delegate_receiver_), std::move(delegate));
OnInit();
}
std::unique_ptr<DriveFsBootstrapListener> CreateListener() {
mojom::DriveFsBootstrapPtrInfo pending_bootstrap;
bootstrap_binding_.Bind(mojo::MakeRequest(&pending_bootstrap));
pending_delegate_request_ = mojo::MakeRequest(&delegate_ptr_);
pending_delegate_receiver_ = delegate_.BindNewPipeAndPassReceiver();
return std::make_unique<DriveFsBootstrapListenerForTest>(
std::move(pending_bootstrap));
bootstrap_receiver_.BindNewPipeAndPassRemote());
}
base::UnguessableToken ListenForConnection() {
......@@ -91,7 +94,7 @@ class DriveFsBootstrapTest : public testing::Test,
ASSERT_TRUE(
PendingConnectionManager::Get().OpenIpcChannel(token.ToString(), {}));
base::RunLoop run_loop;
bootstrap_binding_.set_connection_error_handler(run_loop.QuitClosure());
bootstrap_receiver_.set_disconnect_handler(run_loop.QuitClosure());
run_loop.Run();
}
......@@ -99,11 +102,11 @@ class DriveFsBootstrapTest : public testing::Test,
MockDriveFs mock_drivefs_;
MockDriveFsDelegate mock_delegate_;
mojo::Binding<mojom::DriveFsBootstrap> bootstrap_binding_;
mojo::Binding<mojom::DriveFs> binding_;
mojo::Receiver<mojom::DriveFsBootstrap> bootstrap_receiver_{this};
mojo::Receiver<mojom::DriveFs> receiver_{&mock_drivefs_};
std::unique_ptr<DriveFsConnection> connection_;
mojom::DriveFsDelegatePtr delegate_ptr_;
mojom::DriveFsDelegateRequest pending_delegate_request_;
mojo::Remote<mojom::DriveFsDelegate> delegate_;
mojo::PendingReceiver<mojom::DriveFsDelegate> pending_delegate_receiver_;
std::string email_;
DISALLOW_COPY_AND_ASSIGN(DriveFsBootstrapTest);
......@@ -116,7 +119,7 @@ TEST_F(DriveFsBootstrapTest, Listen_Connect_Disconnect) {
EXPECT_CALL(*this, OnInit());
WaitForConnection(token);
EXPECT_CALL(*this, OnDisconnect());
binding_.Close();
receiver_.reset();
base::RunLoop().RunUntilIdle();
ASSERT_FALSE(
PendingConnectionManager::Get().OpenIpcChannel(token.ToString(), {}));
......@@ -127,7 +130,7 @@ TEST_F(DriveFsBootstrapTest, Listen_Connect_DisconnectDelegate) {
EXPECT_CALL(*this, OnInit());
WaitForConnection(token);
EXPECT_CALL(*this, OnDisconnect());
delegate_ptr_.reset();
delegate_.reset();
base::RunLoop().RunUntilIdle();
ASSERT_FALSE(
PendingConnectionManager::Get().OpenIpcChannel(token.ToString(), {}));
......@@ -156,7 +159,7 @@ TEST_F(DriveFsBootstrapTest, Listen_Destroy) {
TEST_F(DriveFsBootstrapTest, Listen_DisconnectDelegate) {
EXPECT_CALL(*this, OnDisconnect()).Times(0);
ListenForConnection();
delegate_ptr_.reset();
delegate_.reset();
base::RunLoop().RunUntilIdle();
}
......
......@@ -4,7 +4,11 @@
#include "chromeos/components/drivefs/drivefs_search.h"
#include <utility>
#include "base/bind.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/cpp/network_connection_tracker.h"
namespace drivefs {
......@@ -44,7 +48,7 @@ mojom::QueryParameters::QuerySource DriveFsSearch::PerformSearch(
}
}
drivefs::mojom::SearchQueryPtr search;
mojo::Remote<drivefs::mojom::SearchQuery> search;
drivefs::mojom::QueryParameters::QuerySource source = query->query_source;
if (network_connection_tracker_->IsOffline() &&
source != drivefs::mojom::QueryParameters::QuerySource::kLocalOnly) {
......@@ -53,7 +57,8 @@ mojom::QueryParameters::QuerySource DriveFsSearch::PerformSearch(
OnSearchDriveFs(std::move(search), std::move(query), std::move(callback),
drive::FILE_ERROR_NO_CONNECTION, {});
} else {
drivefs_->StartSearchQuery(mojo::MakeRequest(&search), query.Clone());
drivefs_->StartSearchQuery(search.BindNewPipeAndPassReceiver(),
query.Clone());
auto* raw_search = search.get();
raw_search->GetNextPage(base::BindOnce(
&DriveFsSearch::OnSearchDriveFs, weak_ptr_factory_.GetWeakPtr(),
......@@ -63,7 +68,7 @@ mojom::QueryParameters::QuerySource DriveFsSearch::PerformSearch(
}
void DriveFsSearch::OnSearchDriveFs(
drivefs::mojom::SearchQueryPtr search,
mojo::Remote<drivefs::mojom::SearchQuery> search,
drivefs::mojom::QueryParametersPtr query,
mojom::SearchQuery::GetNextPageCallback callback,
drive::FileError error,
......
......@@ -14,6 +14,7 @@
#include "base/memory/weak_ptr.h"
#include "base/time/clock.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace network {
class NetworkConnectionTracker;
......@@ -37,7 +38,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsSearch {
private:
void OnSearchDriveFs(
drivefs::mojom::SearchQueryPtr search,
mojo::Remote<drivefs::mojom::SearchQuery> search,
drivefs::mojom::QueryParametersPtr query,
mojom::SearchQuery::GetNextPageCallback callback,
drive::FileError error,
......
......@@ -4,12 +4,16 @@
#include "chromeos/components/drivefs/drivefs_search.h"
#include <utility>
#include "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom-test-utils.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/network/test/test_network_connection_tracker.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -22,7 +26,7 @@ using testing::_;
class MockDriveFs : public mojom::DriveFsInterceptorForTesting,
public mojom::SearchQuery {
public:
MockDriveFs() : search_binding_(this) {}
MockDriveFs() = default;
DriveFs* GetForwardingInterface() override {
NOTREACHED();
......@@ -30,12 +34,11 @@ class MockDriveFs : public mojom::DriveFsInterceptorForTesting,
}
MOCK_CONST_METHOD1(OnStartSearchQuery, void(const mojom::QueryParameters&));
void StartSearchQuery(mojom::SearchQueryRequest query,
void StartSearchQuery(mojo::PendingReceiver<mojom::SearchQuery> receiver,
mojom::QueryParametersPtr query_params) override {
if (search_binding_.is_bound())
search_binding_.Unbind();
search_receiver_.reset();
OnStartSearchQuery(*query_params);
search_binding_.Bind(std::move(query));
search_receiver_.Bind(std::move(receiver));
}
MOCK_METHOD1(OnGetNextPage,
......@@ -49,7 +52,7 @@ class MockDriveFs : public mojom::DriveFsInterceptorForTesting,
}
private:
mojo::Binding<mojom::SearchQuery> search_binding_;
mojo::Receiver<mojom::SearchQuery> search_receiver_{this};
DISALLOW_COPY_AND_ASSIGN(MockDriveFs);
};
......
......@@ -20,9 +20,12 @@
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "chromeos/components/drivefs/drivefs_util.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_cros_disks_client.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace drivefs {
namespace {
......@@ -70,15 +73,16 @@ base::FilePath MaybeMountDriveFs(
} // namespace
FakeDriveFsBootstrapListener::FakeDriveFsBootstrapListener(
drivefs::mojom::DriveFsBootstrapPtrInfo bootstrap)
mojo::PendingRemote<drivefs::mojom::DriveFsBootstrap> bootstrap)
: bootstrap_(std::move(bootstrap)) {}
FakeDriveFsBootstrapListener::~FakeDriveFsBootstrapListener() = default;
void FakeDriveFsBootstrapListener::SendInvitationOverPipe(base::ScopedFD) {}
mojom::DriveFsBootstrapPtr FakeDriveFsBootstrapListener::bootstrap() {
return mojo::MakeProxy(std::move(bootstrap_));
mojo::PendingRemote<mojom::DriveFsBootstrap>
FakeDriveFsBootstrapListener::bootstrap() {
return std::move(bootstrap_);
}
struct FakeDriveFs::FileMetadata {
......@@ -227,7 +231,7 @@ class FakeDriveFs::SearchQuery : public mojom::SearchQuery {
};
FakeDriveFs::FakeDriveFs(const base::FilePath& mount_path)
: mount_path_(mount_path), binding_(this), bootstrap_binding_(this) {
: mount_path_(mount_path) {
CHECK(mount_path.IsAbsolute());
CHECK(!mount_path.ReferencesParent());
}
......@@ -248,13 +252,13 @@ void FakeDriveFs::RegisterMountingForAccountId(
std::unique_ptr<drivefs::DriveFsBootstrapListener>
FakeDriveFs::CreateMojoListener() {
drivefs::mojom::DriveFsBootstrapPtrInfo bootstrap;
if (bootstrap_binding_.is_bound())
bootstrap_binding_.Unbind();
bootstrap_binding_.Bind(mojo::MakeRequest(&bootstrap));
pending_delegate_request_ = mojo::MakeRequest(&delegate_);
delegate_.reset();
pending_delegate_receiver_ = delegate_.BindNewPipeAndPassReceiver();
delegate_->OnMounted();
return std::make_unique<FakeDriveFsBootstrapListener>(std::move(bootstrap));
bootstrap_receiver_.reset();
return std::make_unique<FakeDriveFsBootstrapListener>(
bootstrap_receiver_.BindNewPipeAndPassRemote());
}
void FakeDriveFs::SetMetadata(const base::FilePath& path,
......@@ -278,18 +282,17 @@ void FakeDriveFs::SetMetadata(const base::FilePath& path,
}
}
void FakeDriveFs::Init(drivefs::mojom::DriveFsConfigurationPtr config,
drivefs::mojom::DriveFsRequest drive_fs_request,
drivefs::mojom::DriveFsDelegatePtr delegate) {
void FakeDriveFs::Init(
drivefs::mojom::DriveFsConfigurationPtr config,
mojo::PendingReceiver<drivefs::mojom::DriveFs> receiver,
mojo::PendingRemote<drivefs::mojom::DriveFsDelegate> delegate) {
{
base::ScopedAllowBlockingForTesting allow_io;
CHECK(base::CreateDirectory(mount_path_.Append(".Trash")));
}
mojo::FuseInterface(std::move(pending_delegate_request_),
delegate.PassInterface());
if (binding_.is_bound())
binding_.Unbind();
binding_.Bind(std::move(drive_fs_request));
mojo::FusePipes(std::move(pending_delegate_receiver_), std::move(delegate));
receiver_.reset();
receiver_.Bind(std::move(receiver));
}
void FakeDriveFs::GetMetadata(const base::FilePath& path,
......@@ -401,11 +404,11 @@ void FakeDriveFs::CopyFile(const base::FilePath& source,
}
void FakeDriveFs::StartSearchQuery(
drivefs::mojom::SearchQueryRequest query,
mojo::PendingReceiver<drivefs::mojom::SearchQuery> receiver,
drivefs::mojom::QueryParametersPtr query_params) {
auto search_query = std::make_unique<SearchQuery>(weak_factory_.GetWeakPtr(),
std::move(query_params));
mojo::MakeStrongBinding(std::move(search_query), std::move(query));
mojo::MakeSelfOwnedReceiver(std::move(search_query), std::move(receiver));
}
void FakeDriveFs::FetchAllChangeLogs() {}
......
......@@ -16,21 +16,24 @@
#include "chromeos/components/drivefs/drivefs_bootstrap.h"
#include "chromeos/components/drivefs/drivefs_host.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace drivefs {
class FakeDriveFsBootstrapListener : public DriveFsBootstrapListener {
public:
explicit FakeDriveFsBootstrapListener(
drivefs::mojom::DriveFsBootstrapPtrInfo bootstrap);
mojo::PendingRemote<drivefs::mojom::DriveFsBootstrap> bootstrap);
~FakeDriveFsBootstrapListener() override;
private:
void SendInvitationOverPipe(base::ScopedFD) override;
mojom::DriveFsBootstrapPtr bootstrap() override;
mojo::PendingRemote<mojom::DriveFsBootstrap> bootstrap() override;
drivefs::mojom::DriveFsBootstrapPtrInfo bootstrap_;
mojo::PendingRemote<drivefs::mojom::DriveFsBootstrap> bootstrap_;
DISALLOW_COPY_AND_ASSIGN(FakeDriveFsBootstrapListener);
};
......@@ -61,9 +64,10 @@ class FakeDriveFs : public drivefs::mojom::DriveFs,
class SearchQuery;
// drivefs::mojom::DriveFsBootstrap:
void Init(drivefs::mojom::DriveFsConfigurationPtr config,
drivefs::mojom::DriveFsRequest drive_fs_request,
drivefs::mojom::DriveFsDelegatePtr delegate) override;
void Init(
drivefs::mojom::DriveFsConfigurationPtr config,
mojo::PendingReceiver<drivefs::mojom::DriveFs> receiver,
mojo::PendingRemote<drivefs::mojom::DriveFsDelegate> delegate) override;
// drivefs::mojom::DriveFs:
void GetMetadata(const base::FilePath& path,
......@@ -86,7 +90,7 @@ class FakeDriveFs : public drivefs::mojom::DriveFs,
CopyFileCallback callback) override;
void StartSearchQuery(
drivefs::mojom::SearchQueryRequest query,
mojo::PendingReceiver<drivefs::mojom::SearchQuery> receiver,
drivefs::mojom::QueryParametersPtr query_params) override;
void FetchAllChangeLogs() override;
......@@ -98,10 +102,11 @@ class FakeDriveFs : public drivefs::mojom::DriveFs,
std::map<base::FilePath, FileMetadata> metadata_;
mojo::Binding<drivefs::mojom::DriveFs> binding_;
drivefs::mojom::DriveFsDelegatePtr delegate_;
mojo::Binding<drivefs::mojom::DriveFsBootstrap> bootstrap_binding_;
drivefs::mojom::DriveFsDelegateRequest pending_delegate_request_;
mojo::Receiver<drivefs::mojom::DriveFs> receiver_{this};
mojo::Remote<drivefs::mojom::DriveFsDelegate> delegate_;
mojo::Receiver<drivefs::mojom::DriveFsBootstrap> bootstrap_receiver_{this};
mojo::PendingReceiver<drivefs::mojom::DriveFsDelegate>
pending_delegate_receiver_;
base::WeakPtrFactory<FakeDriveFs> weak_factory_{this};
......
......@@ -14,8 +14,8 @@ import "mojo/public/mojom/base/time.mojom";
interface DriveFsBootstrap {
// Initialize a DriveFS instance with its configuration and mojo connections
// to the browser.
Init(DriveFsConfiguration config, DriveFs& drive_fs,
DriveFsDelegate delegate);
Init(DriveFsConfiguration config, pending_receiver<DriveFs> drive_fs,
pending_remote<DriveFsDelegate> delegate);
};
// Implemented by DriveFS, used from Chrome.
......@@ -49,7 +49,8 @@ interface DriveFs {
(FileError error);
// Start a search query with given parameters.
StartSearchQuery(SearchQuery& query, QueryParameters query_params);
StartSearchQuery(pending_receiver<SearchQuery> query,
QueryParameters query_params);
// Fetches all changelogs, i.e. for My Drive and all Team Drives.
FetchAllChangeLogs();
......
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