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

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

Issue 1134733006: Push API: use (un)subscription instead of (un)registration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed pre-submit warning 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
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 void OnMessagesDeleted(const std::string& app_id) override; 56 void OnMessagesDeleted(const std::string& app_id) override;
57 void OnSendError( 57 void OnSendError(
58 const std::string& app_id, 58 const std::string& app_id,
59 const gcm::GCMClient::SendErrorDetails& send_error_details) override; 59 const gcm::GCMClient::SendErrorDetails& send_error_details) override;
60 void OnSendAcknowledged(const std::string& app_id, 60 void OnSendAcknowledged(const std::string& app_id,
61 const std::string& message_id) override; 61 const std::string& message_id) override;
62 bool CanHandle(const std::string& app_id) const override; 62 bool CanHandle(const std::string& app_id) const override;
63 63
64 // content::PushMessagingService implementation: 64 // content::PushMessagingService implementation:
65 GURL GetPushEndpoint() override; 65 GURL GetPushEndpoint() override;
66 void RegisterFromDocument( 66 void SubscribeFromDocument(
67 const GURL& requesting_origin, 67 const GURL& requesting_origin,
68 int64 service_worker_registration_id, 68 int64 service_worker_registration_id,
69 const std::string& sender_id, 69 const std::string& sender_id,
70 int renderer_id, 70 int renderer_id,
71 int render_frame_id, 71 int render_frame_id,
72 bool user_visible, 72 bool user_visible,
73 const content::PushMessagingService::RegisterCallback& callback) override; 73 const content::PushMessagingService::RegisterCallback& callback) override;
74 void RegisterFromWorker( 74 void SubscribeFromWorker(
75 const GURL& requesting_origin, 75 const GURL& requesting_origin,
76 int64 service_worker_registration_id, 76 int64 service_worker_registration_id,
77 const std::string& sender_id, 77 const std::string& sender_id,
78 bool user_visible, 78 bool user_visible,
79 const content::PushMessagingService::RegisterCallback& callback) override; 79 const content::PushMessagingService::RegisterCallback& callback) override;
80 void Unregister( 80 void Unsubscribe(
81 const GURL& requesting_origin, 81 const GURL& requesting_origin,
82 int64 service_worker_registration_id, 82 int64 service_worker_registration_id,
83 const std::string& sender_id, 83 const std::string& sender_id,
84 const content::PushMessagingService::UnregisterCallback&) override; 84 const content::PushMessagingService::UnregisterCallback&) override;
85 blink::WebPushPermissionStatus GetPermissionStatus( 85 blink::WebPushPermissionStatus GetPermissionStatus(
86 const GURL& requesting_origin, 86 const GURL& requesting_origin,
87 const GURL& embedding_origin, 87 const GURL& embedding_origin,
88 bool user_visible) override; 88 bool user_visible) override;
89 bool SupportNonVisibleMessages() override; 89 bool SupportNonVisibleMessages() override;
90 90
91 91
92 // content_settings::Observer implementation. 92 // content_settings::Observer implementation.
93 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 93 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
94 const ContentSettingsPattern& secondary_pattern, 94 const ContentSettingsPattern& secondary_pattern,
95 ContentSettingsType content_type, 95 ContentSettingsType content_type,
96 std::string resource_identifier) override; 96 std::string resource_identifier) override;
97 97
98 // KeyedService implementation. 98 // KeyedService implementation.
99 void Shutdown() override; 99 void Shutdown() override;
100 100
101 void SetMessageCallbackForTesting(const base::Closure& callback); 101 void SetMessageCallbackForTesting(const base::Closure& callback);
102 void SetContentSettingChangedCallbackForTesting( 102 void SetContentSettingChangedCallbackForTesting(
103 const base::Closure& callback); 103 const base::Closure& callback);
104 104
105 private: 105 private:
106 // A registration is pending until it has succeeded or failed. 106 // A subscription is pending until it has succeeded or failed.
107 void IncreasePushRegistrationCount(int add, bool is_pending); 107 void IncreasePushSubscriptionCount(int add, bool is_pending);
108 void DecreasePushRegistrationCount(int subtract, bool was_pending); 108 void DecreasePushSubscriptionCount(int subtract, bool was_pending);
109 109
110 // OnMessage methods --------------------------------------------------------- 110 // OnMessage methods ---------------------------------------------------------
111 111
112 void DeliverMessageCallback(const std::string& app_id, 112 void DeliverMessageCallback(const std::string& app_id,
113 const GURL& requesting_origin, 113 const GURL& requesting_origin,
114 int64 service_worker_registration_id, 114 int64 service_worker_registration_id,
115 const gcm::GCMClient::IncomingMessage& message, 115 const gcm::GCMClient::IncomingMessage& message,
116 const base::Closure& message_handled_closure, 116 const base::Closure& message_handled_closure,
117 content::PushDeliveryStatus status); 117 content::PushDeliveryStatus status);
118 118
119 // Register methods ---------------------------------------------------------- 119 // Subscribe methods ---------------------------------------------------------
120 120
121 void RegisterEnd( 121 void SubscribeEnd(
122 const content::PushMessagingService::RegisterCallback& callback, 122 const content::PushMessagingService::RegisterCallback& callback,
123 const std::string& registration_id, 123 const std::string& subscription_id,
124 content::PushRegistrationStatus status); 124 content::PushRegistrationStatus status);
125 125
126 void DidRegister( 126 void DidSubscribe(
127 const PushMessagingAppIdentifier& app_identifier, 127 const PushMessagingAppIdentifier& app_identifier,
128 const content::PushMessagingService::RegisterCallback& callback, 128 const content::PushMessagingService::RegisterCallback& callback,
129 const std::string& registration_id, 129 const std::string& subscription_id,
130 gcm::GCMClient::Result result); 130 gcm::GCMClient::Result result);
131 131
132 void DidRequestPermission( 132 void DidRequestPermission(
133 const PushMessagingAppIdentifier& app_identifier, 133 const PushMessagingAppIdentifier& app_identifier,
134 const std::string& sender_id, 134 const std::string& sender_id,
135 const content::PushMessagingService::RegisterCallback& callback, 135 const content::PushMessagingService::RegisterCallback& callback,
136 ContentSetting content_setting); 136 ContentSetting content_setting);
137 137
138 // Unregister methods -------------------------------------------------------- 138 // Unsubscribe methods -------------------------------------------------------
139 139
140 void Unregister(const std::string& app_id, 140 void Unsubscribe(const std::string& app_id,
141 const std::string& sender_id, 141 const std::string& sender_id,
142 const content::PushMessagingService::UnregisterCallback&); 142 const content::PushMessagingService::UnregisterCallback&);
143 143
144 void DidUnregister(bool was_registered, 144 void DidUnsubscribe(bool was_subscribed,
145 const content::PushMessagingService::UnregisterCallback&, 145 const content::PushMessagingService::UnregisterCallback&,
146 gcm::GCMClient::Result result); 146 gcm::GCMClient::Result result);
147 147
148 // OnContentSettingChanged methods ------------------------------------------- 148 // OnContentSettingChanged methods -------------------------------------------
149 149
150 void UnregisterBecausePermissionRevoked( 150 void UnsubscribeBecausePermissionRevoked(
151 const PushMessagingAppIdentifier& app_identifier, 151 const PushMessagingAppIdentifier& app_identifier,
152 const base::Closure& closure, 152 const base::Closure& closure,
153 const std::string& sender_id, 153 const std::string& sender_id,
154 bool success, 154 bool success,
155 bool not_found); 155 bool not_found);
156 156
157 // Helper methods ------------------------------------------------------------ 157 // Helper methods ------------------------------------------------------------
158 158
159 // Checks if a given origin is allowed to use Push. 159 // Checks if a given origin is allowed to use Push.
160 bool HasPermission(const GURL& origin); 160 bool HasPermission(const GURL& origin);
161 161
162 gcm::GCMDriver* GetGCMDriver() const; 162 gcm::GCMDriver* GetGCMDriver() const;
163 163
164 Profile* profile_; 164 Profile* profile_;
165 165
166 int push_registration_count_; 166 int push_subscription_count_;
167 int pending_push_registration_count_; 167 int pending_push_subscription_count_;
168 168
169 base::Closure message_callback_for_testing_; 169 base::Closure message_callback_for_testing_;
170 base::Closure content_setting_changed_callback_for_testing_; 170 base::Closure content_setting_changed_callback_for_testing_;
171 171
172 #if defined(ENABLE_NOTIFICATIONS) 172 #if defined(ENABLE_NOTIFICATIONS)
173 PushMessagingNotificationManager notification_manager_; 173 PushMessagingNotificationManager notification_manager_;
174 #endif 174 #endif
175 175
176 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; 176 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
177 177
178 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); 178 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
179 }; 179 };
180 180
181 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 181 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698