#include "chrome/browser/chromeos/drive/file_system.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/drive/job_scheduler.h"
-#include "chrome/browser/chromeos/drive/logging.h"
#include "chrome/browser/chromeos/drive/resource_metadata.h"
#include "chrome/browser/chromeos/drive/resource_metadata_storage.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/drive/drive_app_registry.h"
#include "chrome/browser/drive/drive_notification_manager.h"
#include "chrome/browser/drive/drive_notification_manager_factory.h"
+#include "chrome/browser/drive/event_logger.h"
#include "chrome/browser/drive/gdata_wapi_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service.h"
metadata_storage->RecoverCacheInfoFromTrashedResourceMap(
&recovered_cache_info);
- LOG(WARNING) << "DB could not be opened for some reasons. "
- << "Recovering cache files to " << dest_directory.value();
+ LOG_IF(WARNING, !recovered_cache_info.empty())
+ << "DB could not be opened for some reasons. "
+ << "Recovering cache files to " << dest_directory.value();
if (!cache->RecoverFilesFromCacheDirectory(dest_directory,
recovered_cache_info)) {
LOG(WARNING) << "Failed to recover cache files.";
Profile* profile,
PreferenceWatcher* preference_watcher,
DriveServiceInterface* test_drive_service,
+ const std::string& test_mount_point_name,
const base::FilePath& test_cache_root,
FileSystemInterface* test_file_system)
: profile_(profile),
state_(NOT_INITIALIZED),
enabled_(false),
+ mount_point_name_(test_mount_point_name),
cache_root_directory_(!test_cache_root.empty() ?
test_cache_root : util::GetCacheRootPath(profile)),
weak_ptr_factory_(this) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ logger_.reset(new EventLogger);
base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool();
blocking_task_runner_ = blocking_pool->GetSequencedTaskRunner(
blocking_pool->GetSequenceToken());
}
scheduler_.reset(new JobScheduler(
profile_->GetPrefs(),
+ logger_.get(),
drive_service_.get(),
blocking_task_runner_.get()));
metadata_storage_.reset(new internal::ResourceMetadataStorage(
file_system_.reset(
test_file_system ? test_file_system : new FileSystem(
profile_->GetPrefs(),
+ logger_.get(),
cache_.get(),
drive_service_.get(),
scheduler_.get(),
blocking_task_runner_.get(),
cache_root_directory_.Append(kTemporaryFileDirectory)));
download_handler_.reset(new DownloadHandler(file_system()));
- debug_info_collector_.reset(
- new DebugInfoCollector(file_system(), cache_.get(),
- blocking_task_runner_.get()));
+ debug_info_collector_.reset(new DebugInfoCollector(
+ cache_.get(), resource_metadata_.get(), file_system(),
+ blocking_task_runner_.get()));
if (preference_watcher) {
preference_watcher_.reset(preference_watcher);
}
bool DriveIntegrationService::IsMounted() const {
+ if (mount_point_name_.empty())
+ return false;
+
// Look up the registered path, and just discard it.
// GetRegisteredPath() returns true if the path is available.
- const base::FilePath& drive_mount_point = util::GetDriveMountPointPath();
base::FilePath unused;
- return BrowserContext::GetMountPoints(profile_)->GetRegisteredPath(
- drive_mount_point.BaseName().AsUTF8Unsafe(), &unused);
+ fileapi::ExternalMountPoints* const mount_points =
+ fileapi::ExternalMountPoints::GetSystemInstance();
+ DCHECK(mount_points);
+ return mount_points->GetRegisteredPath(mount_point_name_, &unused);
}
void DriveIntegrationService::AddObserver(
drive_app_registry_->Update();
const char* status = (enabled ? "enabled" : "disabled");
- util::Log(logging::LOG_INFO, "Push notification is %s", status);
+ logger_->Log(logging::LOG_INFO, "Push notification is %s", status);
}
void DriveIntegrationService::ClearCacheAndRemountFileSystem(
DCHECK_EQ(INITIALIZED, state_);
DCHECK(enabled_);
- const base::FilePath drive_mount_point = util::GetDriveMountPointPath();
- fileapi::ExternalMountPoints* mount_points =
- BrowserContext::GetMountPoints(profile_);
+ const base::FilePath& drive_mount_point =
+ util::GetDriveMountPointPath(profile_);
+ if (mount_point_name_.empty())
+ mount_point_name_ = drive_mount_point.BaseName().AsUTF8Unsafe();
+ fileapi::ExternalMountPoints* const mount_points =
+ fileapi::ExternalMountPoints::GetSystemInstance();
DCHECK(mount_points);
bool success = mount_points->RegisterFileSystem(
- drive_mount_point.BaseName().AsUTF8Unsafe(),
+ mount_point_name_,
fileapi::kFileSystemTypeDrive,
fileapi::FileSystemMountOption(),
drive_mount_point);
if (success) {
- util::Log(logging::LOG_INFO, "Drive mount point is added");
+ logger_->Log(logging::LOG_INFO, "Drive mount point is added");
FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_,
OnFileSystemMounted());
}
void DriveIntegrationService::RemoveDriveMountPoint() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- job_list()->CancelAllJobs();
+ if (!mount_point_name_.empty()) {
+ job_list()->CancelAllJobs();
- FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_,
- OnFileSystemBeingUnmounted());
+ FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_,
+ OnFileSystemBeingUnmounted());
- fileapi::ExternalMountPoints* mount_points =
- BrowserContext::GetMountPoints(profile_);
- DCHECK(mount_points);
+ fileapi::ExternalMountPoints* const mount_points =
+ fileapi::ExternalMountPoints::GetSystemInstance();
+ DCHECK(mount_points);
- mount_points->RevokeFileSystem(
- util::GetDriveMountPointPath().BaseName().AsUTF8Unsafe());
- util::Log(logging::LOG_INFO, "Drive mount point is removed");
+ mount_points->RevokeFileSystem(mount_point_name_);
+ logger_->Log(logging::LOG_INFO, "Drive mount point is removed");
+ }
}
void DriveIntegrationService::Initialize() {
const bool registered =
drive_notification_manager->push_notification_registered();
const char* status = (registered ? "registered" : "not registered");
- util::Log(logging::LOG_INFO, "Push notification is %s", status);
+ logger_->Log(logging::LOG_INFO, "Push notification is %s", status);
if (drive_notification_manager->push_notification_enabled())
drive_app_registry_->Update();
new DriveIntegrationService::PreferenceWatcher(profile->GetPrefs());
}
- service = new DriveIntegrationService(profile, preference_watcher,
- NULL, base::FilePath(), NULL);
+ service = new DriveIntegrationService(
+ profile, preference_watcher,
+ NULL, std::string(), base::FilePath(), NULL);
} else {
service = factory_for_test_->Run(profile);
}