Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: chrome/browser/google_apis/drive_notification_manager.cc

Issue 13891016: Merge ChromeOS and SyncFS XMPP Notification into one class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ChromeOS SigFault fix Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..497835e4e248d0523f57739d5667615b0d053357 100644
--- a/chrome/browser/google_apis/drive_notification_manager.cc
+++ b/chrome/browser/google_apis/drive_notification_manager.cc
@@ -15,13 +15,10 @@ 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.
RegisterDriveNotifications();
}
@@ -42,7 +39,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(
@@ -58,7 +60,6 @@ void DriveNotificationManager::OnIncomingInvalidation(
// completed. http://crbug.com/156843
ProfileSyncService* profile_sync_service =
ProfileSyncServiceFactory::GetForProfile(profile_);
- CHECK(profile_sync_service);
profile_sync_service->AcknowledgeInvalidation(
invalidation_map.begin()->first,
invalidation_map.begin()->second.ack_handle);
@@ -76,15 +77,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 +105,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

Powered by Google App Engine
This is Rietveld 408576698