diff options
author | calvinlo@chromium.org <calvinlo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-22 10:12:30 +0000 |
---|---|---|
committer | calvinlo@chromium.org <calvinlo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-22 10:12:30 +0000 |
commit | e33736c882c03383f0ba6f07ba3438a9944926e2 (patch) | |
tree | 4e822716fc9bc71d6ae26c5a86ae488fb25caab3 /chrome | |
parent | 8cc5ad4f39b5214789bd95566b80f1b398da4497 (diff) | |
download | chromium_src-e33736c882c03383f0ba6f07ba3438a9944926e2.zip chromium_src-e33736c882c03383f0ba6f07ba3438a9944926e2.tar.gz chromium_src-e33736c882c03383f0ba6f07ba3438a9944926e2.tar.bz2 |
Make DriveSystemService an observer of DriveNotificationManager so that it no longer has to handle registering for Drive XMPP notifications itself. This will also allow both SyncFileSystem and the ChromeOS Filemanager (and possibly more observers) to use XMPP notifications solving the problem from before where the same XMPP Invalidation ID was being registered twice.
Also removed polling code from SyncFS it's OKed to remove by both SyncFS and ChromeOS teams.
BUG=173339
Review URL: https://codereview.chromium.org/13891016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
8 files changed, 62 insertions, 216 deletions
diff --git a/chrome/browser/chromeos/drive/drive_system_service.cc b/chrome/browser/chromeos/drive/drive_system_service.cc index ae0d051..7dba08b 100644 --- a/chrome/browser/chromeos/drive/drive_system_service.cc +++ b/chrome/browser/chromeos/drive/drive_system_service.cc @@ -25,12 +25,12 @@ #include "chrome/browser/google_apis/auth_service.h" #include "chrome/browser/google_apis/drive_api_service.h" #include "chrome/browser/google_apis/drive_api_util.h" +#include "chrome/browser/google_apis/drive_notification_manager.h" +#include "chrome/browser/google_apis/drive_notification_manager_factory.h" #include "chrome/browser/google_apis/gdata_wapi_service.h" #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_dependency_manager.h" -#include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/pref_names.h" @@ -49,9 +49,6 @@ namespace { static const size_t kEventLogHistorySize = 100; -// The sync invalidation object ID for Google Drive. -const char kDriveInvalidationObjectId[] = "CHANGELOG"; - // Returns true if Drive is enabled for the given Profile. bool IsDriveEnabledForProfile(Profile* profile) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -106,7 +103,6 @@ DriveSystemService::DriveSystemService( DriveFileSystemInterface* test_file_system) : profile_(profile), drive_disabled_(false), - push_notification_registered_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool(); @@ -176,19 +172,10 @@ void DriveSystemService::Initialize() { void DriveSystemService::Shutdown() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ProfileSyncService* profile_sync_service = - profile_ ? ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; - if (profile_sync_service && push_notification_registered_) { - // TODO(kochi): Once DriveSystemService gets started / stopped at runtime, - // this ID needs to be unregistered *before* the handler is unregistered - // as ID persists across browser restarts. - if (!IsDriveEnabledForProfile(profile_)) { - profile_sync_service->UpdateRegisteredInvalidationIds( - this, syncer::ObjectIdSet()); - } - profile_sync_service->UnregisterInvalidationHandler(this); - push_notification_registered_ = false; - } + google_apis::DriveNotificationManager* drive_notification_manager = + google_apis::DriveNotificationManagerFactory::GetForProfile(profile_); + DCHECK(drive_notification_manager); + drive_notification_manager->RemoveObserver(this); RemoveDriveMountPoint(); } @@ -203,6 +190,10 @@ void DriveSystemService::RemoveObserver(DriveSystemServiceObserver* observer) { observers_.RemoveObserver(observer); } +void DriveSystemService::OnNotificationReceived() { + file_system_->CheckForUpdates(); +} + bool DriveSystemService::IsDriveEnabled() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -216,22 +207,6 @@ bool DriveSystemService::IsDriveEnabled() { return true; } -void DriveSystemService::OnInvalidatorStateChange( - syncer::InvalidatorState state) { - DVLOG(1) << "InvalidatorState changed to " << state; -} - -void DriveSystemService::OnIncomingInvalidation( - const syncer::ObjectIdInvalidationMap& invalidation_map) { - DCHECK_EQ(1U, invalidation_map.size()); - const invalidation::ObjectId object_id( - ipc::invalidation::ObjectSource::COSMO_CHANGELOG, - kDriveInvalidationObjectId); - DCHECK_EQ(1U, invalidation_map.count(object_id)); - - file_system_->CheckForUpdates(); -} - void DriveSystemService::ClearCacheAndRemountFileSystem( const base::Callback<void(bool)>& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -289,19 +264,6 @@ void DriveSystemService::ReloadAndRemountFileSystem() { AddDriveMountPoint(); } -bool DriveSystemService::PushNotificationEnabled() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(profile_); - - ProfileSyncService* profile_sync_service = - ProfileSyncServiceFactory::GetForProfile(profile_); - if (!profile_sync_service) - return false; - - return (profile_sync_service->GetInvalidatorState() == - syncer::INVALIDATIONS_ENABLED); -} - void DriveSystemService::AddDriveMountPoint() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!file_system_proxy_.get()); @@ -379,18 +341,10 @@ void DriveSystemService::InitializeAfterResourceMetadataInitialized( cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_TMP_DOWNLOADS)); // Register for Google Drive invalidation notifications. - ProfileSyncService* profile_sync_service = - profile_ ? ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; - if (profile_sync_service) { - DCHECK(!push_notification_registered_); - profile_sync_service->RegisterInvalidationHandler(this); - syncer::ObjectIdSet ids; - ids.insert(invalidation::ObjectId( - ipc::invalidation::ObjectSource::COSMO_CHANGELOG, - kDriveInvalidationObjectId)); - profile_sync_service->UpdateRegisteredInvalidationIds(this, ids); - push_notification_registered_ = true; - } + google_apis::DriveNotificationManager* drive_notification_manager = + google_apis::DriveNotificationManagerFactory::GetForProfile(profile_); + DCHECK(drive_notification_manager); + drive_notification_manager->AddObserver(this); AddDriveMountPoint(); } @@ -459,7 +413,7 @@ void DriveSystemServiceFactory::SetFactoryForTest( DriveSystemServiceFactory::DriveSystemServiceFactory() : ProfileKeyedServiceFactory("DriveSystemService", ProfileDependencyManager::GetInstance()) { - DependsOn(ProfileSyncServiceFactory::GetInstance()); + DependsOn(google_apis::DriveNotificationManagerFactory::GetInstance()); DependsOn(DownloadServiceFactory::GetInstance()); } diff --git a/chrome/browser/chromeos/drive/drive_system_service.h b/chrome/browser/chromeos/drive/drive_system_service.h index 0ad2f05..f408fc9 100644 --- a/chrome/browser/chromeos/drive/drive_system_service.h +++ b/chrome/browser/chromeos/drive/drive_system_service.h @@ -16,9 +16,9 @@ #include "chrome/browser/chromeos/drive/drive_file_error.h" #include "chrome/browser/chromeos/drive/drive_file_system_util.h" #include "chrome/browser/chromeos/drive/drive_scheduler.h" +#include "chrome/browser/google_apis/drive_notification_observer.h" #include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/browser/profiles/profile_keyed_service_factory.h" -#include "sync/notifier/invalidation_handler.h" namespace base { class FilePath; @@ -65,8 +65,9 @@ class DriveSystemServiceObserver { // The class is essentially a container that manages lifetime of the objects // that are used to run the Drive system. The DriveSystemService object is // created per-profile. -class DriveSystemService : public ProfileKeyedService, - public syncer::InvalidationHandler { +class DriveSystemService + : public ProfileKeyedService, + public google_apis::DriveNotificationObserver { public: // test_drive_service, test_cache_root and test_file_system are used by tests // to inject customized instances. @@ -88,6 +89,9 @@ class DriveSystemService : public ProfileKeyedService, void AddObserver(DriveSystemServiceObserver* observer); void RemoveObserver(DriveSystemServiceObserver* observer); + // google_apis::DriveNotificationObserver implementation. + virtual void OnNotificationReceived() OVERRIDE; + google_apis::DriveServiceInterface* drive_service() { return drive_service_.get(); } @@ -110,16 +114,7 @@ class DriveSystemService : public ProfileKeyedService, // Reloads and remounts the file system. void ReloadAndRemountFileSystem(); - // Returns true if the push notification is enabled. - bool PushNotificationEnabled(); - private: - // syncer::InvalidationHandler implementation. - virtual void OnInvalidatorStateChange( - syncer::InvalidatorState state) OVERRIDE; - virtual void OnIncomingInvalidation( - const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; - // Returns true if Drive is enabled. // Must be called on UI thread. bool IsDriveEnabled(); @@ -159,9 +154,6 @@ class DriveSystemService : public ProfileKeyedService, // True if Drive is disabled due to initialization errors. bool drive_disabled_; - // True once this is registered to listen to the Drive updates. - bool push_notification_registered_; - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; scoped_ptr<EventLogger> event_logger_; scoped_ptr<DriveCache, util::DestroyHelper> cache_; diff --git a/chrome/browser/google_apis/drive_notification_manager.cc b/chrome/browser/google_apis/drive_notification_manager.cc index 7ce0235..a4d0149 100644 --- a/chrome/browser/google_apis/drive_notification_manager.cc +++ b/chrome/browser/google_apis/drive_notification_manager.cc @@ -15,13 +15,14 @@ namespace google_apis { // The sync invalidation object ID for Google Drive. const char kDriveInvalidationObjectId[] = "CHANGELOG"; -// TODO(calvinlo): Constants for polling to go here. - DriveNotificationManager::DriveNotificationManager(Profile* profile) : profile_(profile), push_notification_registered_(false), push_notification_enabled_(false) { - // TODO(calvinlo): Initialize member variables for polling here. + ProfileSyncService* profile_sync_service_ = + ProfileSyncServiceFactory::GetForProfile(profile_); + CHECK(profile_sync_service_); + RegisterDriveNotifications(); } @@ -42,7 +43,12 @@ void DriveNotificationManager::Shutdown() { void DriveNotificationManager::OnInvalidatorStateChange( syncer::InvalidatorState state) { - SetPushNotificationEnabled(state); + push_notification_enabled_ = (state == syncer::INVALIDATIONS_ENABLED); + if (push_notification_enabled_) { + DVLOG(1) << "XMPP Notifications enabled"; + } else { + DVLOG(1) << "XMPP Notifications disabled (state=" << state << ")"; + } } void DriveNotificationManager::OnIncomingInvalidation( @@ -56,10 +62,7 @@ void DriveNotificationManager::OnIncomingInvalidation( // TODO(dcheng): Only acknowledge the invalidation once the fetch has // completed. http://crbug.com/156843 - ProfileSyncService* profile_sync_service = - ProfileSyncServiceFactory::GetForProfile(profile_); - CHECK(profile_sync_service); - profile_sync_service->AcknowledgeInvalidation( + profile_sync_service_->AcknowledgeInvalidation( invalidation_map.begin()->first, invalidation_map.begin()->second.ack_handle); @@ -76,15 +79,20 @@ void DriveNotificationManager::RemoveObserver( observers_.RemoveObserver(observer); } +bool DriveNotificationManager::IsPushNotificationEnabled() { + return push_notification_enabled_; +} + void DriveNotificationManager::NotifyObserversToUpdate() { - FOR_EACH_OBSERVER(DriveNotificationObserver, observers_, CheckForUpdates()); + FOR_EACH_OBSERVER(DriveNotificationObserver, observers_, + OnNotificationReceived()); } // Register for Google Drive invalidation notifications through XMPP. void DriveNotificationManager::RegisterDriveNotifications() { // Push notification registration might have already occurred if called from // a different extension. - if (!IsDriveNotificationSupported() || push_notification_registered_) + if (push_notification_registered_) return; ProfileSyncService* profile_sync_service = @@ -99,33 +107,7 @@ void DriveNotificationManager::RegisterDriveNotifications() { kDriveInvalidationObjectId)); profile_sync_service->UpdateRegisteredInvalidationIds(this, ids); push_notification_registered_ = true; - SetPushNotificationEnabled(profile_sync_service->GetInvalidatorState()); -} - -// TODO(calvinlo): Remove when all patches for http://crbug.com/173339 done. -bool DriveNotificationManager::IsDriveNotificationSupported() { - // TODO(calvinlo): A invalidation ID can only be registered to one handler. - // Therefore ChromeOS and SyncFS cannot both use XMPP notifications until - // (http://crbug.com/173339) is completed. - // For now, disable XMPP notifications for SyncFC on ChromeOS to guarantee - // that ChromeOS's file manager can register itself to the invalidationID. - -#if defined(OS_CHROMEOS) - return false; -#else - return true; -#endif -} - -void DriveNotificationManager::SetPushNotificationEnabled( - syncer::InvalidatorState state) { - DVLOG(1) << "SetPushNotificationEnabled() with state=" << state; - push_notification_enabled_ = (state == syncer::INVALIDATIONS_ENABLED); - if (!push_notification_enabled_) - return; - - // Push notifications are enabled so reset polling timer. - //UpdatePollingDelay(kPollingDelaySecondsWithNotification); + OnInvalidatorStateChange(profile_sync_service->GetInvalidatorState()); } } // namespace google_apis diff --git a/chrome/browser/google_apis/drive_notification_manager.h b/chrome/browser/google_apis/drive_notification_manager.h index 16905db..3713ae8 100644 --- a/chrome/browser/google_apis/drive_notification_manager.h +++ b/chrome/browser/google_apis/drive_notification_manager.h @@ -11,15 +11,14 @@ #include "sync/notifier/invalidation_handler.h" class Profile; +class ProfileSyncService; namespace google_apis { // Informs observers when they should check Google Drive for updates. // Conditions under which updates should be searched: // 1. XMPP invalidation is received from Google Drive. -// TODO(calvinlo): Implement public syncer::InvalidationHandler interface. // 2. Polling timer counts down. -// TODO(calvinlo): Also add in backup timer. class DriveNotificationManager : public ProfileKeyedService, public syncer::InvalidationHandler { @@ -39,25 +38,22 @@ class DriveNotificationManager void AddObserver(DriveNotificationObserver* observer); void RemoveObserver(DriveNotificationObserver* observer); + // True when XMPP notifications registered and enabled. False otherwise. + bool IsPushNotificationEnabled(); + private: void NotifyObserversToUpdate(); - - // XMPP notification related methods. void RegisterDriveNotifications(); - bool IsDriveNotificationSupported(); - void SetPushNotificationEnabled(syncer::InvalidatorState state); Profile* profile_; + ProfileSyncService* profile_sync_service_; ObserverList<DriveNotificationObserver> observers_; - // XMPP notification related variables. // True when Drive File Sync Service is registered for Drive notifications. bool push_notification_registered_; // True once the first drive notification is received with OK state. bool push_notification_enabled_; - // TODO(calvinlo): Polling variables to go here. - DISALLOW_COPY_AND_ASSIGN(DriveNotificationManager); }; diff --git a/chrome/browser/google_apis/drive_notification_observer.h b/chrome/browser/google_apis/drive_notification_observer.h index 0d40c7f..94df1d1 100644 --- a/chrome/browser/google_apis/drive_notification_observer.h +++ b/chrome/browser/google_apis/drive_notification_observer.h @@ -11,8 +11,8 @@ namespace google_apis { // updates. class DriveNotificationObserver { public: - // Called when an observer should check Google Drive for updates. - virtual void CheckForUpdates() = 0; + // Called when a notification from Google Drive is received. + virtual void OnNotificationReceived() = 0; protected: virtual ~DriveNotificationObserver() {} diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_file_sync_service.cc index 370bedc7..a37cb78 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc @@ -46,14 +46,6 @@ const base::FilePath::CharType kTempDirName[] = FILE_PATH_LITERAL("tmp"); const base::FilePath::CharType kSyncFileSystemDir[] = FILE_PATH_LITERAL("Sync FileSystem"); -// Incremental sync polling interval. -// TODO(calvinlo): Improve polling algorithm dependent on whether push -// notifications are on or off. -const int64 kMinimumPollingDelaySeconds = 5; -const int64 kMaximumPollingDelaySeconds = 10 * 60; // 10 min -const int64 kPollingDelaySecondsWithNotification = 4 * 60 * 60; // 4 hr -const double kDelayMultiplier = 1.6; - bool CreateTemporaryFile(const base::FilePath& dir_path, base::FilePath* temp_file) { return file_util::CreateDirectory(dir_path) && @@ -275,7 +267,6 @@ DriveFileSyncService::DriveFileSyncService(Profile* profile) state_(REMOTE_SERVICE_OK), sync_enabled_(true), largest_fetched_changestamp_(0), - polling_delay_seconds_(kMinimumPollingDelaySeconds), may_have_unfetched_changes_(false), remote_change_processor_(NULL), conflict_resolution_(kDefaultPolicy), @@ -568,11 +559,6 @@ void DriveFileSyncService::SetSyncEnabled(bool enabled) { FOR_EACH_OBSERVER( Observer, service_observers_, OnRemoteServiceStateUpdated(GetCurrentState(), status_message)); - - if (GetCurrentState() == REMOTE_SERVICE_OK) { - UpdatePollingDelay(kMinimumPollingDelaySeconds); - SchedulePolling(); - } } SyncStatusCode DriveFileSyncService::SetConflictResolutionPolicy( @@ -643,7 +629,6 @@ void DriveFileSyncService::OnAuthenticated() { FOR_EACH_OBSERVER( Observer, service_observers_, OnRemoteServiceStateUpdated(GetCurrentState(), "Authenticated")); - UpdatePollingDelay(kMinimumPollingDelaySeconds); may_have_unfetched_changes_ = true; MaybeStartFetchChanges(); @@ -659,7 +644,6 @@ void DriveFileSyncService::OnNetworkConnected() { FOR_EACH_OBSERVER( Observer, service_observers_, OnRemoteServiceStateUpdated(GetCurrentState(), "Network connected")); - UpdatePollingDelay(kMinimumPollingDelaySeconds); may_have_unfetched_changes_ = true; MaybeStartFetchChanges(); @@ -676,7 +660,6 @@ DriveFileSyncService::DriveFileSyncService( state_(REMOTE_SERVICE_OK), sync_enabled_(true), largest_fetched_changestamp_(0), - polling_delay_seconds_(-1), may_have_unfetched_changes_(false), remote_change_processor_(NULL), conflict_resolution_(kDefaultPolicy), @@ -727,10 +710,6 @@ void DriveFileSyncService::NotifyTaskDone(SyncStatusCode status, RemoteServiceState old_state = GetCurrentState(); UpdateServiceState(); - // Reset the polling delay. This will adjust the polling timer - // based on the current service state. - UpdatePollingDelay(polling_delay_seconds_); - // Notify remote sync service state if the state has been changed. if (!token_->description().empty() || old_state != GetCurrentState()) { FOR_EACH_OBSERVER( @@ -753,8 +732,6 @@ void DriveFileSyncService::NotifyTaskDone(SyncStatusCode status, MaybeStartFetchChanges(); - SchedulePolling(); - // Notify observer of the update of |pending_changes_|. FOR_EACH_OBSERVER(Observer, service_observers_, OnRemoteChangeQueueUpdated(pending_changes_.size())); @@ -1024,7 +1001,8 @@ void DriveFileSyncService::DidGetDirectoryContentForBatchSync( metadata_store_->MoveBatchSyncOriginToIncremental(origin); } - CheckForUpdates(); + may_have_unfetched_changes_ = true; + MaybeStartFetchChanges(); NotifyTaskDone(SYNC_STATUS_OK, token.Pass()); } @@ -2107,7 +2085,7 @@ void DriveFileSyncService::MaybeStartFetchChanges() { } } -void DriveFileSyncService::CheckForUpdates() { +void DriveFileSyncService::OnNotificationReceived() { // TODO(calvinlo): Try to eliminate may_have_unfetched_changes_ variable. may_have_unfetched_changes_ = true; MaybeStartFetchChanges(); @@ -2197,15 +2175,6 @@ void DriveFileSyncService::DidFetchChangesForIncrementalSync( if (!changes->entries().empty()) largest_fetched_changestamp_ = changes->entries().back()->changestamp(); - if (has_new_changes) { - UpdatePollingDelay(kMinimumPollingDelaySeconds); - } else { - // If the change_queue_ was not updated, update the polling delay to wait - // longer. - UpdatePollingDelay(static_cast<int64>( - kDelayMultiplier * polling_delay_seconds_)); - } - NotifyTaskDone(SYNC_STATUS_OK, token.Pass()); } @@ -2237,49 +2206,6 @@ bool DriveFileSyncService::GetOriginForEntry( return false; } -void DriveFileSyncService::SchedulePolling() { - if (polling_timer_.IsRunning() || - polling_delay_seconds_ < 0 || - GetCurrentState() == REMOTE_SERVICE_DISABLED) - return; - - DVLOG(1) << "Polling scheduled" - << " (delay:" << polling_delay_seconds_ << "s)"; - - polling_timer_.Start( - FROM_HERE, base::TimeDelta::FromSeconds(polling_delay_seconds_), - base::Bind(&DriveFileSyncService::OnPollingTimerFired, AsWeakPtr())); -} - -void DriveFileSyncService::OnPollingTimerFired() { - may_have_unfetched_changes_ = true; - MaybeStartFetchChanges(); -} - -void DriveFileSyncService::UpdatePollingDelay(int64 new_delay_sec) { - // polling_delay_seconds_ made negative to disable polling for testing. - if (polling_delay_seconds_ < 0) - return; - - if (state_ == REMOTE_SERVICE_TEMPORARY_UNAVAILABLE) { - // If the service state is TEMPORARY_UNAVAILABLE, poll the service - // with a modest duration (but more frequently than - // kPollingDelaySecondsWithNotification) so that we have a mild chance - // to recover the state. - polling_delay_seconds_ = kMaximumPollingDelaySeconds; - polling_timer_.Stop(); - return; - } - - int64 old_delay = polling_delay_seconds_; - - // Push notifications off. - polling_delay_seconds_ = std::min(new_delay_sec, kMaximumPollingDelaySeconds); - - if (polling_delay_seconds_ < old_delay) - polling_timer_.Stop(); -} - void DriveFileSyncService::NotifyObserversFileStatusChanged( const FileSystemURL& url, SyncFileStatus sync_status, diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.h b/chrome/browser/sync_file_system/drive_file_sync_service.h index d26ee11..ce15d06 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.h +++ b/chrome/browser/sync_file_system/drive_file_sync_service.h @@ -11,12 +11,11 @@ #include <string> #include <vector> -#include "base/callback_forward.h" +#include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/threading/non_thread_safe.h" -#include "base/timer.h" #include "chrome/browser/google_apis/drive_notification_observer.h" #include "chrome/browser/sync_file_system/drive_file_sync_client_interface.h" #include "chrome/browser/sync_file_system/drive_metadata_store.h" @@ -115,7 +114,7 @@ class DriveFileSyncService virtual void OnNetworkConnected() OVERRIDE; // google_apis::DriveNotificationObserver implementation. - virtual void CheckForUpdates() OVERRIDE; + virtual void OnNotificationReceived() OVERRIDE; private: friend class DriveFileSyncServiceMockTest; @@ -428,9 +427,6 @@ class DriveFileSyncService google_apis::GDataErrorCode error, scoped_ptr<google_apis::ResourceList> changes); bool GetOriginForEntry(const google_apis::ResourceEntry& entry, GURL* origin); - void SchedulePolling(); - void OnPollingTimerFired(); - void UpdatePollingDelay(int64 new_delay_sec); void NotifyObserversFileStatusChanged(const fileapi::FileSystemURL& url, SyncFileStatus sync_status, SyncAction action_taken, @@ -492,11 +488,6 @@ class DriveFileSyncService // NotifyTaskDone when the task finished. scoped_ptr<TaskToken> token_; - // Timer to trigger fetching changes for incremental sync. - base::OneShotTimer<DriveFileSyncService> polling_timer_; - // If polling_delay_seconds_ is negative (<0) the timer won't start. - int64 polling_delay_seconds_; - // Is set to true when there's a fair possibility that we have some // remote changes that haven't been fetched yet. // diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc index 4b4d011..cc23d8c 100644 --- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc @@ -24,6 +24,8 @@ #include "chrome/browser/google_apis/auth_service.h" #include "chrome/browser/google_apis/drive_api_parser.h" #include "chrome/browser/google_apis/drive_api_util.h" +#include "chrome/browser/google_apis/drive_notification_manager.h" +#include "chrome/browser/google_apis/drive_notification_manager_factory.h" #include "chrome/browser/google_apis/drive_service_interface.h" #include "chrome/browser/google_apis/drive_switches.h" #include "chrome/browser/google_apis/gdata_errorcode.h" @@ -514,13 +516,16 @@ void DriveInternalsWebUIHandler::UpdateDeltaUpdateStatusSection() { void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate( const drive::DriveFileSystemMetadata& metadata) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - drive::DriveSystemService* const system_service = GetSystemService(); - if (!system_service) + Profile* profile = Profile::FromWebUI(web_ui()); + google_apis::DriveNotificationManager* drive_notification_manager = + google_apis::DriveNotificationManagerFactory::GetForProfile(profile); + if (!drive_notification_manager) return; base::DictionaryValue delta_update_status; - delta_update_status.SetBoolean("push-notification-enabled", - system_service->PushNotificationEnabled()); + delta_update_status.SetBoolean( + "push-notification-enabled", + drive_notification_manager->IsPushNotificationEnabled()); delta_update_status.SetString( "last-update-check-time", google_apis::util::FormatTimeAsStringLocaltime( |