Index: chrome/browser/push_messaging/push_messaging_service_impl.h |
diff --git a/chrome/browser/services/gcm/push_messaging_service_impl.h b/chrome/browser/push_messaging/push_messaging_service_impl.h |
similarity index 84% |
rename from chrome/browser/services/gcm/push_messaging_service_impl.h |
rename to chrome/browser/push_messaging/push_messaging_service_impl.h |
index c5cb50083d31a23c4397fea7c483c163cf44f839..cbffbfd9bbd8a2654e1d4849a2d4ea1f467e290c 100644 |
--- a/chrome/browser/services/gcm/push_messaging_service_impl.h |
+++ b/chrome/browser/push_messaging/push_messaging_service_impl.h |
@@ -2,32 +2,35 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
-#define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
+#ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |
+#define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |
#include "base/compiler_specific.h" |
#include "base/memory/weak_ptr.h" |
#include "components/content_settings/core/browser/content_settings_observer.h" |
#include "components/gcm_driver/gcm_app_handler.h" |
#include "components/gcm_driver/gcm_client.h" |
+#include "components/keyed_service/core/keyed_service.h" |
#include "content/public/browser/push_messaging_service.h" |
#include "content/public/common/push_messaging_status.h" |
#include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermissionStatus.h" |
class Profile; |
+class PushMessagingApplicationId; |
namespace user_prefs { |
class PrefRegistrySyncable; |
} |
namespace gcm { |
- |
+class GCMDriver; |
class GCMProfileService; |
-class PushMessagingApplicationId; |
+} |
class PushMessagingServiceImpl : public content::PushMessagingService, |
- public GCMAppHandler, |
- public content_settings::Observer { |
+ public gcm::GCMAppHandler, |
+ public content_settings::Observer, |
+ public KeyedService { |
public: |
// Register profile-specific prefs for GCM. |
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
@@ -35,18 +38,17 @@ class PushMessagingServiceImpl : public content::PushMessagingService, |
// If any Service Workers are using push, starts GCM and adds an app handler. |
static void InitializeForProfile(Profile* profile); |
- PushMessagingServiceImpl(GCMProfileService* gcm_profile_service, |
- Profile* profile); |
+ explicit PushMessagingServiceImpl(Profile* profile); |
~PushMessagingServiceImpl() override; |
- // GCMAppHandler implementation. |
+ // gcm::GCMAppHandler implementation. |
void ShutdownHandler() override; |
void OnMessage(const std::string& app_id, |
- const GCMClient::IncomingMessage& message) override; |
+ const gcm::GCMClient::IncomingMessage& message) override; |
void OnMessagesDeleted(const std::string& app_id) override; |
void OnSendError( |
const std::string& app_id, |
- const GCMClient::SendErrorDetails& send_error_details) override; |
+ const gcm::GCMClient::SendErrorDetails& send_error_details) override; |
void OnSendAcknowledged(const std::string& app_id, |
const std::string& message_id) override; |
bool CanHandle(const std::string& app_id) const override; |
@@ -82,7 +84,8 @@ class PushMessagingServiceImpl : public content::PushMessagingService, |
ContentSettingsType content_type, |
std::string resource_identifier) override; |
- void SetProfileForTesting(Profile* profile); |
+ // KeyedService implementation. |
+ void Shutdown() override; |
private: |
// A registration is pending until it has succeeded or failed. |
@@ -94,7 +97,7 @@ class PushMessagingServiceImpl : public content::PushMessagingService, |
void DeliverMessageCallback(const std::string& app_id_guid, |
const GURL& requesting_origin, |
int64 service_worker_registration_id, |
- const GCMClient::IncomingMessage& message, |
+ const gcm::GCMClient::IncomingMessage& message, |
content::PushDeliveryStatus status); |
// Developers are required to display a Web Notification in response to an |
@@ -123,7 +126,7 @@ class PushMessagingServiceImpl : public content::PushMessagingService, |
const PushMessagingApplicationId& application_id, |
const content::PushMessagingService::RegisterCallback& callback, |
const std::string& registration_id, |
- GCMClient::Result result); |
+ gcm::GCMClient::Result result); |
void DidRequestPermission( |
const PushMessagingApplicationId& application_id, |
@@ -141,7 +144,7 @@ class PushMessagingServiceImpl : public content::PushMessagingService, |
void DidUnregister(const std::string& app_id_guid, |
bool retry_on_failure, |
const content::PushMessagingService::UnregisterCallback&, |
- GCMClient::Result result); |
+ gcm::GCMClient::Result result); |
// OnContentSettingChanged methods ------------------------------------------- |
@@ -154,9 +157,13 @@ class PushMessagingServiceImpl : public content::PushMessagingService, |
// Checks if a given origin is allowed to use Push. |
bool HasPermission(const GURL& origin); |
- GCMProfileService* gcm_profile_service_; // It owns us. |
+ gcm::GCMDriver* gcm_driver() const; |
+ |
+ // PushMessagingServiceFactory defines a dependency on the GCMProfileService, |
+ // guaranteeing that GCMProfileService will outlive this class. |
+ gcm::GCMProfileService* gcm_profile_service_; |
- Profile* profile_; // It owns our owner. |
+ Profile* profile_; |
int push_registration_count_; |
int pending_push_registration_count_; |
@@ -166,6 +173,4 @@ class PushMessagingServiceImpl : public content::PushMessagingService, |
DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); |
}; |
-} // namespace gcm |
- |
-#endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ |
+#endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |