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

Unified Diff: chrome/browser/services/gcm/push_messaging_service_impl.h

Issue 338363003: Push API: register PushMessagingServiceImpl as GCMAppHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add as AppHandler before calling Register. Other review issues. Created 6 years, 6 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/push_messaging_service_impl.h
diff --git a/chrome/browser/services/gcm/push_messaging_service_impl.h b/chrome/browser/services/gcm/push_messaging_service_impl.h
index 64aa91ffe0d3401624c2539bff5ff4cf5335fe2c..aea8a08edf8321f1cd0a9d2d449892652b891164 100644
--- a/chrome/browser/services/gcm/push_messaging_service_impl.h
+++ b/chrome/browser/services/gcm/push_messaging_service_impl.h
@@ -7,18 +7,43 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
+#include "components/gcm_driver/gcm_app_handler.h"
#include "components/gcm_driver/gcm_client.h"
#include "content/public/browser/push_messaging_service.h"
+class Profile;
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
namespace gcm {
class GCMProfileService;
-class PushMessagingServiceImpl : public content::PushMessagingService {
+class PushMessagingServiceImpl : public content::PushMessagingService,
+ public GCMAppHandler {
public:
- explicit PushMessagingServiceImpl(GCMProfileService* gcm_profile_service);
+ // Register profile-specific prefs for GCM.
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
+ // 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);
virtual ~PushMessagingServiceImpl();
+ // GCMAppHandler implementation.
+ virtual void ShutdownHandler() OVERRIDE;
+ virtual void OnMessage(const std::string& app_id,
+ const GCMClient::IncomingMessage& message) OVERRIDE;
+ virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE;
+ virtual void OnSendError(
+ const std::string& app_id,
+ const GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
+ virtual bool CanHandle(const std::string& app_id) const OVERRIDE;
+
// content::PushMessagingService implementation:
virtual void Register(
const std::string& app_id,
@@ -27,12 +52,15 @@ class PushMessagingServiceImpl : public content::PushMessagingService {
private:
void DidRegister(
+ const std::string& app_id,
const content::PushMessagingService::RegisterCallback& callback,
const std::string& registration_id,
GCMClient::Result result);
GCMProfileService* gcm_profile_service_; // It owns us.
+ Profile* profile_; // It owns our owner.
+
base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);

Powered by Google App Engine
This is Rietveld 408576698