Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4259)

Unified Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 23477070: Move OnFileSystemMounted/BeingUnmounted to VolumeManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/file_manager/volume_manager.cc
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc
index 6e869fd705912000a0f0a7302c9bcc3f693a0310..578089244da1722e10ccac387312b975ec2dfac2 100644
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -12,6 +12,7 @@
#include "base/memory/singleton.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
+#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_errors.h"
#include "chrome/browser/chromeos/drive/file_system_interface.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
@@ -46,6 +47,19 @@ VolumeType MountTypeToVolumeType(
return VOLUME_TYPE_DOWNLOADS_DIRECTORY;
}
+// Returns the VolumeInfo for Drive file system.
+VolumeInfo CreateDriveVolumeInfo() {
+ const base::FilePath& drive_path = drive::util::GetDriveMountPointPath();
+
+ VolumeInfo volume_info;
+ volume_info.type = VOLUME_TYPE_GOOGLE_DRIVE;
+ volume_info.source_path = drive_path;
+ volume_info.mount_path = drive_path;
+ volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
+ volume_info.is_parent = false;
+ return volume_info;
+}
+
VolumeInfo CreateDownloadsVolumeInfo(
const base::FilePath& downloads_path) {
VolumeInfo volume_info;
@@ -85,23 +99,13 @@ VolumeInfo::VolumeInfo() {
VolumeInfo::~VolumeInfo() {
}
-VolumeInfo CreateDriveVolumeInfo() {
- const base::FilePath& drive_path = drive::util::GetDriveMountPointPath();
-
- VolumeInfo volume_info;
- volume_info.type = VOLUME_TYPE_GOOGLE_DRIVE;
- volume_info.source_path = drive_path;
- volume_info.mount_path = drive_path;
- volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
- volume_info.is_parent = false;
- return volume_info;
-}
-
VolumeManager::VolumeManager(
Profile* profile,
+ drive::DriveIntegrationService* drive_integration_service,
chromeos::PowerManagerClient* power_manager_client,
chromeos::disks::DiskMountManager* disk_mount_manager)
: profile_(profile),
+ drive_integration_service_(drive_integration_service),
disk_mount_manager_(disk_mount_manager),
mounted_disk_monitor_(
new MountedDiskMonitor(power_manager_client, disk_mount_manager)) {
@@ -116,6 +120,9 @@ VolumeManager* VolumeManager::Get(content::BrowserContext* context) {
}
void VolumeManager::Initialize() {
+ if (drive_integration_service_)
+ drive_integration_service_->AddObserver(this);
+
// Subscribe to DiskMountManager.
disk_mount_manager_->AddObserver(this);
disk_mount_manager_->RequestMountInfoRefresh();
@@ -131,6 +138,9 @@ void VolumeManager::Initialize() {
void VolumeManager::Shutdown() {
pref_change_registrar_.RemoveAll();
disk_mount_manager_->RemoveObserver(this);
+
+ if (drive_integration_service_)
+ drive_integration_service_->RemoveObserver(this);
}
void VolumeManager::AddObserver(VolumeManagerObserver* observer) {
@@ -175,6 +185,28 @@ std::vector<VolumeInfo> VolumeManager::GetVolumeInfoList() const {
return result;
}
+void VolumeManager::OnFileSystemMounted() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ // Raise mount event.
+ // We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed
+ // or network is unreachable. These two errors will be handled later.
+ VolumeInfo volume_info = CreateDriveVolumeInfo();
+ FOR_EACH_OBSERVER(VolumeManagerObserver, observers_,
+ OnVolumeMounted(chromeos::MOUNT_ERROR_NONE,
+ volume_info,
+ false)); // Not remounting.
+}
+
+void VolumeManager::OnFileSystemBeingUnmounted() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ VolumeInfo volume_info = CreateDriveVolumeInfo();
+ FOR_EACH_OBSERVER(
+ VolumeManagerObserver, observers_,
+ OnVolumeUnmounted(chromeos::MOUNT_ERROR_NONE, volume_info));
+}
+
void VolumeManager::OnDiskEvent(
chromeos::disks::DiskMountManager::DiskEvent event,
const chromeos::disks::DiskMountManager::Disk* disk) {
« no previous file with comments | « chrome/browser/chromeos/file_manager/volume_manager.h ('k') | chrome/browser/chromeos/file_manager/volume_manager_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698