diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-16 01:41:20 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-16 01:41:20 +0000 |
commit | e434265e3ccf1e14699a7465c9e2d39efa775704 (patch) | |
tree | 782869d47ed1f70b5950fe86f680beca72d21bc0 | |
parent | 23c354c243ca9f4d9f26e0f12d76621c3624e1d0 (diff) | |
download | chromium_src-e434265e3ccf1e14699a7465c9e2d39efa775704.zip chromium_src-e434265e3ccf1e14699a7465c9e2d39efa775704.tar.gz chromium_src-e434265e3ccf1e14699a7465c9e2d39efa775704.tar.bz2 |
drive: Stop calling StartPolling() from FileBrowserEventRouter and elsewhere
The polling code was added before the XMPP-based notification was introduced
and no longer necessary.
BUG=231198
TEST=Open Drive in Files.app; open drive.google.com and add a new document; Confirm that the new document shows up in Files.app in seconds.
Review URL: https://codereview.chromium.org/14042004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194274 0039d316-1c4b-4281-b951-d872f2087c98
9 files changed, 5 insertions, 60 deletions
diff --git a/chrome/browser/chromeos/drive/drive_file_system.cc b/chrome/browser/chromeos/drive/drive_file_system.cc index 13d0cc3..fcf601d 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.cc +++ b/chrome/browser/chromeos/drive/drive_file_system.cc @@ -345,13 +345,6 @@ void DriveFileSystem::StartPolling() { } void DriveFileSystem::StopPolling() { - // If unmount request comes from filesystem side, this method may be called - // twice. First is just after unmounting on filesystem, second is after - // unmounting on filemanager on JS. In other words, if this is called from - // DriveSystemService::RemoveDriveMountPoint(), this will be called again from - // FileManagerEventRouter::HandleRemoteUpdateRequestOnUIThread(). - // We choose to stopping updates asynchronous without waiting for filemanager, - // rather than waiting for completion of unmounting on filemanager. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (update_timer_.IsRunning()) update_timer_.Stop(); diff --git a/chrome/browser/chromeos/drive/drive_file_system.h b/chrome/browser/chromeos/drive/drive_file_system.h index 48c3722..4e953e4 100644 --- a/chrome/browser/chromeos/drive/drive_file_system.h +++ b/chrome/browser/chromeos/drive/drive_file_system.h @@ -68,8 +68,6 @@ class DriveFileSystem : public DriveFileSystemInterface, virtual void AddObserver(DriveFileSystemObserver* observer) OVERRIDE; virtual void RemoveObserver(DriveFileSystemObserver* observer) OVERRIDE; virtual void StartInitialFeedFetch() OVERRIDE; - virtual void StartPolling() OVERRIDE; - virtual void StopPolling() OVERRIDE; virtual void SetPushNotificationEnabled(bool enabled) OVERRIDE; virtual void NotifyFileSystemMounted() OVERRIDE; virtual void NotifyFileSystemToBeUnmounted() OVERRIDE; @@ -170,6 +168,11 @@ class DriveFileSystem : public DriveFileSystemInterface, // Struct used for AddUploadedFile. struct AddUploadedFileParams; + // Starts and stops periodic polling. + // TODO(satorux): Remove them. crbug.com/231202 + void StartPolling(); + void StopPolling(); + // Used to implement Reload(). void ReloadAfterReset(); diff --git a/chrome/browser/chromeos/drive/drive_file_system_interface.h b/chrome/browser/chromeos/drive/drive_file_system_interface.h index c3df669..53709f1 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_interface.h +++ b/chrome/browser/chromeos/drive/drive_file_system_interface.h @@ -152,10 +152,6 @@ class DriveFileSystemInterface { // Starts initial feed fetch from the server. virtual void StartInitialFeedFetch() = 0; - // Starts and stops periodic polling. - virtual void StartPolling() = 0; - virtual void StopPolling() = 0; - // Sets the availability of push notification when its status is changed. virtual void SetPushNotificationEnabled(bool enabled) = 0; diff --git a/chrome/browser/chromeos/drive/drive_system_service.cc b/chrome/browser/chromeos/drive/drive_system_service.cc index 7f5e024..5dee768 100644 --- a/chrome/browser/chromeos/drive/drive_system_service.cc +++ b/chrome/browser/chromeos/drive/drive_system_service.cc @@ -305,7 +305,6 @@ void DriveSystemService::RemoveDriveMountPoint() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); file_system_->NotifyFileSystemToBeUnmounted(); - file_system_->StopPolling(); fileapi::ExternalMountPoints* mount_points = BrowserContext::GetMountPoints(profile_); diff --git a/chrome/browser/chromeos/drive/fake_drive_file_system.cc b/chrome/browser/chromeos/drive/fake_drive_file_system.cc index 0f3b073..458c112 100644 --- a/chrome/browser/chromeos/drive/fake_drive_file_system.cc +++ b/chrome/browser/chromeos/drive/fake_drive_file_system.cc @@ -46,14 +46,6 @@ void FakeDriveFileSystem::StartInitialFeedFetch() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); } -void FakeDriveFileSystem::StartPolling() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); -} - -void FakeDriveFileSystem::StopPolling() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); -} - void FakeDriveFileSystem::SetPushNotificationEnabled(bool enabled) { } diff --git a/chrome/browser/chromeos/drive/fake_drive_file_system.h b/chrome/browser/chromeos/drive/fake_drive_file_system.h index d05fda6..c9b4e52 100644 --- a/chrome/browser/chromeos/drive/fake_drive_file_system.h +++ b/chrome/browser/chromeos/drive/fake_drive_file_system.h @@ -46,8 +46,6 @@ class FakeDriveFileSystem : public DriveFileSystemInterface { virtual void AddObserver(DriveFileSystemObserver* observer) OVERRIDE; virtual void RemoveObserver(DriveFileSystemObserver* observer) OVERRIDE; virtual void StartInitialFeedFetch() OVERRIDE; - virtual void StartPolling() OVERRIDE; - virtual void StopPolling() OVERRIDE; virtual void SetPushNotificationEnabled(bool enabled) OVERRIDE; virtual void NotifyFileSystemMounted() OVERRIDE; virtual void NotifyFileSystemToBeUnmounted() OVERRIDE; diff --git a/chrome/browser/chromeos/drive/mock_drive_file_system.h b/chrome/browser/chromeos/drive/mock_drive_file_system.h index 040250f..af55820 100644 --- a/chrome/browser/chromeos/drive/mock_drive_file_system.h +++ b/chrome/browser/chromeos/drive/mock_drive_file_system.h @@ -26,8 +26,6 @@ class MockDriveFileSystem : public DriveFileSystemInterface { MOCK_METHOD1(RemoveObserver, void(DriveFileSystemObserver* observer)); MOCK_METHOD0(StartInitialFeedFetch, void()); - MOCK_METHOD0(StartPolling, void()); - MOCK_METHOD0(StopPolling, void()); MOCK_METHOD1(SetPushNotificationEnabled, void(bool)); MOCK_METHOD0(NotifyFileSystemMounted, void()); MOCK_METHOD0(NotifyFileSystemToBeUnmounted, void()); diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc index f51a049..8a1c14c 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.cc @@ -253,7 +253,6 @@ FileManagerEventRouter::FileManagerEventRouter( notifications_(new FileManagerNotifications(profile)), pref_change_registrar_(new PrefChangeRegistrar), profile_(profile), - num_remote_update_requests_(0), shift_pressed_(false) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -366,7 +365,6 @@ void FileManagerEventRouter::AddFileWatch( if (drive::util::GetSpecialRemoteRootPath().IsParent(watch_path)) { watch_path = drive::util::ExtractDrivePath(watch_path); is_remote_watch = true; - HandleRemoteUpdateRequestOnUIThread(true /* start */); } WatcherMap::iterator iter = file_watchers_.find(watch_path); @@ -397,7 +395,6 @@ void FileManagerEventRouter::RemoveFileWatch( // their change notifications. if (drive::util::GetSpecialRemoteRootPath().IsParent(watch_path)) { watch_path = drive::util::ExtractDrivePath(watch_path); - HandleRemoteUpdateRequestOnUIThread(false /* start */); } WatcherMap::iterator iter = file_watchers_.find(watch_path); if (iter == file_watchers_.end()) @@ -433,27 +430,6 @@ void FileManagerEventRouter::MountDrive( callback.Run(); } -void FileManagerEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - drive::DriveFileSystemInterface* file_system = GetRemoteFileSystem(); - // |file_system| is NULL if Drive is disabled. - if (!file_system) - return; - - if (start) { - file_system->CheckForUpdates(); - if (num_remote_update_requests_ == 0) - file_system->StartPolling(); - ++num_remote_update_requests_; - } else { - DCHECK_LE(1, num_remote_update_requests_); - --num_remote_update_requests_; - if (num_remote_update_requests_ == 0) - file_system->StopPolling(); - } -} - void FileManagerEventRouter::OnDiskEvent( DiskMountManager::DiskEvent event, const DiskMountManager::Disk* disk) { diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.h b/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.h index 993e770..9a5b327 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.h +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_event_router.h @@ -209,13 +209,6 @@ class FileManagerEventRouter // Returns the DriveFileSystem for the current profile. drive::DriveFileSystemInterface* GetRemoteFileSystem() const; - // Handles requests to start and stop periodic updates on remote file system. - // When |start| is set to true, this function starts periodic updates only if - // it is not yet started; when |start| is set to false, this function stops - // periodic updates only if the number of outstanding update requests reaches - // zero. - void HandleRemoteUpdateRequestOnUIThread(bool start); - base::WeakPtrFactory<FileManagerEventRouter> weak_factory_; base::FilePathWatcher::Callback file_watcher_callback_; WatcherMap file_watchers_; @@ -224,9 +217,6 @@ class FileManagerEventRouter scoped_ptr<SuspendStateDelegate> suspend_state_delegate_; Profile* profile_; - // Number of active update requests on the remote file system. - int num_remote_update_requests_; - // Event router behavior depends on shift modifier status. This is designed // for power users. bool shift_pressed_; |