| Index: chrome/browser/google_apis/drive_notification_manager.cc
|
| diff --git a/chrome/browser/google_apis/drive_notification_manager.cc b/chrome/browser/google_apis/drive_notification_manager.cc
|
| index 7ce0235d8a3a258e147aa208dd81bdd0c21bd058..5b3eaeedbdccd391fecf987ec63263724af31e19 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,6 +79,10 @@ void DriveNotificationManager::RemoveObserver(
|
| observers_.RemoveObserver(observer);
|
| }
|
|
|
| +bool DriveNotificationManager::IsPushNotificationEnabled() {
|
| + return push_notification_enabled_;
|
| +}
|
| +
|
| void DriveNotificationManager::NotifyObserversToUpdate() {
|
| FOR_EACH_OBSERVER(DriveNotificationObserver, observers_, CheckForUpdates());
|
| }
|
| @@ -84,7 +91,7 @@ void DriveNotificationManager::NotifyObserversToUpdate() {
|
| 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 +106,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
|
|
|