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

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

Issue 2637163002: Defer ARC file system operations while ARC is booting. (Closed)
Patch Set: Addressed hidehiko's comments. Created 3 years, 11 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 392914fab273a9fa107ffdc177e12eff87808256..5663e8d5ba1915634c1824fa33ed76c10e453250 100644
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -17,7 +17,6 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_file_system_service.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_media_view_util.h"
@@ -34,7 +33,6 @@
#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/disks/disk_mount_manager.h"
-#include "components/arc/arc_service_manager.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/file_system_core_util.h"
#include "components/prefs/pref_service.h"
@@ -410,8 +408,8 @@ void VolumeManager::Initialize() {
// Subscribe to ARC file system events.
if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) &&
arc::ArcSessionManager::IsAllowedForProfile(profile_)) {
- arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>()
- ->AddObserver(this);
+ arc::ArcSessionManager::Get()->AddObserver(this);
+ OnArcOptInChanged(arc::ArcSessionManager::Get()->IsArcEnabled());
}
}
@@ -433,12 +431,11 @@ void VolumeManager::Shutdown() {
// Unsubscribe from ARC file system events.
if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) &&
arc::ArcSessionManager::IsAllowedForProfile(profile_)) {
- arc::ArcFileSystemService* file_system_service =
- arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>();
+ auto* session_manager = arc::ArcSessionManager::Get();
// TODO(crbug.com/672829): We need nullptr check here because
- // ArcServiceManager may or may not be alive at this point.
- if (file_system_service)
- file_system_service->RemoveObserver(this);
+ // ArcSessionManager may or may not be alive at this point.
+ if (session_manager)
+ session_manager->RemoveObserver(this);
}
}
@@ -744,36 +741,37 @@ void VolumeManager::OnExternalStorageDisabledChangedUnmountCallback(
weak_ptr_factory_.GetWeakPtr()));
}
-void VolumeManager::OnFileSystemsReady() {
+void VolumeManager::OnArcOptInChanged(bool enabled) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature));
DCHECK(arc::ArcSessionManager::IsAllowedForProfile(profile_));
- DoMountEvent(chromeos::MOUNT_ERROR_NONE,
- linked_ptr<Volume>(
- Volume::CreateForMediaView(arc::kImagesRootDocumentId)));
- DoMountEvent(chromeos::MOUNT_ERROR_NONE,
- linked_ptr<Volume>(
- Volume::CreateForMediaView(arc::kVideosRootDocumentId)));
- DoMountEvent(chromeos::MOUNT_ERROR_NONE,
- linked_ptr<Volume>(
- Volume::CreateForMediaView(arc::kAudioRootDocumentId)));
-}
-
-void VolumeManager::OnFileSystemsClosed() {
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature));
- DCHECK(arc::ArcSessionManager::IsAllowedForProfile(profile_));
+ if (enabled == arc_volumes_mounted_)
+ return;
- DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
+ if (enabled) {
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE,
linked_ptr<Volume>(
Volume::CreateForMediaView(arc::kImagesRootDocumentId)));
- DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE,
linked_ptr<Volume>(
Volume::CreateForMediaView(arc::kVideosRootDocumentId)));
- DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE,
linked_ptr<Volume>(
Volume::CreateForMediaView(arc::kAudioRootDocumentId)));
+ arc_volumes_mounted_ = true;
hashimoto 2017/01/23 08:28:43 nit: arc_volumes_mounted_ = enabled at the last of
Shuhei Takahashi 2017/01/23 09:17:51 Done.
+ } else {
+ DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
+ linked_ptr<Volume>(
+ Volume::CreateForMediaView(arc::kImagesRootDocumentId)));
+ DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
+ linked_ptr<Volume>(
+ Volume::CreateForMediaView(arc::kVideosRootDocumentId)));
+ DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
+ linked_ptr<Volume>(
+ Volume::CreateForMediaView(arc::kAudioRootDocumentId)));
+ arc_volumes_mounted_ = false;
+ }
}
void VolumeManager::OnExternalStorageDisabledChanged() {

Powered by Google App Engine
This is Rietveld 408576698