Index: chrome/browser/services/gcm/gcm_profile_service_factory.cc |
diff --git a/chrome/browser/services/gcm/gcm_profile_service_factory.cc b/chrome/browser/services/gcm/gcm_profile_service_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..519883e19199d8c1f788af25e0fbc06db86fdbce |
--- /dev/null |
+++ b/chrome/browser/services/gcm/gcm_profile_service_factory.cc |
@@ -0,0 +1,52 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
+ |
+#include "chrome/browser/browser_process.h" |
Nicolas Zea
2013/11/05 20:17:33
is this used?
jianli
2013/11/05 20:42:32
Done.
|
+#include "chrome/browser/profiles/incognito_helpers.h" |
+#include "chrome/browser/profiles/profile.h" |
Nicolas Zea
2013/11/05 20:17:33
you never actually do anything with the profile, s
jianli
2013/11/05 20:42:32
It is needed because we need to cast from BrowserC
|
+#include "chrome/browser/services/gcm/gcm_profile_service.h" |
+#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" |
+#include "content/public/browser/browser_thread.h" |
Nicolas Zea
2013/11/05 20:17:33
don't think you use this?
jianli
2013/11/05 20:42:32
Done.
|
+ |
+using content::BrowserThread; |
Nicolas Zea
2013/11/05 20:17:33
this too
jianli
2013/11/05 20:42:32
Done.
|
+ |
+namespace gcm { |
+ |
+// static |
+GCMProfileService* GCMProfileServiceFactory::GetForProfile(Profile* profile) { |
Nicolas Zea
2013/11/05 20:17:33
same comment about having ordering consistent with
jianli
2013/11/05 20:42:32
For this file, indeed it is consistent with the or
|
+ if (!gcm::GCMProfileService::IsGCMEnabled()) |
+ return NULL; |
+ |
+ return static_cast<GCMProfileService*>( |
+ GetInstance()->GetServiceForBrowserContext(profile, true)); |
+} |
+ |
+// static |
+GCMProfileServiceFactory* GCMProfileServiceFactory::GetInstance() { |
+ return Singleton<GCMProfileServiceFactory>::get(); |
+} |
+ |
+GCMProfileServiceFactory::GCMProfileServiceFactory() |
+ : BrowserContextKeyedServiceFactory( |
+ "GCMProfileService", |
+ BrowserContextDependencyManager::GetInstance()) { |
+} |
+ |
+GCMProfileServiceFactory::~GCMProfileServiceFactory() { |
+} |
+ |
+BrowserContextKeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( |
+ content::BrowserContext* profile) const { |
+ return gcm::GCMProfileService::IsGCMEnabled() ? |
+ new GCMProfileService(static_cast<Profile*>(profile)) : NULL; |
+} |
+ |
+content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( |
+ content::BrowserContext* context) const { |
+ return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
+} |
+ |
+} // namespace gcm |