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

Side by Side 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: Rebase. Address 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ 5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ 6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "components/gcm_driver/gcm_app_handler.h"
10 #include "components/gcm_driver/gcm_client.h" 11 #include "components/gcm_driver/gcm_client.h"
11 #include "content/public/browser/push_messaging_service.h" 12 #include "content/public/browser/push_messaging_service.h"
12 13
14 class Profile;
15
16 namespace user_prefs {
17 class PrefRegistrySyncable;
18 }
19
13 namespace gcm { 20 namespace gcm {
14 21
15 class GCMProfileService; 22 class GCMProfileService;
16 23
17 class PushMessagingServiceImpl : public content::PushMessagingService { 24 class PushMessagingServiceImpl : public content::PushMessagingService,
25 public GCMAppHandler {
18 public: 26 public:
19 explicit PushMessagingServiceImpl(GCMProfileService* gcm_profile_service); 27 // Register profile-specific prefs for GCM.
28 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
29
30 // If any Service Workers are using push, starts GCM and adds an app handler.
31 static void InitializeForProfile(Profile* profile);
32
33 PushMessagingServiceImpl(GCMProfileService* gcm_profile_service,
34 Profile* profile);
20 virtual ~PushMessagingServiceImpl(); 35 virtual ~PushMessagingServiceImpl();
21 36
37 // GCMAppHandler implementation.
38 virtual void ShutdownHandler() OVERRIDE;
39 virtual void OnMessage(const std::string& app_id,
40 const GCMClient::IncomingMessage& message) OVERRIDE;
41 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE;
42 virtual void OnSendError(
43 const std::string& app_id,
44 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
45 virtual bool CanHandle(const std::string& app_id) const OVERRIDE;
46
22 // content::PushMessagingService implementation: 47 // content::PushMessagingService implementation:
23 virtual void Register( 48 virtual void Register(
24 const std::string& app_id, 49 const std::string& app_id,
25 const std::string& sender_id, 50 const std::string& sender_id,
26 const content::PushMessagingService::RegisterCallback& callback) OVERRIDE; 51 const content::PushMessagingService::RegisterCallback& callback) OVERRIDE;
27 52
28 private: 53 private:
29 void DidRegister( 54 void DidRegister(
55 const std::string& app_id,
30 const content::PushMessagingService::RegisterCallback& callback, 56 const content::PushMessagingService::RegisterCallback& callback,
31 const std::string& registration_id, 57 const std::string& registration_id,
32 GCMClient::Result result); 58 GCMClient::Result result);
33 59
34 GCMProfileService* gcm_profile_service_; // It owns us. 60 GCMProfileService* gcm_profile_service_; // It owns us.
35 61
62 Profile* profile_; // It owns our owner.
63
36 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; 64 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
37 65
38 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); 66 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
39 }; 67 };
40 68
41 } // namespace gcm 69 } // namespace gcm
42 70
43 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ 71 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.cc ('k') | chrome/browser/services/gcm/push_messaging_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698