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

Side by Side Diff: chrome/browser/services/gcm/push_messaging_service_impl.h

Issue 404353003: Define PushMessagingApplicationId and replace ad-hoc code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments from jam and fgorski. Created 6 years, 4 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_app_handler.h"
11 #include "components/gcm_driver/gcm_client.h" 11 #include "components/gcm_driver/gcm_client.h"
12 #include "content/public/browser/push_messaging_service.h" 12 #include "content/public/browser/push_messaging_service.h"
13 #include "content/public/common/push_messaging_status.h" 13 #include "content/public/common/push_messaging_status.h"
14 14
15 class Profile; 15 class Profile;
16 16
17 namespace user_prefs { 17 namespace user_prefs {
18 class PrefRegistrySyncable; 18 class PrefRegistrySyncable;
19 } 19 }
20 20
21 namespace gcm { 21 namespace gcm {
22 22
23 class GCMProfileService; 23 class GCMProfileService;
24 struct PushMessagingApplicationId;
24 25
25 class PushMessagingServiceImpl : public content::PushMessagingService, 26 class PushMessagingServiceImpl : public content::PushMessagingService,
26 public GCMAppHandler { 27 public GCMAppHandler {
27 public: 28 public:
28 // Register profile-specific prefs for GCM. 29 // Register profile-specific prefs for GCM.
29 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 30 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
30 31
31 // If any Service Workers are using push, starts GCM and adds an app handler. 32 // If any Service Workers are using push, starts GCM and adds an app handler.
32 static void InitializeForProfile(Profile* profile); 33 static void InitializeForProfile(Profile* profile);
33 34
34 PushMessagingServiceImpl(GCMProfileService* gcm_profile_service, 35 PushMessagingServiceImpl(GCMProfileService* gcm_profile_service,
35 Profile* profile); 36 Profile* profile);
36 virtual ~PushMessagingServiceImpl(); 37 virtual ~PushMessagingServiceImpl();
37 38
38 // GCMAppHandler implementation. 39 // GCMAppHandler implementation.
39 virtual void ShutdownHandler() OVERRIDE; 40 virtual void ShutdownHandler() OVERRIDE;
40 virtual void OnMessage(const std::string& app_id, 41 virtual void OnMessage(const std::string& app_id,
41 const GCMClient::IncomingMessage& message) OVERRIDE; 42 const GCMClient::IncomingMessage& message) OVERRIDE;
42 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; 43 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE;
43 virtual void OnSendError( 44 virtual void OnSendError(
44 const std::string& app_id, 45 const std::string& app_id,
45 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; 46 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
46 virtual bool CanHandle(const std::string& app_id) const OVERRIDE; 47 virtual bool CanHandle(const std::string& app_id) const OVERRIDE;
47 48
48 // content::PushMessagingService implementation: 49 // content::PushMessagingService implementation:
49 virtual void Register( 50 virtual void Register(
50 const std::string& app_id, 51 const GURL& origin,
52 int64 service_worker_registration_id,
51 const std::string& sender_id, 53 const std::string& sender_id,
52 int renderer_id, 54 int renderer_id,
53 int render_frame_id, 55 int render_frame_id,
54 bool user_gesture, 56 bool user_gesture,
55 const content::PushMessagingService::RegisterCallback& callback) OVERRIDE; 57 const content::PushMessagingService::RegisterCallback& callback) OVERRIDE;
56 58
57 private: 59 private:
58 void RegisterEnd( 60 void RegisterEnd(
59 const std::string& app_id,
60 const content::PushMessagingService::RegisterCallback& callback, 61 const content::PushMessagingService::RegisterCallback& callback,
61 const std::string& registration_id, 62 const std::string& registration_id,
62 content::PushMessagingStatus status); 63 content::PushMessagingStatus status);
63 64
64 void DidRegister( 65 void DidRegister(
65 const std::string& app_id,
66 const content::PushMessagingService::RegisterCallback& callback, 66 const content::PushMessagingService::RegisterCallback& callback,
67 const std::string& registration_id, 67 const std::string& registration_id,
68 GCMClient::Result result); 68 GCMClient::Result result);
69 69
70 void DidRequestPermission( 70 void DidRequestPermission(
71 const PushMessagingApplicationId& application_id,
71 const std::string& sender_id, 72 const std::string& sender_id,
72 const std::string& app_id,
73 const content::PushMessagingService::RegisterCallback& callback, 73 const content::PushMessagingService::RegisterCallback& callback,
74 bool allow); 74 bool allow);
75 75
76 GCMProfileService* gcm_profile_service_; // It owns us. 76 GCMProfileService* gcm_profile_service_; // It owns us.
77 77
78 Profile* profile_; // It owns our owner. 78 Profile* profile_; // It owns our owner.
79 79
80 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; 80 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
81 81
82 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); 82 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
83 }; 83 };
84 84
85 } // namespace gcm 85 } // namespace gcm
86 86
87 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_ 87 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698