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

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

Issue 183923006: [GCM] API update to allow only a single sender in registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updates based on CR. Changing how the senders/reg_ids are stored to avoid upgrade to multiple sedne… Created 6 years, 9 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_GCM_PROFILE_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Registers |sender_id| for an app. A registration ID will be returned by 77 // Registers |sender_id| for an app. A registration ID will be returned by
78 // the GCM server. 78 // the GCM server.
79 // |app_id|: application ID. 79 // |app_id|: application ID.
80 // |cert|: SHA-1 of public key of the application, in base16 format. 80 // |cert|: SHA-1 of public key of the application, in base16 format.
81 // |sender_ids|: list of IDs of the servers that are allowed to send the 81 // |sender_ids|: list of IDs of the servers that are allowed to send the
82 // messages to the application. These IDs are assigned by the 82 // messages to the application. These IDs are assigned by the
83 // Google API Console. 83 // Google API Console.
84 // |callback|: to be called once the asynchronous operation is done. 84 // |callback|: to be called once the asynchronous operation is done.
85 virtual void Register(const std::string& app_id, 85 virtual void Register(const std::string& app_id,
86 const std::vector<std::string>& sender_ids, 86 const std::string& sender_id,
87 const std::string& cert, 87 const std::string& cert,
88 RegisterCallback callback); 88 RegisterCallback callback);
89 89
90 // Sends a message to a given receiver. 90 // Sends a message to a given receiver.
91 // |app_id|: application ID. 91 // |app_id|: application ID.
92 // |receiver_id|: registration ID of the receiver party. 92 // |receiver_id|: registration ID of the receiver party.
93 // |message|: message to be sent. 93 // |message|: message to be sent.
94 // |callback|: to be called once the asynchronous operation is done. 94 // |callback|: to be called once the asynchronous operation is done.
95 virtual void Send(const std::string& app_id, 95 virtual void Send(const std::string& app_id,
96 const std::string& receiver_id, 96 const std::string& receiver_id,
(...skipping 11 matching lines...) Expand all
108 friend class GCMProfileServiceTestConsumer; 108 friend class GCMProfileServiceTestConsumer;
109 109
110 class DelayedTaskController; 110 class DelayedTaskController;
111 class IOWorker; 111 class IOWorker;
112 112
113 struct RegistrationInfo { 113 struct RegistrationInfo {
114 RegistrationInfo(); 114 RegistrationInfo();
115 ~RegistrationInfo(); 115 ~RegistrationInfo();
116 bool IsValid() const; 116 bool IsValid() const;
117 117
118 std::vector<std::string> sender_ids; 118 std::string sender_id;
119 std::string registration_id; 119 std::string registration_id;
120 }; 120 };
121 121
122 // Overridden from content::NotificationObserver: 122 // Overridden from content::NotificationObserver:
123 virtual void Observe(int type, 123 virtual void Observe(int type,
124 const content::NotificationSource& source, 124 const content::NotificationSource& source,
125 const content::NotificationDetails& details) OVERRIDE; 125 const content::NotificationDetails& details) OVERRIDE;
126 126
127 // Ensures that the GCMClient is loaded and the GCM check-in is done when 127 // Ensures that the GCMClient is loaded and the GCM check-in is done when
128 // the profile was signed in. 128 // the profile was signed in.
129 void EnsureLoaded(); 129 void EnsureLoaded();
130 130
131 // Checks out of GCM when the profile has been signed out. This will erase 131 // Checks out of GCM when the profile has been signed out. This will erase
132 // all the cached and persisted data. 132 // all the cached and persisted data.
133 void CheckOut(); 133 void CheckOut();
134 134
135 // Resets the GCMClient instance. This is called when the profile is being 135 // Resets the GCMClient instance. This is called when the profile is being
136 // destroyed. 136 // destroyed.
137 void ResetGCMClient(); 137 void ResetGCMClient();
138 138
139 // Ensures that the app is ready for GCM functions and events. 139 // Ensures that the app is ready for GCM functions and events.
140 void EnsureAppReady(const std::string& app_id); 140 void EnsureAppReady(const std::string& app_id);
141 141
142 // Unregisters an app from using the GCM after it has been uninstalled. 142 // Unregisters an app from using the GCM after it has been uninstalled.
143 void Unregister(const std::string& app_id); 143 void Unregister(const std::string& app_id);
144 144
145 void DoRegister(const std::string& app_id, 145 void DoRegister(const std::string& app_id,
146 const std::vector<std::string>& sender_ids, 146 const std::string& sender_id,
147 const std::string& cert); 147 const std::string& cert);
148 void DoSend(const std::string& app_id, 148 void DoSend(const std::string& app_id,
149 const std::string& receiver_id, 149 const std::string& receiver_id,
150 const GCMClient::OutgoingMessage& message); 150 const GCMClient::OutgoingMessage& message);
151 151
152 // Callbacks posted from IO thread to UI thread. 152 // Callbacks posted from IO thread to UI thread.
153 void RegisterFinished(const std::string& app_id, 153 void RegisterFinished(const std::string& app_id,
154 const std::string& registration_id, 154 const std::string& registration_id,
155 GCMClient::Result result); 155 GCMClient::Result result);
156 void SendFinished(const std::string& app_id, 156 void SendFinished(const std::string& app_id,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 // Used to pass a weak pointer to the IO worker. 221 // Used to pass a weak pointer to the IO worker.
222 base::WeakPtrFactory<GCMProfileService> weak_ptr_factory_; 222 base::WeakPtrFactory<GCMProfileService> weak_ptr_factory_;
223 223
224 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); 224 DISALLOW_COPY_AND_ASSIGN(GCMProfileService);
225 }; 225 };
226 226
227 } // namespace gcm 227 } // namespace gcm
228 228
229 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ 229 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698