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

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

Issue 23514025: Use GetForBrowserContext instead of GetForProfile for DriveNotificationManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & resolve conflict Created 7 years, 3 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/drive/drive_notification_manager.cc
diff --git a/chrome/browser/drive/drive_notification_manager.cc b/chrome/browser/drive/drive_notification_manager.cc
index ae94124e7bcc6545caa00099a9bbb232b7fd72ff..198c0148ecb35690202e1c99743bd46bd230c328 100644
--- a/chrome/browser/drive/drive_notification_manager.cc
+++ b/chrome/browser/drive/drive_notification_manager.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/drive/drive_notification_observer.h"
#include "chrome/browser/invalidation/invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
#include "google/cacheinvalidation/types.pb.h"
namespace drive {
@@ -27,13 +26,15 @@ const char kDriveInvalidationObjectId[] = "CHANGELOG";
} // namespace
-DriveNotificationManager::DriveNotificationManager(Profile* profile)
- : profile_(profile),
+DriveNotificationManager::DriveNotificationManager(
+ invalidation::InvalidationService* invalidation_service)
+ : invalidation_service_(invalidation_service),
push_notification_registered_(false),
push_notification_enabled_(false),
observers_notified_(false),
polling_timer_(true /* retain_user_task */, false /* is_repeating */),
weak_ptr_factory_(this) {
+ DCHECK(invalidation_service_);
RegisterDriveNotifications();
RestartPollingTimer();
}
@@ -42,16 +43,14 @@ DriveNotificationManager::~DriveNotificationManager() {}
void DriveNotificationManager::Shutdown() {
// Unregister for Drive notifications.
- invalidation::InvalidationService* invalidation_service =
- invalidation::InvalidationServiceFactory::GetForProfile(profile_);
- if (!invalidation_service || !push_notification_registered_) {
+ if (!invalidation_service_ || !push_notification_registered_)
return;
- }
// We unregister the handler without updating unregistering our IDs on
// purpose. See the class comment on the InvalidationService interface for
// more information.
- invalidation_service->UnregisterInvalidationHandler(this);
+ invalidation_service_->UnregisterInvalidationHandler(this);
+ invalidation_service_ = NULL;
}
void DriveNotificationManager::OnInvalidatorStateChange(
@@ -77,10 +76,8 @@ void DriveNotificationManager::OnIncomingInvalidation(
// TODO(dcheng): Only acknowledge the invalidation once the fetch has
// completed. http://crbug.com/156843
- invalidation::InvalidationService* invalidation_service =
- invalidation::InvalidationServiceFactory::GetForProfile(profile_);
- DCHECK(invalidation_service);
- invalidation_service->AcknowledgeInvalidation(
+ DCHECK(invalidation_service_);
+ invalidation_service_->AcknowledgeInvalidation(
invalidation_map.begin()->first,
invalidation_map.begin()->second.ack_handle);
@@ -130,19 +127,17 @@ void DriveNotificationManager::NotifyObserversToUpdate(
void DriveNotificationManager::RegisterDriveNotifications() {
DCHECK(!push_notification_enabled_);
- invalidation::InvalidationService* invalidation_service =
- invalidation::InvalidationServiceFactory::GetForProfile(profile_);
- if (!invalidation_service)
+ if (!invalidation_service_)
return;
- invalidation_service->RegisterInvalidationHandler(this);
+ invalidation_service_->RegisterInvalidationHandler(this);
syncer::ObjectIdSet ids;
ids.insert(invalidation::ObjectId(
ipc::invalidation::ObjectSource::COSMO_CHANGELOG,
kDriveInvalidationObjectId));
- invalidation_service->UpdateRegisteredInvalidationIds(this, ids);
+ invalidation_service_->UpdateRegisteredInvalidationIds(this, ids);
push_notification_registered_ = true;
- OnInvalidatorStateChange(invalidation_service->GetInvalidatorState());
+ OnInvalidatorStateChange(invalidation_service_->GetInvalidatorState());
UMA_HISTOGRAM_BOOLEAN("Drive.PushNotificationRegistered",
push_notification_registered_);
« no previous file with comments | « chrome/browser/drive/drive_notification_manager.h ('k') | chrome/browser/drive/drive_notification_manager_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698