diff options
Diffstat (limited to 'chrome/browser/chromeos')
6 files changed, 51 insertions, 8 deletions
diff --git a/chrome/browser/chromeos/drive/drive_file_system.cc b/chrome/browser/chromeos/drive/drive_file_system.cc index 6a97489..e4d19e4 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.cc +++ b/chrome/browser/chromeos/drive/drive_file_system.cc @@ -386,18 +386,26 @@ DriveFileSystem::DriveFileSystem( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); } +void DriveFileSystem::Reload() { + InitializeResourceMetadtaAndFeedLoader(); + + resource_metadata_->set_origin(INITIALIZING); + feed_loader_->ReloadFromServerIfNeeded( + UNINITIALIZED, + resource_metadata_->largest_changestamp(), + base::Bind(&DriveFileSystem::NotifyInitialLoadFinishedAndRun, + ui_weak_ptr_, + base::Bind(&DriveFileSystem::OnUpdateChecked, + ui_weak_ptr_, + UNINITIALIZED))); +} + void DriveFileSystem::Initialize() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); drive_service_->Initialize(profile_); - resource_metadata_.reset(new DriveResourceMetadata); - feed_loader_.reset(new DriveFeedLoader(resource_metadata_.get(), - drive_service_, - webapps_registry_, - cache_, - blocking_task_runner_)); - feed_loader_->AddObserver(this); + InitializeResourceMetadtaAndFeedLoader(); // Allocate the drive operation handlers. drive_operations_.Init(drive_service_, @@ -416,6 +424,16 @@ void DriveFileSystem::Initialize() { InitializePreferenceObserver(); } +void DriveFileSystem::InitializeResourceMetadtaAndFeedLoader() { + resource_metadata_.reset(new DriveResourceMetadata); + feed_loader_.reset(new DriveFeedLoader(resource_metadata_.get(), + drive_service_, + webapps_registry_, + cache_, + blocking_task_runner_)); + feed_loader_->AddObserver(this); +} + void DriveFileSystem::CheckForUpdates() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DVLOG(1) << "CheckForUpdates"; diff --git a/chrome/browser/chromeos/drive/drive_file_system.h b/chrome/browser/chromeos/drive/drive_file_system.h index 6ed1c5b..1526f72 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.h +++ b/chrome/browser/chromeos/drive/drive_file_system.h @@ -141,6 +141,7 @@ class DriveFileSystem : public DriveFileSystemInterface, const FilePath& file_content_path, const base::Closure& callback) OVERRIDE; virtual DriveFileSystemMetadata GetMetadata() const OVERRIDE; + virtual void Reload() OVERRIDE; // content::NotificationObserver implementation. virtual void Observe(int type, @@ -242,6 +243,10 @@ class DriveFileSystem : public DriveFileSystemInterface, // Struct used by UpdateEntryData. struct UpdateEntryParams; + // Initializes DriveResourceMetadta and DriveFeedLoader instances. This is a + // part of the initialization. + void InitializeResourceMetadtaAndFeedLoader(); + // Callback passed to |LoadFeedFromServer| from |Search| method. // |callback| is that should be run with data received from // |LoadFeedFromServer|. |callback| must not be null. diff --git a/chrome/browser/chromeos/drive/drive_file_system_interface.h b/chrome/browser/chromeos/drive/drive_file_system_interface.h index 867ed6b..4b115eb 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_interface.h +++ b/chrome/browser/chromeos/drive/drive_file_system_interface.h @@ -360,8 +360,12 @@ class DriveFileSystemInterface { const FilePath& file_content_path, const base::Closure& callback) = 0; - // Returns metadata of the file system. + // Returns miscellaneous metadata of the file system like the largest + // timestamp. Used in chrome:drive-internals. virtual DriveFileSystemMetadata GetMetadata() const = 0; + + // Reloads the file system feeds from the server. + virtual void Reload() = 0; }; } // namespace drive diff --git a/chrome/browser/chromeos/drive/drive_system_service.cc b/chrome/browser/chromeos/drive/drive_system_service.cc index 9a94977..c1db5a8 100644 --- a/chrome/browser/chromeos/drive/drive_system_service.cc +++ b/chrome/browser/chromeos/drive/drive_system_service.cc @@ -207,6 +207,18 @@ void DriveSystemService::AddBackDriveMountPoint( callback.Run(error == DRIVE_FILE_OK); } +void DriveSystemService::ReloadAndRemountFileSystem() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + RemoveDriveMountPoint(); + drive_service()->CancelAll(); + file_system_->Reload(); + + // Reload() is asynchronous. But we can add back the mount point right away + // because every operation waits until loading is complete. + AddDriveMountPoint(); +} + void DriveSystemService::AddDriveMountPoint() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/chrome/browser/chromeos/drive/drive_system_service.h b/chrome/browser/chromeos/drive/drive_system_service.h index 1af59bb..96b6fa6 100644 --- a/chrome/browser/chromeos/drive/drive_system_service.h +++ b/chrome/browser/chromeos/drive/drive_system_service.h @@ -58,6 +58,9 @@ class DriveSystemService : public ProfileKeyedService, void ClearCacheAndRemountFileSystem( const base::Callback<void(bool)>& callback); + // Reloads and remounts the file system. + void ReloadAndRemountFileSystem(); + // ProfileKeyedService override: virtual void Shutdown() OVERRIDE; diff --git a/chrome/browser/chromeos/drive/mock_drive_file_system.h b/chrome/browser/chromeos/drive/mock_drive_file_system.h index 2c6f39a..0b2c42a 100644 --- a/chrome/browser/chromeos/drive/mock_drive_file_system.h +++ b/chrome/browser/chromeos/drive/mock_drive_file_system.h @@ -104,6 +104,7 @@ class MockDriveFileSystem : public DriveFileSystemInterface { const FilePath& file_content_path, const base::Closure& callback) OVERRIDE {} MOCK_CONST_METHOD0(GetMetadata, DriveFileSystemMetadata()); + MOCK_METHOD0(Reload, void()); }; } // namespace drive |