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

Unified Diff: chrome/browser/services/gcm/gcm_profile_service.cc

Issue 286213003: Make GCMProfileService own GCMDriver, instead of deriving from it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 6 years, 7 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/services/gcm/gcm_profile_service.cc
diff --git a/chrome/browser/services/gcm/gcm_profile_service.cc b/chrome/browser/services/gcm/gcm_profile_service.cc
index a14ae00d55bc6f20cf433ab22ab119b7ee6385ae..39283d9f31fbc060d24e3db7cb7c7c464518735a 100644
--- a/chrome/browser/services/gcm/gcm_profile_service.cc
+++ b/chrome/browser/services/gcm/gcm_profile_service.cc
@@ -9,12 +9,14 @@
#include "base/prefs/pref_service.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/services/gcm/gcm_driver.h"
#include "chrome/browser/signin/profile_identity_provider.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
+#include "components/gcm_driver/gcm_client_factory.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/identity_provider.h"
@@ -73,43 +75,61 @@ void GCMProfileService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
-GCMProfileService::GCMProfileService(Profile* profile)
- : GCMDriver(scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
- SigninManagerFactory::GetForProfile(profile),
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
+GCMProfileService::GCMProfileService(
+ Profile* profile,
+ scoped_ptr<GCMClientFactory> gcm_client_factory)
+ : profile_(profile) {
+ DCHECK(!profile->IsOffTheRecord());
+
#if defined(OS_ANDROID)
- NULL))),
+ LoginUIService* login_ui_service = NULL;
#else
- LoginUIServiceFactory::GetForProfile(profile)))),
+ LoginUIService* login_ui_service =
+ LoginUIServiceFactory::GetForProfile(profile_);
#endif
- profile_(profile) {
- DCHECK(!profile->IsOffTheRecord());
+ driver_.reset(new GCMDriver(
+ gcm_client_factory.Pass(),
+ scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
+ SigninManagerFactory::GetForProfile(profile_),
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
+ login_ui_service)),
+ profile_->GetPath().Append(chrome::kGCMStoreDirname),
+ profile_->GetRequestContext()));
+}
+
+GCMProfileService::GCMProfileService() : profile_(NULL) {
}
GCMProfileService::~GCMProfileService() {
}
-void GCMProfileService::Shutdown() {
- ShutdownService();
+void GCMProfileService::AddAppHandler(const std::string& app_id,
+ GCMAppHandler* handler) {
+ if (driver_)
+ driver_->AddAppHandler(app_id, handler);
}
-std::string GCMProfileService::SignedInUserName() const {
- if (IsStarted())
- return identity_provider_->GetActiveUsername();
- return std::string();
+void GCMProfileService::RemoveAppHandler(const std::string& app_id) {
+ if (driver_)
+ driver_->RemoveAppHandler(app_id);
}
-bool GCMProfileService::ShouldStartAutomatically() const {
- return GetGCMEnabledState(profile_) == ALWAYS_ENABLED;
+void GCMProfileService::Register(const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ const GCMDriver::RegisterCallback& callback) {
+ if (driver_)
+ driver_->Register(app_id, sender_ids, callback);
}
-base::FilePath GCMProfileService::GetStorePath() const {
- return profile_->GetPath().Append(chrome::kGCMStoreDirname);
+void GCMProfileService::Shutdown() {
+ if (driver_) {
+ driver_->Shutdown();
+ driver_.reset();
+ }
}
-scoped_refptr<net::URLRequestContextGetter>
-GCMProfileService::GetURLRequestContextGetter() const {
- return profile_->GetRequestContext();
+void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
+ driver_.reset(driver);
}
} // namespace gcm
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.h ('k') | chrome/browser/services/gcm/gcm_profile_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698