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

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

Issue 2697793004: Push API: Validate storage before returning cached subscriptions (Closed)
Patch Set: Comment out PUSH_GETREGISTRATION_STATUS_PUBLIC_KEY_UNAVAILABLE Created 3 years, 10 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>
(...skipping 15 matching lines...) Expand all
26 26
27 namespace gcm { 27 namespace gcm {
28 28
29 class GCMAppHandler; 29 class GCMAppHandler;
30 class GCMConnectionObserver; 30 class GCMConnectionObserver;
31 struct AccountMapping; 31 struct AccountMapping;
32 32
33 // Provides the InstanceID support via GCMDriver. 33 // Provides the InstanceID support via GCMDriver.
34 class InstanceIDHandler { 34 class InstanceIDHandler {
35 public: 35 public:
36 typedef base::Callback<void(const std::string& token, 36 using GetTokenCallback =
37 GCMClient::Result result)> GetTokenCallback; 37 base::Callback<void(const std::string& token, GCMClient::Result result)>;
38 typedef base::Callback<void(GCMClient::Result result)> DeleteTokenCallback; 38 using ValidateTokenCallback = base::Callback<void(bool is_valid)>;
39 typedef base::Callback<void(const std::string& instance_id, 39 using DeleteTokenCallback = base::Callback<void(GCMClient::Result result)>;
40 const std::string& extra_data)> 40 using GetInstanceIDDataCallback =
41 GetInstanceIDDataCallback; 41 base::Callback<void(const std::string& instance_id,
42 const std::string& extra_data)>;
42 43
43 InstanceIDHandler(); 44 InstanceIDHandler();
44 virtual ~InstanceIDHandler(); 45 virtual ~InstanceIDHandler();
45 46
46 // Token service. 47 // Token service.
47 virtual void GetToken(const std::string& app_id, 48 virtual void GetToken(const std::string& app_id,
48 const std::string& authorized_entity, 49 const std::string& authorized_entity,
49 const std::string& scope, 50 const std::string& scope,
50 const std::map<std::string, std::string>& options, 51 const std::map<std::string, std::string>& options,
51 const GetTokenCallback& callback) = 0; 52 const GetTokenCallback& callback) = 0;
53 virtual void ValidateToken(const std::string& app_id,
54 const std::string& authorized_entity,
55 const std::string& scope,
56 const std::string& token,
57 const ValidateTokenCallback& callback) = 0;
52 virtual void DeleteToken(const std::string& app_id, 58 virtual void DeleteToken(const std::string& app_id,
53 const std::string& authorized_entity, 59 const std::string& authorized_entity,
54 const std::string& scope, 60 const std::string& scope,
55 const DeleteTokenCallback& callback) = 0; 61 const DeleteTokenCallback& callback) = 0;
56 void DeleteAllTokensForApp(const std::string& app_id, 62 void DeleteAllTokensForApp(const std::string& app_id,
57 const DeleteTokenCallback& callback); 63 const DeleteTokenCallback& callback);
58 64
59 // Persistence support. 65 // Persistence support.
60 virtual void AddInstanceIDData(const std::string& app_id, 66 virtual void AddInstanceIDData(const std::string& app_id,
61 const std::string& instance_id, 67 const std::string& instance_id,
62 const std::string& extra_data) = 0; 68 const std::string& extra_data) = 0;
63 virtual void RemoveInstanceIDData(const std::string& app_id) = 0; 69 virtual void RemoveInstanceIDData(const std::string& app_id) = 0;
64 virtual void GetInstanceIDData( 70 virtual void GetInstanceIDData(
65 const std::string& app_id, 71 const std::string& app_id,
66 const GetInstanceIDDataCallback& callback) = 0; 72 const GetInstanceIDDataCallback& callback) = 0;
67 73
68 private: 74 private:
69 DISALLOW_COPY_AND_ASSIGN(InstanceIDHandler); 75 DISALLOW_COPY_AND_ASSIGN(InstanceIDHandler);
70 }; 76 };
71 77
72 // Bridge between GCM users in Chrome and the platform-specific implementation. 78 // Bridge between GCM users in Chrome and the platform-specific implementation.
73 class GCMDriver { 79 class GCMDriver {
74 public: 80 public:
75 typedef std::map<std::string, GCMAppHandler*> GCMAppHandlerMap; 81 static const size_t kMaxSenders;
Peter Beverloo 2017/03/20 23:50:13 It seems to me like making this protected would be
johnme 2017/03/30 18:36:38 Doneish. I kept it public as I feel the limit is p
76 typedef base::Callback<void(const std::string& registration_id, 82
77 GCMClient::Result result)> RegisterCallback; 83 using GCMAppHandlerMap = std::map<std::string, GCMAppHandler*>;
78 typedef base::Callback<void(const std::string& message_id, 84 using RegisterCallback =
79 GCMClient::Result result)> SendCallback; 85 base::Callback<void(const std::string& registration_id,
80 typedef base::Callback<void(const std::string&, const std::string&)> 86 GCMClient::Result result)>;
81 GetEncryptionInfoCallback; 87 using ValidateRegistrationCallback = base::Callback<void(bool is_valid)>;
82 typedef base::Callback<void(GCMClient::Result result)> UnregisterCallback; 88 using UnregisterCallback = base::Callback<void(GCMClient::Result result)>;
83 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)> 89 using SendCallback = base::Callback<void(const std::string& message_id,
84 GetGCMStatisticsCallback; 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)>;
85 95
86 // Enumeration to be used with GetGCMStatistics() for indicating whether the 96 // Enumeration to be used with GetGCMStatistics() for indicating whether the
87 // existing logs should be cleared or kept. 97 // existing logs should be cleared or kept.
88 enum ClearActivityLogs { 98 enum ClearActivityLogs {
89 CLEAR_LOGS, 99 CLEAR_LOGS,
90 KEEP_LOGS 100 KEEP_LOGS
91 }; 101 };
92 102
93 GCMDriver( 103 GCMDriver(
94 const base::FilePath& store_path, 104 const base::FilePath& store_path,
95 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); 105 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner);
96 virtual ~GCMDriver(); 106 virtual ~GCMDriver();
97 107
98 // 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
99 // 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
100 // instead multiple simultaneous registrations are allowed. 110 // instead multiple simultaneous registrations are allowed.
101 // |app_id|: application ID. 111 // |app_id|: application ID.
102 // |sender_ids|: list of IDs of the servers that are allowed to send the 112 // |sender_ids|: list of IDs of the servers that are allowed to send the
103 // messages to the application. These IDs are assigned by the 113 // messages to the application. These IDs are assigned by the
104 // Google API Console. 114 // Google API Console.
105 // |callback|: to be called once the asynchronous operation is done. 115 // |callback|: to be called once the asynchronous operation is done.
106 void Register(const std::string& app_id, 116 void Register(const std::string& app_id,
107 const std::vector<std::string>& sender_ids, 117 const std::vector<std::string>& sender_ids,
108 const RegisterCallback& callback); 118 const RegisterCallback& callback);
109 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
110 // 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
111 // remove any encryption keys associated with the |app_id|. 129 // remove any encryption keys associated with the |app_id|.
112 // |app_id|: application ID. 130 // |app_id|: application ID.
113 // |callback|: to be called once the asynchronous operation is done. 131 // |callback|: to be called once the asynchronous operation is done.
114 void Unregister(const std::string& app_id, 132 void Unregister(const std::string& app_id,
115 const UnregisterCallback& callback); 133 const UnregisterCallback& callback);
116 134
117 // 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
118 // 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|.
119 // TODO(jianli): Switch to using GCM's unsubscribe API. 137 // TODO(jianli): Switch to using GCM's unsubscribe API.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 DefaultGCMAppHandler default_app_handler_; 354 DefaultGCMAppHandler default_app_handler_;
337 355
338 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; 356 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_;
339 357
340 DISALLOW_COPY_AND_ASSIGN(GCMDriver); 358 DISALLOW_COPY_AND_ASSIGN(GCMDriver);
341 }; 359 };
342 360
343 } // namespace gcm 361 } // namespace gcm
344 362
345 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ 363 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698