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_ACCOUNT_MAPPER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_ACCOUNT_MAPPER_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_ACCOUNT_MAPPER_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_ACCOUNT_MAPPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 class GCMDriver; | 24 class GCMDriver; |
25 extern const char kGCMAccountMapperAppId[]; | 25 extern const char kGCMAccountMapperAppId[]; |
26 | 26 |
27 // Class for mapping signed-in GAIA accounts to the GCM Device ID. | 27 // Class for mapping signed-in GAIA accounts to the GCM Device ID. |
28 class GCMAccountMapper : public GCMAppHandler { | 28 class GCMAccountMapper : public GCMAppHandler { |
29 public: | 29 public: |
30 // List of account mappings. | 30 // List of account mappings. |
31 typedef std::vector<AccountMapping> AccountMappings; | 31 typedef std::vector<AccountMapping> AccountMappings; |
32 | 32 |
33 explicit GCMAccountMapper(GCMDriver* gcm_driver); | 33 explicit GCMAccountMapper(GCMDriver* gcm_driver); |
34 virtual ~GCMAccountMapper(); | 34 ~GCMAccountMapper() override; |
35 | 35 |
36 void Initialize(const AccountMappings& account_mappings); | 36 void Initialize(const AccountMappings& account_mappings); |
37 | 37 |
38 // Called by AccountTracker, when a new list of account tokens is available. | 38 // Called by AccountTracker, when a new list of account tokens is available. |
39 // This will cause a refresh of account mappings and sending updates to GCM. | 39 // This will cause a refresh of account mappings and sending updates to GCM. |
40 void SetAccountTokens( | 40 void SetAccountTokens( |
41 const std::vector<GCMClient::AccountTokenInfo>& account_tokens); | 41 const std::vector<GCMClient::AccountTokenInfo>& account_tokens); |
42 | 42 |
43 // Implementation of GCMAppHandler: | 43 // Implementation of GCMAppHandler: |
44 virtual void ShutdownHandler() override; | 44 void ShutdownHandler() override; |
45 virtual void OnMessage(const std::string& app_id, | 45 void OnMessage(const std::string& app_id, |
46 const GCMClient::IncomingMessage& message) override; | 46 const GCMClient::IncomingMessage& message) override; |
47 virtual void OnMessagesDeleted(const std::string& app_id) override; | 47 void OnMessagesDeleted(const std::string& app_id) override; |
48 virtual void OnSendError( | 48 void OnSendError( |
49 const std::string& app_id, | 49 const std::string& app_id, |
50 const GCMClient::SendErrorDetails& send_error_details) override; | 50 const GCMClient::SendErrorDetails& send_error_details) override; |
51 virtual void OnSendAcknowledged(const std::string& app_id, | 51 void OnSendAcknowledged(const std::string& app_id, |
52 const std::string& message_id) override; | 52 const std::string& message_id) override; |
53 virtual bool CanHandle(const std::string& app_id) const override; | 53 bool CanHandle(const std::string& app_id) const override; |
54 | 54 |
55 private: | 55 private: |
56 friend class GCMAccountMapperTest; | 56 friend class GCMAccountMapperTest; |
57 | 57 |
58 typedef std::map<std::string, GCMClient::OutgoingMessage> OutgoingMessages; | 58 typedef std::map<std::string, GCMClient::OutgoingMessage> OutgoingMessages; |
59 | 59 |
60 // Checks whether account mapper is ready to process new account tokens. | 60 // Checks whether account mapper is ready to process new account tokens. |
61 bool IsReady(); | 61 bool IsReady(); |
62 | 62 |
63 // Informs GCM of an added or refreshed account mapping. | 63 // Informs GCM of an added or refreshed account mapping. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 bool initialized_; | 116 bool initialized_; |
117 | 117 |
118 base::WeakPtrFactory<GCMAccountMapper> weak_ptr_factory_; | 118 base::WeakPtrFactory<GCMAccountMapper> weak_ptr_factory_; |
119 | 119 |
120 DISALLOW_COPY_AND_ASSIGN(GCMAccountMapper); | 120 DISALLOW_COPY_AND_ASSIGN(GCMAccountMapper); |
121 }; | 121 }; |
122 | 122 |
123 } // namespace gcm | 123 } // namespace gcm |
124 | 124 |
125 #endif // COMPONENTS_GCM_DRIVER_GCM_ACCOUNT_MAPPER_H_ | 125 #endif // COMPONENTS_GCM_DRIVER_GCM_ACCOUNT_MAPPER_H_ |
OLD | NEW |