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

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

Issue 379743004: Add a method in DiskMountManager to refresh mount entries in addition to devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments + Fix up MockDiskMountManager. Created 6 years, 5 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 a1945b3012424462df7d0faf87832aa0c04f983f..03796335660428afd17ade79fef38ce6e0ba07a0 100644
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -310,6 +310,9 @@ void VolumeManager::Initialize() {
// Subscribe to DiskMountManager.
disk_mount_manager_->AddObserver(this);
+ disk_mount_manager_->EnsureMountInfoRefreshed(
+ base::Bind(&VolumeManager::OnDiskMountManagerRefreshed,
+ weak_ptr_factory_.GetWeakPtr()));
// Subscribe to FileSystemProviderService and register currently mounted
// volumes for the profile.
@@ -326,54 +329,6 @@ void VolumeManager::Initialize() {
}
}
- std::vector<VolumeInfo> archives;
-
- const chromeos::disks::DiskMountManager::MountPointMap& mount_points =
- disk_mount_manager_->mount_points();
- for (chromeos::disks::DiskMountManager::MountPointMap::const_iterator it =
- mount_points.begin();
- it != mount_points.end();
- ++it) {
- if (it->second.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) {
- // Archives are mounted after other type of volumes. See below.
- archives.push_back(CreateVolumeInfoFromMountPointInfo(it->second, NULL));
- continue;
- }
- DoMountEvent(
- chromeos::MOUNT_ERROR_NONE,
- CreateVolumeInfoFromMountPointInfo(
- it->second,
- disk_mount_manager_->FindDiskBySourcePath(it->second.source_path)),
- kNotRemounting);
- }
-
- // We mount archives only if they are opened from currently mounted volumes.
- // To check the condition correctly in DoMountEvent, we care the order.
- std::vector<bool> done(archives.size(), false);
- for (size_t i = 0; i < archives.size(); ++i) {
- if (!done[i]) {
- std::vector<VolumeInfo> chain;
- done[i] = true;
- chain.push_back(archives[i]);
-
- // If archives[i]'s source_path is in another archive, mount it first.
- for (size_t parent = 0; parent < archives.size(); ++parent) {
- if (!done[parent] &&
- archives[parent].mount_path.IsParent(chain.back().source_path)) {
- done[parent] = true;
- chain.push_back(archives[parent]);
- parent = 0; // Search archives[parent]'s parent from the beginning.
- }
- }
-
- // Mount from the tail of chain.
- for (size_t i = chain.size(); i > 0; --i)
- DoMountEvent(chromeos::MOUNT_ERROR_NONE, chain[i - 1], kNotRemounting);
- }
- }
-
- disk_mount_manager_->RequestMountInfoRefresh();
-
// Subscribe to Profile Preference change.
pref_change_registrar_.Init(profile_->GetPrefs());
pref_change_registrar_.Add(
@@ -787,6 +742,60 @@ void VolumeManager::OnRemovableStorageDetached(
}
}
+void VolumeManager::OnDiskMountManagerRefreshed(bool success) {
+ if (!success) {
+ LOG(ERROR) << "Failed to refresh disk mount manager";
+ return;
+ }
+
+ std::vector<VolumeInfo> archives;
+
+ const chromeos::disks::DiskMountManager::MountPointMap& mount_points =
+ disk_mount_manager_->mount_points();
+ for (chromeos::disks::DiskMountManager::MountPointMap::const_iterator it =
+ mount_points.begin();
+ it != mount_points.end();
+ ++it) {
+ if (it->second.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) {
+ // Archives are mounted after other types of volume. See below.
+ archives.push_back(CreateVolumeInfoFromMountPointInfo(it->second, NULL));
+ continue;
+ }
+ DoMountEvent(
+ chromeos::MOUNT_ERROR_NONE,
+ CreateVolumeInfoFromMountPointInfo(
+ it->second,
+ disk_mount_manager_->FindDiskBySourcePath(it->second.source_path)),
+ kNotRemounting);
+ }
+
+ // We mount archives only if they are opened from currently mounted volumes.
+ // To check the condition correctly in DoMountEvent, we care about the order.
+ std::vector<bool> done(archives.size(), false);
+ for (size_t i = 0; i < archives.size(); ++i) {
+ if (done[i])
+ continue;
+
+ std::vector<VolumeInfo> chain;
+ done[i] = true;
+ chain.push_back(archives[i]);
+
+ // If archives[i]'s source_path is in another archive, mount it first.
+ for (size_t parent = i + 1; parent < archives.size(); ++parent) {
+ if (!done[parent] &&
+ archives[parent].mount_path.IsParent(chain.back().source_path)) {
+ done[parent] = true;
+ chain.push_back(archives[parent]);
+ parent = i + 1; // Search archives[parent]'s parent from the beginning.
+ }
+ }
+
+ // Mount from the tail of chain.
+ for (size_t i = chain.size(); i > 0; --i)
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, chain[i - 1], kNotRemounting);
+ }
+}
+
void VolumeManager::OnStorageMonitorInitialized() {
std::vector<storage_monitor::StorageInfo> storages =
storage_monitor::StorageMonitor::GetInstance()->GetAllAvailableStorages();

Powered by Google App Engine
This is Rietveld 408576698