Commit 6a6a1f26 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Don't initialize the old drive sync infrastructure with DriveFS enabled.

Update the getDriveConnectionStatus() and getSizeStats()
implementations, the file manager EventRouter, and the test fake to
function correctly when only DriveFS is enabled. Also update the test
fakes to handle mount-relative absolute paths sent over mojo.

Bug: 844292, 848126
Change-Id: I6f98d6bb3d00a9fcc4b26cd1090c2fa06ecf33e3
Reviewed-on: https://chromium-review.googlesource.com/1102234Reviewed-by: default avatarSasha Morrissey <sashab@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568335}
parent f96166b9
......@@ -326,6 +326,7 @@ DriveIntegrationService::DriveIntegrationService(
cache_root_directory_(!test_cache_root.empty()
? test_cache_root
: util::GetCacheRootPath(profile)),
preference_watcher_(preference_watcher),
drivefs_holder_(
base::FeatureList::IsEnabled(kDriveFs)
? std::make_unique<DriveFsHolder>(
......@@ -344,6 +345,17 @@ DriveIntegrationService::DriveIntegrationService(
{base::MayBlock(), base::TaskPriority::USER_BLOCKING,
base::WithBaseSyncPrimitives()});
if (preference_watcher_)
preference_watcher->set_integration_service(this);
if (drivefs_holder_) {
delete test_drive_service;
delete test_file_system;
state_ = INITIALIZED;
SetEnabled(drive::util::IsDriveEnabledForProfile(profile));
return;
}
ProfileOAuth2TokenService* oauth_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
......@@ -393,11 +405,6 @@ DriveIntegrationService::DriveIntegrationService(
debug_info_collector_.reset(new DebugInfoCollector(
resource_metadata_.get(), file_system(), blocking_task_runner_.get()));
if (preference_watcher) {
preference_watcher_.reset(preference_watcher);
preference_watcher->set_integration_service(this);
}
SetEnabled(drive::util::IsDriveEnabledForProfile(profile));
}
......@@ -530,7 +537,8 @@ void DriveIntegrationService::ClearCacheAndRemountFileSystem(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!callback.is_null());
if (state_ != INITIALIZED) {
// TODO(crbug.com/845393): Implement for DriveFS.
if (state_ != INITIALIZED || drivefs_holder_) {
callback.Run(false);
return;
}
......@@ -614,7 +622,8 @@ void DriveIntegrationService::RemoveDriveMountPoint() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!mount_point_name_.empty()) {
job_list()->CancelAllJobs();
if (!drivefs_holder_)
job_list()->CancelAllJobs();
for (auto& observer : observers_)
observer.OnFileSystemBeingUnmounted();
......
......@@ -236,14 +236,13 @@ bool IsDriveEnabledForProfile(Profile* profile) {
}
ConnectionStatusType GetDriveConnectionStatus(Profile* profile) {
drive::DriveServiceInterface* const drive_service =
drive::util::GetDriveServiceByProfile(profile);
if (!drive_service)
auto* drive_integration_service = GetIntegrationServiceByProfile(profile);
if (!drive_integration_service)
return DRIVE_DISCONNECTED_NOSERVICE;
if (net::NetworkChangeNotifier::IsOffline())
return DRIVE_DISCONNECTED_NONETWORK;
if (!drive_service->CanSendRequest())
auto* drive_service = drive_integration_service->drive_service();
if (drive_service && !drive_service->CanSendRequest())
return DRIVE_DISCONNECTED_NOTREADY;
const bool is_connection_cellular =
......
......@@ -458,12 +458,13 @@ void EventRouter::Shutdown() {
DriveIntegrationService* const integration_service =
DriveIntegrationServiceFactory::FindForProfile(profile_);
if (integration_service) {
integration_service->file_system()->RemoveObserver(this);
integration_service->drive_service()->RemoveObserver(this);
integration_service->job_list()->RemoveObserver(job_event_router_.get());
if (integration_service->GetDriveFsHost()) {
integration_service->GetDriveFsHost()->RemoveObserver(
drivefs_event_router_.get());
} else {
integration_service->file_system()->RemoveObserver(this);
integration_service->drive_service()->RemoveObserver(this);
integration_service->job_list()->RemoveObserver(job_event_router_.get());
}
}
......@@ -509,12 +510,13 @@ void EventRouter::ObserveEvents() {
DriveIntegrationService* const integration_service =
DriveIntegrationServiceFactory::FindForProfile(profile_);
if (integration_service) {
integration_service->drive_service()->AddObserver(this);
integration_service->file_system()->AddObserver(this);
integration_service->job_list()->AddObserver(job_event_router_.get());
if (integration_service->GetDriveFsHost()) {
integration_service->GetDriveFsHost()->AddObserver(
drivefs_event_router_.get());
} else {
integration_service->drive_service()->AddObserver(this);
integration_service->file_system()->AddObserver(this);
integration_service->job_list()->AddObserver(job_event_router_.get());
}
}
......
......@@ -459,7 +459,8 @@ bool FileManagerPrivateGetSizeStatsFunction::RunAsync() {
if (!volume.get())
return false;
if (volume->type() == file_manager::VOLUME_TYPE_GOOGLE_DRIVE) {
if (volume->type() == file_manager::VOLUME_TYPE_GOOGLE_DRIVE &&
!base::FeatureList::IsEnabled(drive::kDriveFs)) {
drive::FileSystemInterface* file_system =
drive::util::GetFileSystemByProfile(GetProfile());
if (!file_system) {
......
......@@ -635,7 +635,7 @@ class DriveTestVolume : public TestVolume {
// Sets the url base for the test server to be used to generate share urls
// on the files and directories.
void ConfigureShareUrlBase(const GURL& share_url_base) {
virtual void ConfigureShareUrlBase(const GURL& share_url_base) {
fake_drive_service_->set_share_url_base(share_url_base);
}
......@@ -712,6 +712,8 @@ class DriveFsTestVolume : public DriveTestVolume {
ASSERT_TRUE(UpdateModifiedTime(entry));
}
void ConfigureShareUrlBase(const GURL& share_url_base) override {}
private:
base::RepeatingCallback<
std::unique_ptr<drivefs::DriveFsHost::MojoConnectionDelegate>()>
......
......@@ -138,8 +138,10 @@ void FakeDriveFs::Init(drivefs::mojom::DriveFsConfigurationPtr config,
void FakeDriveFs::GetMetadata(const base::FilePath& path,
bool want_thumbnail,
GetMetadataCallback callback) {
base::FilePath absolute_path = mount_path_;
CHECK(base::FilePath("/").AppendRelativePath(path, &absolute_path));
base::File::Info info;
if (!base::GetFileInfo(path, &info)) {
if (!base::GetFileInfo(absolute_path, &info)) {
std::move(callback).Run(drive::FILE_ERROR_NOT_FOUND, nullptr);
return;
}
......
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