OLD | NEW |
---|---|
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/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "components/gcm_driver/common/gcm_messages.h" | 17 #include "components/gcm_driver/common/gcm_messages.h" |
18 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" | 18 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" |
19 #include "components/gcm_driver/default_gcm_app_handler.h" | 19 #include "components/gcm_driver/default_gcm_app_handler.h" |
20 #include "components/gcm_driver/gcm_client.h" | 20 #include "components/gcm_driver/gcm_client.h" |
21 #include "components/gcm_driver/gcm_message_status.h" | |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class FilePath; | 24 class FilePath; |
24 class SequencedTaskRunner; | 25 class SequencedTaskRunner; |
25 } | 26 } |
26 | 27 |
27 namespace gcm { | 28 namespace gcm { |
28 | 29 |
29 class GCMAppHandler; | 30 class GCMAppHandler; |
30 class GCMConnectionObserver; | 31 class GCMConnectionObserver; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 // works in context of a signed in entity (e.g. browser profile where user is | 193 // works in context of a signed in entity (e.g. browser profile where user is |
193 // signed into sync). | 194 // signed into sync). |
194 // |account_tokens|: list of email addresses, account IDs and OAuth2 access | 195 // |account_tokens|: list of email addresses, account IDs and OAuth2 access |
195 // tokens. | 196 // tokens. |
196 virtual void SetAccountTokens( | 197 virtual void SetAccountTokens( |
197 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) = 0; | 198 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) = 0; |
198 | 199 |
199 // Updates the |account_mapping| information in persistent store. | 200 // Updates the |account_mapping| information in persistent store. |
200 virtual void UpdateAccountMapping(const AccountMapping& account_mapping) = 0; | 201 virtual void UpdateAccountMapping(const AccountMapping& account_mapping) = 0; |
201 | 202 |
202 // Removes the account mapping information reated to |account_id| from | 203 // Removes the account mapping information related to |account_id| from |
203 // persistent store. | 204 // persistent store. |
204 virtual void RemoveAccountMapping(const std::string& account_id) = 0; | 205 virtual void RemoveAccountMapping(const std::string& account_id) = 0; |
205 | 206 |
206 // Getter and setter of last token fetch time. | 207 // Getter and setter of last token fetch time. |
207 virtual base::Time GetLastTokenFetchTime() = 0; | 208 virtual base::Time GetLastTokenFetchTime() = 0; |
208 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; | 209 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; |
209 | 210 |
210 // Sets whether or not GCM should try to wake the system from suspend in order | 211 // Sets whether or not GCM should try to wake the system from suspend in order |
211 // to send a heartbeat message. | 212 // to send a heartbeat message. |
212 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; | 213 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 const std::string& message_id, | 284 const std::string& message_id, |
284 GCMClient::Result result); | 285 GCMClient::Result result); |
285 | 286 |
286 bool HasRegisterCallback(const std::string& app_id); | 287 bool HasRegisterCallback(const std::string& app_id); |
287 | 288 |
288 void ClearCallbacks(); | 289 void ClearCallbacks(); |
289 | 290 |
290 // Dispatches the OnMessage event to the app handler associated with |app_id|. | 291 // Dispatches the OnMessage event to the app handler associated with |app_id|. |
291 // If |message| has been encrypted, it will be decrypted asynchronously and | 292 // If |message| has been encrypted, it will be decrypted asynchronously and |
292 // dispatched when the decryption operation was successful. Otherwise, the | 293 // dispatched when the decryption operation was successful. Otherwise, the |
293 // |message| will be dispatched immediately to the handler for |app_id|. | 294 // |message| will be dispatched immediately to the handler for |app_id|. |
Peter Beverloo
2017/02/15 15:17:15
// The |optional_receipt_callback| must be invoked
harkness
2017/02/22 17:19:32
Done.
| |
294 void DispatchMessage(const std::string& app_id, | 295 void DispatchMessage(const std::string& app_id, |
295 const IncomingMessage& message); | 296 const IncomingMessage& message, |
297 const MessageReceiptCallback& optional_receipt_callback); | |
296 | 298 |
297 private: | 299 private: |
298 // Common code shared by Unregister and UnregisterWithSenderId. | 300 // Common code shared by Unregister and UnregisterWithSenderId. |
299 void UnregisterInternal(const std::string& app_id, | 301 void UnregisterInternal(const std::string& app_id, |
300 const std::string* sender_id, | 302 const std::string* sender_id, |
301 const UnregisterCallback& callback); | 303 const UnregisterCallback& callback); |
302 | 304 |
303 // Dispatches the OnMessage event to the app handler associated with |app_id| | 305 // Dispatches the OnMessage event to the app handler associated with |app_id| |
304 // if |result| indicates that it is safe to do so, or will report a decryption | 306 // if |result| indicates that it is safe to do so, or will report a decryption |
305 // failure for the |app_id| otherwise. | 307 // failure for the |app_id| otherwise. |
306 void DispatchMessageInternal(const std::string& app_id, | 308 void DispatchMessageInternal( |
307 GCMEncryptionProvider::DecryptionResult result, | 309 const std::string& app_id, |
308 const IncomingMessage& message); | 310 const MessageReceiptCallback& optional_receipt_callback, |
311 GCMEncryptionProvider::DecryptionResult result, | |
312 const IncomingMessage& message); | |
309 | 313 |
310 // Called after unregistration completes in order to trigger the pending | 314 // Called after unregistration completes in order to trigger the pending |
311 // registration. | 315 // registration. |
312 void RegisterAfterUnregister( | 316 void RegisterAfterUnregister( |
313 const std::string& app_id, | 317 const std::string& app_id, |
314 const std::vector<std::string>& normalized_sender_ids, | 318 const std::vector<std::string>& normalized_sender_ids, |
315 const UnregisterCallback& unregister_callback, | 319 const UnregisterCallback& unregister_callback, |
316 GCMClient::Result result); | 320 GCMClient::Result result); |
317 | 321 |
318 // Callback map (from app_id to callback) for Register. | 322 // Callback map (from app_id to callback) for Register. |
(...skipping 17 matching lines...) Expand all Loading... | |
336 DefaultGCMAppHandler default_app_handler_; | 340 DefaultGCMAppHandler default_app_handler_; |
337 | 341 |
338 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 342 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
339 | 343 |
340 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 344 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
341 }; | 345 }; |
342 | 346 |
343 } // namespace gcm | 347 } // namespace gcm |
344 | 348 |
345 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 349 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
OLD | NEW |