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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_service_impl.h

Issue 1129833003: Rename "register" -> "subscribe" in the Push Messaging code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@p-userVisible-tests
Patch Set: Created 5 years, 7 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
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_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 void OnMessagesDeleted(const std::string& app_id) override; 57 void OnMessagesDeleted(const std::string& app_id) override;
58 void OnSendError( 58 void OnSendError(
59 const std::string& app_id, 59 const std::string& app_id,
60 const gcm::GCMClient::SendErrorDetails& send_error_details) override; 60 const gcm::GCMClient::SendErrorDetails& send_error_details) override;
61 void OnSendAcknowledged(const std::string& app_id, 61 void OnSendAcknowledged(const std::string& app_id,
62 const std::string& message_id) override; 62 const std::string& message_id) override;
63 bool CanHandle(const std::string& app_id) const override; 63 bool CanHandle(const std::string& app_id) const override;
64 64
65 // content::PushMessagingService implementation: 65 // content::PushMessagingService implementation:
66 GURL GetPushEndpoint() override; 66 GURL GetPushEndpoint() override;
67 void RegisterFromDocument( 67 void SubscribeFromDocument(
68 const GURL& requesting_origin, 68 const GURL& requesting_origin,
69 int64 service_worker_registration_id, 69 int64 service_worker_registration_id,
70 const std::string& sender_id, 70 const std::string& sender_id,
71 int renderer_id, 71 int renderer_id,
72 int render_frame_id, 72 int render_frame_id,
73 bool user_visible, 73 bool user_visible,
74 const content::PushMessagingService::RegisterCallback& callback) override; 74 const content::PushMessagingService::SubscribeCallback& callback)
75 void RegisterFromWorker( 75 override;
johnme 2015/05/07 13:31:25 Nit: Same indent as previous line.
76 void SubscribeFromWorker(
76 const GURL& requesting_origin, 77 const GURL& requesting_origin,
77 int64 service_worker_registration_id, 78 int64 service_worker_registration_id,
78 const std::string& sender_id, 79 const std::string& sender_id,
79 bool user_visible, 80 bool user_visible,
80 const content::PushMessagingService::RegisterCallback& callback) override; 81 const content::PushMessagingService::SubscribeCallback& callback)
81 void Unregister( 82 override;
johnme 2015/05/07 13:31:25 Nit: Same indent as previous line.
83 void Unsubscribe(
82 const GURL& requesting_origin, 84 const GURL& requesting_origin,
83 int64 service_worker_registration_id, 85 int64 service_worker_registration_id,
84 const std::string& sender_id, 86 const std::string& sender_id,
85 const content::PushMessagingService::UnregisterCallback&) override; 87 const content::PushMessagingService::UnsubscribeCallback&) override;
86 blink::WebPushPermissionStatus GetPermissionStatus( 88 blink::WebPushPermissionStatus GetPermissionStatus(
87 const GURL& requesting_origin, 89 const GURL& requesting_origin,
88 const GURL& embedding_origin, 90 const GURL& embedding_origin,
89 bool user_visible) override; 91 bool user_visible) override;
90 92
91 // content_settings::Observer implementation. 93 // content_settings::Observer implementation.
92 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 94 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
93 const ContentSettingsPattern& secondary_pattern, 95 const ContentSettingsPattern& secondary_pattern,
94 ContentSettingsType content_type, 96 ContentSettingsType content_type,
95 std::string resource_identifier) override; 97 std::string resource_identifier) override;
96 98
97 // KeyedService implementation. 99 // KeyedService implementation.
98 void Shutdown() override; 100 void Shutdown() override;
99 101
100 void SetMessageCallbackForTesting(const base::Closure& callback); 102 void SetMessageCallbackForTesting(const base::Closure& callback);
101 void SetContentSettingChangedCallbackForTesting( 103 void SetContentSettingChangedCallbackForTesting(
102 const base::Closure& callback); 104 const base::Closure& callback);
103 105
104 private: 106 private:
105 // A registration is pending until it has succeeded or failed. 107 // A subscription is pending until it has succeeded or failed.
106 void IncreasePushRegistrationCount(int add, bool is_pending); 108 void IncreasePushSubscriptionCount(int add, bool is_pending);
107 void DecreasePushRegistrationCount(int subtract, bool was_pending); 109 void DecreasePushSubscriptionCount(int subtract, bool was_pending);
108 110
109 // OnMessage methods --------------------------------------------------------- 111 // OnMessage methods ---------------------------------------------------------
110 112
111 void DeliverMessageCallback(const std::string& app_id_guid, 113 void DeliverMessageCallback(const std::string& app_id_guid,
112 const GURL& requesting_origin, 114 const GURL& requesting_origin,
113 int64 service_worker_registration_id, 115 int64 service_worker_registration_id,
114 const gcm::GCMClient::IncomingMessage& message, 116 const gcm::GCMClient::IncomingMessage& message,
115 const base::Closure& message_handled_closure, 117 const base::Closure& message_handled_closure,
116 content::PushDeliveryStatus status); 118 content::PushDeliveryStatus status);
117 119
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 bool success, 158 bool success,
157 int64_t persistent_notification_id); 159 int64_t persistent_notification_id);
158 160
159 void DidWriteNotificationData( 161 void DidWriteNotificationData(
160 const GURL& requesting_origin, 162 const GURL& requesting_origin,
161 const content::PlatformNotificationData& notification_data, 163 const content::PlatformNotificationData& notification_data,
162 const base::Closure& message_handled_closure, 164 const base::Closure& message_handled_closure,
163 bool success, 165 bool success,
164 int64_t persistent_notification_id); 166 int64_t persistent_notification_id);
165 167
166 // Register methods ---------------------------------------------------------- 168 // Subscription methods ------------------------------------------------------
johnme 2015/05/07 13:31:25 Nit: "Subscribe methods" for consistency
167 169
168 void RegisterEnd( 170 void SubscribeEnd(
169 const content::PushMessagingService::RegisterCallback& callback, 171 const content::PushMessagingService::SubscribeCallback& callback,
170 const std::string& registration_id, 172 const std::string& subscription_id,
171 content::PushRegistrationStatus status); 173 content::PushSubscriptionStatus status);
172 174
173 void DidRegister( 175 void DidSubscribe(
174 const PushMessagingApplicationId& application_id, 176 const PushMessagingApplicationId& application_id,
175 const content::PushMessagingService::RegisterCallback& callback, 177 const content::PushMessagingService::SubscribeCallback& callback,
176 const std::string& registration_id, 178 const std::string& subscription_id,
177 gcm::GCMClient::Result result); 179 gcm::GCMClient::Result result);
178 180
179 void DidRequestPermission( 181 void DidRequestPermission(
180 const PushMessagingApplicationId& application_id, 182 const PushMessagingApplicationId& application_id,
181 const std::string& sender_id, 183 const std::string& sender_id,
182 const content::PushMessagingService::RegisterCallback& callback, 184 const content::PushMessagingService::SubscribeCallback& callback,
183 ContentSetting content_setting); 185 ContentSetting content_setting);
184 186
185 // Unregister methods -------------------------------------------------------- 187 // Unsubscribe methods -------------------------------------------------------
186 188
187 void Unregister(const std::string& app_id_guid, 189 void Unsubscribe(const std::string& app_id_guid,
188 const std::string& sender_id, 190 const std::string& sender_id,
189 const content::PushMessagingService::UnregisterCallback&); 191 const content::PushMessagingService::UnsubscribeCallback&);
190 192
191 void DidUnregister(bool was_registered, 193 void DidUnsubscribe(bool was_subscribed,
192 const content::PushMessagingService::UnregisterCallback&, 194 const content::PushMessagingService::UnsubscribeCallback&,
193 gcm::GCMClient::Result result); 195 gcm::GCMClient::Result result);
194 196
195 // OnContentSettingChanged methods ------------------------------------------- 197 // OnContentSettingChanged methods -------------------------------------------
196 198
197 void UnregisterBecausePermissionRevoked(const PushMessagingApplicationId& id, 199 void UnsubscribeBecausePermissionRevoked(const PushMessagingApplicationId& id,
198 const base::Closure& closure, 200 const base::Closure& closure,
199 const std::string& sender_id, 201 const std::string& sender_id,
200 bool success, bool not_found); 202 bool success, bool not_found);
201 203
202 // Helper methods ------------------------------------------------------------ 204 // Helper methods ------------------------------------------------------------
203 205
204 // Checks if a given origin is allowed to use Push. 206 // Checks if a given origin is allowed to use Push.
205 bool HasPermission(const GURL& origin); 207 bool HasPermission(const GURL& origin);
206 208
207 gcm::GCMDriver* GetGCMDriver() const; 209 gcm::GCMDriver* GetGCMDriver() const;
208 210
209 Profile* profile_; 211 Profile* profile_;
210 212
211 int push_registration_count_; 213 int push_subscription_count_;
212 int pending_push_registration_count_; 214 int pending_push_subscription_count_;
213 215
214 base::Closure message_callback_for_testing_; 216 base::Closure message_callback_for_testing_;
215 base::Closure content_setting_changed_callback_for_testing_; 217 base::Closure content_setting_changed_callback_for_testing_;
216 218
217 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; 219 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
218 220
219 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); 221 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
220 }; 222 };
221 223
222 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 224 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698