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

Side by Side Diff: components/gcm_driver/gcm_driver.h

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new files 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 COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "components/gcm_driver/default_gcm_app_handler.h" 16 #include "components/gcm_driver/default_gcm_app_handler.h"
17 #include "components/gcm_driver/gcm_client.h" 17 #include "components/gcm_driver/gcm_client.h"
18 18
19 namespace gcm { 19 namespace gcm {
20 20
21 class GCMAppHandler; 21 class GCMAppHandler;
22 class GCMConnectionObserver; 22 class GCMConnectionObserver;
23 struct AccountMapping; 23 struct AccountMapping;
24 24
25 // Provides the capability to set/get InstanceID data in the GCM store. 25 // Provides the InstanceID support via GCMDriver.
26 class InstanceIDStore { 26 class InstanceIDHandler {
27 public: 27 public:
28 typedef base::Callback<void(const std::string& token,
29 GCMClient::Result result)> GetTokenCallback;
30 typedef base::Callback<void(GCMClient::Result result)> DeleteTokenCallback;
28 typedef base::Callback<void(const std::string& instance_id_data)> 31 typedef base::Callback<void(const std::string& instance_id_data)>
29 GetInstanceIDDataCallback; 32 GetInstanceIDDataCallback;
30 33
31 InstanceIDStore(); 34 InstanceIDHandler();
32 virtual ~InstanceIDStore(); 35 virtual ~InstanceIDHandler();
33 36
37 // Token service.
38 virtual void GetToken(const std::string& app_id,
39 const std::string& authorized_entity,
40 const std::string& scope,
41 const std::map<std::string, std::string>& options,
42 const GetTokenCallback& callback) = 0;
43 virtual void DeleteToken(const std::string& app_id,
44 const std::string& authorized_entity,
45 const std::string& scope,
46 const DeleteTokenCallback& callback) = 0;
47
48 // Persistence support.
34 virtual void AddInstanceIDData(const std::string& app_id, 49 virtual void AddInstanceIDData(const std::string& app_id,
35 const std::string& instance_id_data) = 0; 50 const std::string& instance_id_data) = 0;
36 virtual void RemoveInstanceIDData(const std::string& app_id) = 0; 51 virtual void RemoveInstanceIDData(const std::string& app_id) = 0;
37 virtual void GetInstanceIDData( 52 virtual void GetInstanceIDData(
38 const std::string& app_id, 53 const std::string& app_id,
39 const GetInstanceIDDataCallback& callback) = 0; 54 const GetInstanceIDDataCallback& callback) = 0;
40 55
41 private: 56 private:
42 DISALLOW_COPY_AND_ASSIGN(InstanceIDStore); 57 DISALLOW_COPY_AND_ASSIGN(InstanceIDHandler);
43 }; 58 };
44 59
45 // Bridge between GCM users in Chrome and the platform-specific implementation. 60 // Bridge between GCM users in Chrome and the platform-specific implementation.
46 class GCMDriver { 61 class GCMDriver {
47 public: 62 public:
48 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap; 63 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap;
49 typedef base::Callback<void(const std::string& registration_id, 64 typedef base::Callback<void(const std::string& registration_id,
50 GCMClient::Result result)> RegisterCallback; 65 GCMClient::Result result)> RegisterCallback;
51 typedef base::Callback<void(const std::string& message_id, 66 typedef base::Callback<void(const std::string& message_id,
52 GCMClient::Result result)> SendCallback; 67 GCMClient::Result result)> SendCallback;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 virtual void RemoveAccountMapping(const std::string& account_id) = 0; 174 virtual void RemoveAccountMapping(const std::string& account_id) = 0;
160 175
161 // Getter and setter of last token fetch time. 176 // Getter and setter of last token fetch time.
162 virtual base::Time GetLastTokenFetchTime() = 0; 177 virtual base::Time GetLastTokenFetchTime() = 0;
163 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; 178 virtual void SetLastTokenFetchTime(const base::Time& time) = 0;
164 179
165 // Sets whether or not GCM should try to wake the system from suspend in order 180 // Sets whether or not GCM should try to wake the system from suspend in order
166 // to send a heartbeat message. 181 // to send a heartbeat message.
167 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; 182 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0;
168 183
169 // Supports saving the Instance ID data in the GCM store. 184 // Supports InstanceID handling.
170 virtual InstanceIDStore* GetInstanceIDStore() = 0; 185 virtual InstanceIDHandler* GetInstanceIDHandler() = 0;
171 186
172 protected: 187 protected:
173 // Ensures that the GCM service starts (if necessary conditions are met). 188 // Ensures that the GCM service starts (if necessary conditions are met).
174 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0; 189 virtual GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) = 0;
175 190
176 // Platform-specific implementation of Register. 191 // Platform-specific implementation of Register.
177 virtual void RegisterImpl(const std::string& app_id, 192 virtual void RegisterImpl(const std::string& app_id,
178 const std::vector<std::string>& sender_ids) = 0; 193 const std::vector<std::string>& sender_ids) = 0;
179 194
180 // Platform-specific implementation of Unregister. 195 // Platform-specific implementation of Unregister.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 DefaultGCMAppHandler default_app_handler_; 253 DefaultGCMAppHandler default_app_handler_;
239 254
240 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; 255 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_;
241 256
242 DISALLOW_COPY_AND_ASSIGN(GCMDriver); 257 DISALLOW_COPY_AND_ASSIGN(GCMDriver);
243 }; 258 };
244 259
245 } // namespace gcm 260 } // namespace gcm
246 261
247 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 262 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698