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

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 194693002: [fsp] Add requestUnmount() method together with the request manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed some too strict thread checks. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 VolumeInfo CreateProvidedFileSystemVolumeInfo( 201 VolumeInfo CreateProvidedFileSystemVolumeInfo(
202 const chromeos::file_system_provider::ProvidedFileSystem& file_system) { 202 const chromeos::file_system_provider::ProvidedFileSystem& file_system) {
203 VolumeInfo volume_info; 203 VolumeInfo volume_info;
204 volume_info.type = VOLUME_TYPE_PROVIDED; 204 volume_info.type = VOLUME_TYPE_PROVIDED;
205 volume_info.mount_path = file_system.mount_path(); 205 volume_info.mount_path = file_system.mount_path();
206 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; 206 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
207 volume_info.is_parent = true; 207 volume_info.is_parent = true;
208 volume_info.is_read_only = true; 208 volume_info.is_read_only = true;
209 volume_info.volume_id = GenerateVolumeId(volume_info); 209 volume_info.volume_id = GenerateVolumeId(volume_info);
210 volume_info.file_system_id = file_system.file_system_id();
210 return volume_info; 211 return volume_info;
211 } 212 }
212 213
213 } // namespace 214 } // namespace
214 215
215 VolumeInfo::VolumeInfo() { 216 VolumeInfo::VolumeInfo()
216 } 217 : file_system_id(0),
218 type(VOLUME_TYPE_GOOGLE_DRIVE),
219 mount_condition(chromeos::disks::MOUNT_CONDITION_NONE),
220 is_parent(false),
221 is_read_only(false) {}
217 222
218 VolumeInfo::~VolumeInfo() { 223 VolumeInfo::~VolumeInfo() {
219 } 224 }
220 225
221 VolumeManager::VolumeManager( 226 VolumeManager::VolumeManager(
222 Profile* profile, 227 Profile* profile,
223 drive::DriveIntegrationService* drive_integration_service, 228 drive::DriveIntegrationService* drive_integration_service,
224 chromeos::PowerManagerClient* power_manager_client, 229 chromeos::PowerManagerClient* power_manager_client,
225 chromeos::disks::DiskMountManager* disk_mount_manager, 230 chromeos::disks::DiskMountManager* disk_mount_manager,
226 chromeos::file_system_provider::Service* file_system_provider_service) 231 chromeos::file_system_provider::Service* file_system_provider_service)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Subscribe to DiskMountManager. 290 // Subscribe to DiskMountManager.
286 disk_mount_manager_->AddObserver(this); 291 disk_mount_manager_->AddObserver(this);
287 292
288 // Subscribe to FileSystemProviderService and register currently mounted 293 // Subscribe to FileSystemProviderService and register currently mounted
289 // volumes for the profile. 294 // volumes for the profile.
290 if (file_system_provider_service_) { 295 if (file_system_provider_service_) {
291 using chromeos::file_system_provider::ProvidedFileSystem; 296 using chromeos::file_system_provider::ProvidedFileSystem;
292 file_system_provider_service_->AddObserver(this); 297 file_system_provider_service_->AddObserver(this);
293 298
294 std::vector<ProvidedFileSystem> provided_file_systems = 299 std::vector<ProvidedFileSystem> provided_file_systems =
295 file_system_provider_service_->GetRegisteredFileSystems(); 300 file_system_provider_service_->GetMountedFileSystems();
296 for (size_t i = 0; i < provided_file_systems.size(); ++i) { 301 for (size_t i = 0; i < provided_file_systems.size(); ++i) {
297 VolumeInfo volume_info = 302 VolumeInfo volume_info =
298 CreateProvidedFileSystemVolumeInfo(provided_file_systems[i]); 303 CreateProvidedFileSystemVolumeInfo(provided_file_systems[i]);
299 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, kNotRemounting); 304 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, kNotRemounting);
300 } 305 }
301 } 306 }
302 307
303 std::vector<VolumeInfo> archives; 308 std::vector<VolumeInfo> archives;
304 309
305 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
608 FOR_EACH_OBSERVER( 613 FOR_EACH_OBSERVER(
609 VolumeManagerObserver, observers_, 614 VolumeManagerObserver, observers_,
610 OnFormatCompleted(device_path, 615 OnFormatCompleted(device_path,
611 error_code == chromeos::FORMAT_ERROR_NONE)); 616 error_code == chromeos::FORMAT_ERROR_NONE));
612 617
613 return; 618 return;
614 } 619 }
615 NOTREACHED(); 620 NOTREACHED();
616 } 621 }
617 622
618 void VolumeManager::OnProvidedFileSystemRegistered( 623 void VolumeManager::OnProvidedFileSystemMount(
619 const chromeos::file_system_provider::ProvidedFileSystem& file_system) { 624 const chromeos::file_system_provider::ProvidedFileSystem& file_system,
625 base::File::Error error) {
620 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); 626 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system);
621 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 */);
622 } 633 }
623 634
624 void VolumeManager::OnProvidedFileSystemUnregistered( 635 void VolumeManager::OnProvidedFileSystemUnmount(
625 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;
626 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); 643 VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system);
627 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, volume_info); 644 DoUnmountEvent(mount_error, volume_info);
628 } 645 }
629 646
630 void VolumeManager::OnExternalStorageDisabledChanged() { 647 void VolumeManager::OnExternalStorageDisabledChanged() {
631 // 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
632 // 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
633 // make it available. 650 // make it available.
634 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { 651 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
635 // 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
636 // be changed by UnmountPath(). 653 // be changed by UnmountPath().
637 // 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
697 return; 714 return;
698 if (error_code == chromeos::MOUNT_ERROR_NONE) 715 if (error_code == chromeos::MOUNT_ERROR_NONE)
699 mounted_volumes_.erase(volume_info.volume_id); 716 mounted_volumes_.erase(volume_info.volume_id);
700 717
701 FOR_EACH_OBSERVER(VolumeManagerObserver, 718 FOR_EACH_OBSERVER(VolumeManagerObserver,
702 observers_, 719 observers_,
703 OnVolumeUnmounted(error_code, volume_info)); 720 OnVolumeUnmounted(error_code, volume_info));
704 } 721 }
705 722
706 } // namespace file_manager 723 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/volume_manager.h ('k') | chrome/browser/chromeos/file_system_provider/observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698