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

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

Issue 2697793004: Push API: Validate storage before returning cached subscriptions (Closed)
Patch Set: Fix include Created 3 years, 8 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 | « components/gcm_driver/gcm_client_impl.cc ('k') | components/gcm_driver/gcm_driver.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 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>
(...skipping 14 matching lines...) Expand all
25 25
26 namespace gcm { 26 namespace gcm {
27 27
28 class GCMAppHandler; 28 class GCMAppHandler;
29 class GCMConnectionObserver; 29 class GCMConnectionObserver;
30 struct AccountMapping; 30 struct AccountMapping;
31 31
32 // Provides the InstanceID support via GCMDriver. 32 // Provides the InstanceID support via GCMDriver.
33 class InstanceIDHandler { 33 class InstanceIDHandler {
34 public: 34 public:
35 typedef base::Callback<void(const std::string& token, 35 using GetTokenCallback =
36 GCMClient::Result result)> GetTokenCallback; 36 base::Callback<void(const std::string& token, GCMClient::Result result)>;
37 typedef base::Callback<void(GCMClient::Result result)> DeleteTokenCallback; 37 using ValidateTokenCallback = base::Callback<void(bool is_valid)>;
38 typedef base::Callback<void(const std::string& instance_id, 38 using DeleteTokenCallback = base::Callback<void(GCMClient::Result result)>;
39 const std::string& extra_data)> 39 using GetInstanceIDDataCallback =
40 GetInstanceIDDataCallback; 40 base::Callback<void(const std::string& instance_id,
41 const std::string& extra_data)>;
41 42
42 InstanceIDHandler(); 43 InstanceIDHandler();
43 virtual ~InstanceIDHandler(); 44 virtual ~InstanceIDHandler();
44 45
45 // Token service. 46 // Token service.
46 virtual void GetToken(const std::string& app_id, 47 virtual void GetToken(const std::string& app_id,
47 const std::string& authorized_entity, 48 const std::string& authorized_entity,
48 const std::string& scope, 49 const std::string& scope,
49 const std::map<std::string, std::string>& options, 50 const std::map<std::string, std::string>& options,
50 const GetTokenCallback& callback) = 0; 51 const GetTokenCallback& callback) = 0;
52 virtual void ValidateToken(const std::string& app_id,
53 const std::string& authorized_entity,
54 const std::string& scope,
55 const std::string& token,
56 const ValidateTokenCallback& callback) = 0;
51 virtual void DeleteToken(const std::string& app_id, 57 virtual void DeleteToken(const std::string& app_id,
52 const std::string& authorized_entity, 58 const std::string& authorized_entity,
53 const std::string& scope, 59 const std::string& scope,
54 const DeleteTokenCallback& callback) = 0; 60 const DeleteTokenCallback& callback) = 0;
55 void DeleteAllTokensForApp(const std::string& app_id, 61 void DeleteAllTokensForApp(const std::string& app_id,
56 const DeleteTokenCallback& callback); 62 const DeleteTokenCallback& callback);
57 63
58 // Persistence support. 64 // Persistence support.
59 virtual void AddInstanceIDData(const std::string& app_id, 65 virtual void AddInstanceIDData(const std::string& app_id,
60 const std::string& instance_id, 66 const std::string& instance_id,
61 const std::string& extra_data) = 0; 67 const std::string& extra_data) = 0;
62 virtual void RemoveInstanceIDData(const std::string& app_id) = 0; 68 virtual void RemoveInstanceIDData(const std::string& app_id) = 0;
63 virtual void GetInstanceIDData( 69 virtual void GetInstanceIDData(
64 const std::string& app_id, 70 const std::string& app_id,
65 const GetInstanceIDDataCallback& callback) = 0; 71 const GetInstanceIDDataCallback& callback) = 0;
66 72
67 private: 73 private:
68 DISALLOW_COPY_AND_ASSIGN(InstanceIDHandler); 74 DISALLOW_COPY_AND_ASSIGN(InstanceIDHandler);
69 }; 75 };
70 76
71 // Bridge between GCM users in Chrome and the platform-specific implementation. 77 // Bridge between GCM users in Chrome and the platform-specific implementation.
72 class GCMDriver { 78 class GCMDriver {
73 public: 79 public:
74 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap; 80 // Max number of sender IDs that can be passed to |Register| on desktop.
75 typedef base::Callback<void(const std::string& registration_id, 81 constexpr static size_t kMaxSenders = 100;
76 GCMClient::Result result)> RegisterCallback; 82
77 typedef base::Callback<void(const std::string& message_id, 83 using GCMAppHandlerMap = std::map<std::string, GCMAppHandler*>;
78 GCMClient::Result result)> SendCallback; 84 using RegisterCallback =
79 typedef base::Callback<void(const std::string&, const std::string&)> 85 base::Callback<void(const std::string& registration_id,
80 GetEncryptionInfoCallback; 86 GCMClient::Result result)>;
81 typedef base::Callback<void(GCMClient::Result result)> UnregisterCallback; 87 using ValidateRegistrationCallback = base::Callback<void(bool is_valid)>;
82 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)> 88 using UnregisterCallback = base::Callback<void(GCMClient::Result result)>;
83 GetGCMStatisticsCallback; 89 using SendCallback = base::Callback<void(const std::string& message_id,
90 GCMClient::Result result)>;
91 using GetEncryptionInfoCallback =
92 base::Callback<void(const std::string&, const std::string&)>;
93 using GetGCMStatisticsCallback =
94 base::Callback<void(const GCMClient::GCMStatistics& stats)>;
84 95
85 // Enumeration to be used with GetGCMStatistics() for indicating whether the 96 // Enumeration to be used with GetGCMStatistics() for indicating whether the
86 // existing logs should be cleared or kept. 97 // existing logs should be cleared or kept.
87 enum ClearActivityLogs { 98 enum ClearActivityLogs {
88 CLEAR_LOGS, 99 CLEAR_LOGS,
89 KEEP_LOGS 100 KEEP_LOGS
90 }; 101 };
91 102
92 GCMDriver( 103 GCMDriver(
93 const base::FilePath& store_path, 104 const base::FilePath& store_path,
94 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); 105 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner);
95 virtual ~GCMDriver(); 106 virtual ~GCMDriver();
96 107
97 // Registers |sender_ids| for an app. A registration ID will be returned by 108 // Registers |sender_ids| for an app. A registration ID will be returned by
98 // the GCM server. On Android, only a single sender ID is supported, but 109 // the GCM server. On Android, only a single sender ID is supported, but
99 // instead multiple simultaneous registrations are allowed. 110 // instead multiple simultaneous registrations are allowed.
100 // |app_id|: application ID. 111 // |app_id|: application ID.
101 // |sender_ids|: list of IDs of the servers that are allowed to send the 112 // |sender_ids|: list of IDs of the servers allowed to send messages to the
102 // messages to the application. These IDs are assigned by the 113 // application. The IDs are assigned by the Google API Console.
103 // Google API Console. 114 // Max number of IDs is 1 on Android, |kMaxSenders| on desktop.
104 // |callback|: to be called once the asynchronous operation is done. 115 // |callback|: to be called once the asynchronous operation is done.
105 void Register(const std::string& app_id, 116 void Register(const std::string& app_id,
106 const std::vector<std::string>& sender_ids, 117 const std::vector<std::string>& sender_ids,
107 const RegisterCallback& callback); 118 const RegisterCallback& callback);
108 119
120 // Checks that the provided |sender_ids| and |registration_id| matches the
121 // stored registration info for |app_id|.
122 virtual void ValidateRegistration(
123 const std::string& app_id,
124 const std::vector<std::string>& sender_ids,
125 const std::string& registration_id,
126 const ValidateRegistrationCallback& callback) = 0;
127
109 // Unregisters all sender_ids for an app. Only works on non-Android. Will also 128 // Unregisters all sender_ids for an app. Only works on non-Android. Will also
110 // remove any encryption keys associated with the |app_id|. 129 // remove any encryption keys associated with the |app_id|.
111 // |app_id|: application ID. 130 // |app_id|: application ID.
112 // |callback|: to be called once the asynchronous operation is done. 131 // |callback|: to be called once the asynchronous operation is done.
113 void Unregister(const std::string& app_id, 132 void Unregister(const std::string& app_id,
114 const UnregisterCallback& callback); 133 const UnregisterCallback& callback);
115 134
116 // Unregisters an (app_id, sender_id) pair from using GCM. Only works on 135 // Unregisters an (app_id, sender_id) pair from using GCM. Only works on
117 // Android. Will also remove any encryption keys associated with the |app_id|. 136 // Android. Will also remove any encryption keys associated with the |app_id|.
118 // TODO(jianli): Switch to using GCM's unsubscribe API. 137 // TODO(jianli): Switch to using GCM's unsubscribe API.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 GCMAppHandlerMap app_handlers_; 351 GCMAppHandlerMap app_handlers_;
333 352
334 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; 353 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_;
335 354
336 DISALLOW_COPY_AND_ASSIGN(GCMDriver); 355 DISALLOW_COPY_AND_ASSIGN(GCMDriver);
337 }; 356 };
338 357
339 } // namespace gcm 358 } // namespace gcm
340 359
341 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 360 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_client_impl.cc ('k') | components/gcm_driver/gcm_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698