diff options
author | hshi@google.com <hshi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-12 01:54:07 +0000 |
---|---|---|
committer | hshi@google.com <hshi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-12 01:54:07 +0000 |
commit | ca671ba1ed988a9cdccec91a8baf5da9939eafca (patch) | |
tree | 8b50f3b32d1d8640f9437c53d7e68fc954a5e156 | |
parent | c654d8102e848b058f111fa3ea4e004e4cd770e7 (diff) | |
download | chromium_src-ca671ba1ed988a9cdccec91a8baf5da9939eafca.zip chromium_src-ca671ba1ed988a9cdccec91a8baf5da9939eafca.tar.gz chromium_src-ca671ba1ed988a9cdccec91a8baf5da9939eafca.tar.bz2 |
gdata: notify File Manager when file system is no longer available
When authentication fails raise chrome.fileBrowserPrivate.onMountCompleted
with eventType == 'unmount' and event.mountType == 'gdata'.
BUG=126781
TEST=local test on lumpy
Review URL: https://chromiumcodereview.appspot.com/10389083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136740 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 40 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc index 776f741..d8c7284 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc @@ -393,6 +393,20 @@ void FileBrowserEventRouter::OnDocumentFeedFetched( } +void FileBrowserEventRouter::OnAuthenticationFailed() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + // Raise a MountCompleted event to notify the File Manager. + const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); + DiskMountManager::MountPointInfo mount_info( + gdata_path, + gdata_path, + chromeos::MOUNT_TYPE_GDATA, + chromeos::disks::MOUNT_CONDITION_NONE); + MountCompleted(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, + mount_info); +} + void FileBrowserEventRouter::HandleFileWatchNotification( const FilePath& local_path, bool got_error) { base::AutoLock lock(lock_); diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.h b/chrome/browser/chromeos/extensions/file_browser_event_router.h index d4d4673..d6a2c37 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.h +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.h @@ -78,6 +78,7 @@ class FileBrowserEventRouter virtual void OnProgressUpdate( const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list) OVERRIDE; + virtual void OnAuthenticationFailed() OVERRIDE; // gdata::GDataFileSystem::Observer overrides. virtual void OnDirectoryChanged(const FilePath& directory_path) OVERRIDE; diff --git a/chrome/browser/chromeos/gdata/gdata_operation_registry.cc b/chrome/browser/chromeos/gdata/gdata_operation_registry.cc index b99a78e..683275d 100644 --- a/chrome/browser/chromeos/gdata/gdata_operation_registry.cc +++ b/chrome/browser/chromeos/gdata/gdata_operation_registry.cc @@ -128,6 +128,11 @@ void GDataOperationRegistry::Operation::NotifyResume() { } } +void GDataOperationRegistry::Operation::NotifyAuthFailed() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + registry_->OnOperationAuthFailed(); +} + GDataOperationRegistry::GDataOperationRegistry() { in_flight_operations_.set_check_on_null_data(true); } @@ -266,6 +271,13 @@ void GDataOperationRegistry::OnOperationSuspend(OperationID id) { } } +void GDataOperationRegistry::OnOperationAuthFailed() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + DVLOG(1) << "GDataOperation authentication failed."; + FOR_EACH_OBSERVER(Observer, observer_list_, OnAuthenticationFailed()); +} + bool GDataOperationRegistry::IsFileTransferOperation( const Operation* operation) const { OperationType type = operation->progress_status().operation_type; diff --git a/chrome/browser/chromeos/gdata/gdata_operation_registry.h b/chrome/browser/chromeos/gdata/gdata_operation_registry.h index 95dc2a3..a195681 100644 --- a/chrome/browser/chromeos/gdata/gdata_operation_registry.h +++ b/chrome/browser/chromeos/gdata/gdata_operation_registry.h @@ -76,6 +76,8 @@ class GDataOperationRegistry { public: // Called when a GData operation started, made some progress, or finished. virtual void OnProgressUpdate(const ProgressStatusList& list) = 0; + // Called when GData authentication failed. + virtual void OnAuthenticationFailed() {} protected: virtual ~Observer() {} }; @@ -112,6 +114,8 @@ class GDataOperationRegistry { // that it removes the existing "suspend" operation. void NotifySuspend(); void NotifyResume(); + // Notifies that authentication has failed. + void NotifyAuthFailed(); private: // Does the cancellation. @@ -144,6 +148,7 @@ class GDataOperationRegistry { void OnOperationFinish(OperationID operation); void OnOperationSuspend(OperationID operation); void OnOperationResume(Operation* operation, ProgressStatus* new_status); + void OnOperationAuthFailed(); bool IsFileTransferOperation(const Operation* operation) const; diff --git a/chrome/browser/chromeos/gdata/gdata_operations.cc b/chrome/browser/chromeos/gdata/gdata_operations.cc index be08bd5..ad6df46 100644 --- a/chrome/browser/chromeos/gdata/gdata_operations.cc +++ b/chrome/browser/chromeos/gdata/gdata_operations.cc @@ -349,6 +349,9 @@ void UrlFetchOperationBase::OnAuthFailed(GDataErrorCode code) { NotifyStart(); NotifyFinish(GDataOperationRegistry::OPERATION_FAILED); + + // Notify authentication failed. + NotifyAuthFailed(); } std::string UrlFetchOperationBase::GetResponseHeadersAsString( diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index ce12040..7912a76 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -2643,9 +2643,10 @@ FileManager.prototype = { var changeDirectoryTo = null; if (event && event.mountType == 'gdata') { + var mounted = (event.eventType == 'mount'); metrics.recordInterval('Load.GData'); - console.log('GData mounted'); - if (event.status == 'success') { + console.log('GData ' + (mounted ? 'mounted' : 'unmounted')); + if (mounted && event.status == 'success') { this.gdataMounted_ = true; this.gdataMountInfo_ = { 'mountPath': event.mountPath, @@ -2668,7 +2669,8 @@ FileManager.prototype = { this.gdataMounted_ = false; this.gdataMountInfo_ = null; this.clearGDataLoadingTimer_(); - this.onGDataUnreachable_('GData mount failed: ' + event.status); + this.onGDataUnreachable_('GData ' + + (mounted ? ('mount failed: ' + event.status) : 'unmounted')); if (this.setupCurrentDirectoryPostponed_) { this.setupCurrentDirectoryPostponed_(true /* cancel */); // Change to unmounted GData root. |