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

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: Fix trybots 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..b681a986d25b7155993ff363e9bf9664e52c34c6 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"
@@ -74,42 +76,38 @@ void GCMProfileService::RegisterProfilePrefs(
}
GCMProfileService::GCMProfileService(Profile* profile)
- : GCMDriver(scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
- SigninManagerFactory::GetForProfile(profile),
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
-#if defined(OS_ANDROID)
- NULL))),
-#else
- LoginUIServiceFactory::GetForProfile(profile)))),
-#endif
- profile_(profile) {
+ : profile_(profile) {
DCHECK(!profile->IsOffTheRecord());
}
GCMProfileService::~GCMProfileService() {
}
-void GCMProfileService::Shutdown() {
- ShutdownService();
-}
+void GCMProfileService::Initialize(
+ scoped_ptr<GCMClientFactory> gcm_client_factory) {
+ DCHECK(!driver_);
-std::string GCMProfileService::SignedInUserName() const {
- if (IsStarted())
- return identity_provider_->GetActiveUsername();
- return std::string();
-}
-
-bool GCMProfileService::ShouldStartAutomatically() const {
- return GetGCMEnabledState(profile_) == ALWAYS_ENABLED;
+ driver_.reset(new GCMDriver(
Nicolas Zea 2014/05/19 21:04:06 I wonder if this entire section should be in a if
jianli 2014/05/19 23:03:48 Done.
jianli 2014/05/20 17:37:23 Indeed we still need to create GCMDriver instance
+ gcm_client_factory.Pass(),
+ scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
+ SigninManagerFactory::GetForProfile(profile_),
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
+#if defined(OS_ANDROID)
+ NULL)),
+#else
+ LoginUIServiceFactory::GetForProfile(profile_))),
+#endif
+ profile_->GetPath().Append(chrome::kGCMStoreDirname),
+ profile_->GetRequestContext()));
}
-base::FilePath GCMProfileService::GetStorePath() const {
- return profile_->GetPath().Append(chrome::kGCMStoreDirname);
+void GCMProfileService::Shutdown() {
+ if (driver_)
+ driver_->Shutdown();
Nicolas Zea 2014/05/19 21:04:06 should we also driver_.reset() here?
jianli 2014/05/19 23:03:48 Done.
}
-scoped_refptr<net::URLRequestContextGetter>
-GCMProfileService::GetURLRequestContextGetter() const {
- return profile_->GetRequestContext();
+void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
+ driver_.reset(driver);
}
} // namespace gcm

Powered by Google App Engine
This is Rietveld 408576698