Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 204 |
| 205 VolumeInfo CreateProvidedFileSystemVolumeInfo( | 205 VolumeInfo CreateProvidedFileSystemVolumeInfo( |
| 206 const chromeos::file_system_provider::ProvidedFileSystem& file_system) { | 206 const chromeos::file_system_provider::ProvidedFileSystem& file_system) { |
| 207 VolumeInfo volume_info; | 207 VolumeInfo volume_info; |
| 208 volume_info.type = VOLUME_TYPE_PROVIDED; | 208 volume_info.type = VOLUME_TYPE_PROVIDED; |
| 209 volume_info.mount_path = file_system.mount_path(); | 209 volume_info.mount_path = file_system.mount_path(); |
| 210 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; | 210 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; |
| 211 volume_info.is_parent = true; | 211 volume_info.is_parent = true; |
| 212 volume_info.is_read_only = true; | 212 volume_info.is_read_only = true; |
| 213 volume_info.volume_id = GenerateVolumeId(volume_info); | 213 volume_info.volume_id = GenerateVolumeId(volume_info); |
| 214 volume_info.file_system_id = file_system.file_system_id(); | |
| 214 return volume_info; | 215 return volume_info; |
| 215 } | 216 } |
| 216 | 217 |
| 217 } // namespace | 218 } // namespace |
| 218 | 219 |
| 219 VolumeInfo::VolumeInfo() { | 220 VolumeInfo::VolumeInfo() { |
|
satorux1
2014/03/26 08:15:03
I think we should initialize file_system_id and ot
mtomasz
2014/03/26 10:27:42
Done.
| |
| 220 } | 221 } |
| 221 | 222 |
| 222 VolumeInfo::~VolumeInfo() { | 223 VolumeInfo::~VolumeInfo() { |
| 223 } | 224 } |
| 224 | 225 |
| 225 VolumeManager::VolumeManager( | 226 VolumeManager::VolumeManager( |
| 226 Profile* profile, | 227 Profile* profile, |
| 227 drive::DriveIntegrationService* drive_integration_service, | 228 drive::DriveIntegrationService* drive_integration_service, |
| 228 chromeos::PowerManagerClient* power_manager_client, | 229 chromeos::PowerManagerClient* power_manager_client, |
| 229 chromeos::disks::DiskMountManager* disk_mount_manager, | 230 chromeos::disks::DiskMountManager* disk_mount_manager, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 // Subscribe to DiskMountManager. | 290 // Subscribe to DiskMountManager. |
| 290 disk_mount_manager_->AddObserver(this); | 291 disk_mount_manager_->AddObserver(this); |
| 291 | 292 |
| 292 // Subscribe to FileSystemProviderService and register currently mounted | 293 // Subscribe to FileSystemProviderService and register currently mounted |
| 293 // volumes for the profile. | 294 // volumes for the profile. |
| 294 if (file_system_provider_service_) { | 295 if (file_system_provider_service_) { |
| 295 using chromeos::file_system_provider::ProvidedFileSystem; | 296 using chromeos::file_system_provider::ProvidedFileSystem; |
| 296 file_system_provider_service_->AddObserver(this); | 297 file_system_provider_service_->AddObserver(this); |
| 297 | 298 |
| 298 std::vector<ProvidedFileSystem> provided_file_systems = | 299 std::vector<ProvidedFileSystem> provided_file_systems = |
| 299 file_system_provider_service_->GetRegisteredFileSystems(); | 300 file_system_provider_service_->GetMountedFileSystems(); |
| 300 for (size_t i = 0; i < provided_file_systems.size(); ++i) { | 301 for (size_t i = 0; i < provided_file_systems.size(); ++i) { |
| 301 VolumeInfo volume_info = | 302 VolumeInfo volume_info = |
| 302 CreateProvidedFileSystemVolumeInfo(provided_file_systems[i]); | 303 CreateProvidedFileSystemVolumeInfo(provided_file_systems[i]); |
| 303 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, kNotRemounting); | 304 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, kNotRemounting); |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 | 307 |
| 307 std::vector<VolumeInfo> archives; | 308 std::vector<VolumeInfo> archives; |
| 308 | 309 |
| 309 const chromeos::disks::DiskMountManager::MountPointMap& mount_points = | 310 const chromeos::disks::DiskMountManager::MountPointMap& mount_points = |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 FOR_EACH_OBSERVER( | 613 FOR_EACH_OBSERVER( |
| 613 VolumeManagerObserver, observers_, | 614 VolumeManagerObserver, observers_, |
| 614 OnFormatCompleted(device_path, | 615 OnFormatCompleted(device_path, |
| 615 error_code == chromeos::FORMAT_ERROR_NONE)); | 616 error_code == chromeos::FORMAT_ERROR_NONE)); |
| 616 | 617 |
| 617 return; | 618 return; |
| 618 } | 619 } |
| 619 NOTREACHED(); | 620 NOTREACHED(); |
| 620 } | 621 } |
| 621 | 622 |
| 622 void VolumeManager::OnProvidedFileSystemRegistered( | 623 void VolumeManager::OnProvidedFileSystemMount( |
| 623 const chromeos::file_system_provider::ProvidedFileSystem& file_system) { | 624 const chromeos::file_system_provider::ProvidedFileSystem& file_system, |
| 625 base::File::Error error) { | |
| 624 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); | 626 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); |
| 625 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, false /* remounting */); | 627 // TODO(mtomasz): Introduce own type, and avoid using MountError internally, |
| 628 // since it is related to cros disks only. | |
| 629 const chromeos::MountError mount_error = error == base::File::FILE_OK | |
| 630 ? chromeos::MOUNT_ERROR_NONE | |
| 631 : chromeos::MOUNT_ERROR_UNKNOWN; | |
| 632 DoMountEvent(mount_error, volume_info, false /* remounting */); | |
| 626 } | 633 } |
| 627 | 634 |
| 628 void VolumeManager::OnProvidedFileSystemUnregistered( | 635 void VolumeManager::OnProvidedFileSystemUnmount( |
| 629 const chromeos::file_system_provider::ProvidedFileSystem& file_system) { | 636 const chromeos::file_system_provider::ProvidedFileSystem& file_system, |
| 637 base::File::Error error) { | |
| 638 // TODO(mtomasz): Introduce own type, and avoid using MountError internally, | |
| 639 // since it is related to cros disks only. | |
| 640 const chromeos::MountError mount_error = error == base::File::FILE_OK | |
| 641 ? chromeos::MOUNT_ERROR_NONE | |
| 642 : chromeos::MOUNT_ERROR_UNKNOWN; | |
| 630 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); | 643 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); |
| 631 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, volume_info); | 644 DoUnmountEvent(mount_error, volume_info); |
| 632 } | 645 } |
| 633 | 646 |
| 634 void VolumeManager::OnExternalStorageDisabledChanged() { | 647 void VolumeManager::OnExternalStorageDisabledChanged() { |
| 635 // If the policy just got disabled we have to unmount every device currently | 648 // If the policy just got disabled we have to unmount every device currently |
| 636 // mounted. The opposite is fine - we can let the user re-plug her device to | 649 // mounted. The opposite is fine - we can let the user re-plug her device to |
| 637 // make it available. | 650 // make it available. |
| 638 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { | 651 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { |
| 639 // We do not iterate on mount_points directly, because mount_points can | 652 // We do not iterate on mount_points directly, because mount_points can |
| 640 // be changed by UnmountPath(). | 653 // be changed by UnmountPath(). |
| 641 // TODO(hidehiko): Is it necessary to unmount mounted archives, too, here? | 654 // TODO(hidehiko): Is it necessary to unmount mounted archives, too, here? |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 701 return; | 714 return; |
| 702 if (error_code == chromeos::MOUNT_ERROR_NONE) | 715 if (error_code == chromeos::MOUNT_ERROR_NONE) |
| 703 mounted_volumes_.erase(volume_info.volume_id); | 716 mounted_volumes_.erase(volume_info.volume_id); |
| 704 | 717 |
| 705 FOR_EACH_OBSERVER(VolumeManagerObserver, | 718 FOR_EACH_OBSERVER(VolumeManagerObserver, |
| 706 observers_, | 719 observers_, |
| 707 OnVolumeUnmounted(error_code, volume_info)); | 720 OnVolumeUnmounted(error_code, volume_info)); |
| 708 } | 721 } |
| 709 | 722 |
| 710 } // namespace file_manager | 723 } // namespace file_manager |
| OLD | NEW |