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

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

Issue 961533002: Adding Send to Gaia ID feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removign the callback on shutdown Created 5 years, 9 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_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
11 #include "base/callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "components/gcm_driver/gcm_app_handler.h" 15 #include "components/gcm_driver/gcm_app_handler.h"
15 #include "components/gcm_driver/gcm_client.h" 16 #include "components/gcm_driver/gcm_client.h"
16 #include "google_apis/gcm/engine/account_mapping.h" 17 #include "google_apis/gcm/engine/account_mapping.h"
17 18
18 namespace base { 19 namespace base {
19 class Clock; 20 class Clock;
20 } 21 }
21 22
22 namespace gcm { 23 namespace gcm {
23 24
24 class GCMDriver; 25 class GCMDriver;
25 extern const char kGCMAccountMapperAppId[]; 26 extern const char kGCMAccountMapperAppId[];
26 27
27 // Class for mapping signed-in GAIA accounts to the GCM Device ID. 28 // Class for mapping signed-in GAIA accounts to the GCM Device ID.
28 class GCMAccountMapper : public GCMAppHandler { 29 class GCMAccountMapper : public GCMAppHandler {
29 public: 30 public:
30 // List of account mappings. 31 // List of account mappings.
31 typedef std::vector<AccountMapping> AccountMappings; 32 typedef std::vector<AccountMapping> AccountMappings;
33 typedef base::Callback<void(const std::string& app_id,
34 const GCMClient::IncomingMessage& message)>
35 DispatchMessageCallback;
32 36
33 explicit GCMAccountMapper(GCMDriver* gcm_driver); 37 explicit GCMAccountMapper(GCMDriver* gcm_driver);
34 ~GCMAccountMapper() override; 38 ~GCMAccountMapper() override;
35 39
36 void Initialize(const AccountMappings& account_mappings); 40 void Initialize(const AccountMappings& account_mappings,
41 const DispatchMessageCallback& callback);
37 42
38 // Called by AccountTracker, when a new list of account tokens is available. 43 // 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. 44 // This will cause a refresh of account mappings and sending updates to GCM.
40 void SetAccountTokens( 45 void SetAccountTokens(
41 const std::vector<GCMClient::AccountTokenInfo>& account_tokens); 46 const std::vector<GCMClient::AccountTokenInfo>& account_tokens);
42 47
43 // Implementation of GCMAppHandler: 48 // Implementation of GCMAppHandler:
44 void ShutdownHandler() override; 49 void ShutdownHandler() override;
45 void OnMessage(const std::string& app_id, 50 void OnMessage(const std::string& app_id,
46 const GCMClient::IncomingMessage& message) override; 51 const GCMClient::IncomingMessage& message) override;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Returns iterator that can be used to delete the account. 100 // Returns iterator that can be used to delete the account.
96 AccountMappings::iterator FindMappingByMessageId( 101 AccountMappings::iterator FindMappingByMessageId(
97 const std::string& message_id); 102 const std::string& message_id);
98 103
99 // Sets the clock for testing. 104 // Sets the clock for testing.
100 void SetClockForTesting(scoped_ptr<base::Clock> clock); 105 void SetClockForTesting(scoped_ptr<base::Clock> clock);
101 106
102 // GCMDriver owns GCMAccountMapper. 107 // GCMDriver owns GCMAccountMapper.
103 GCMDriver* gcm_driver_; 108 GCMDriver* gcm_driver_;
104 109
110 // Callback to GCMDriver to dispatch messages send to Gaia ID.
Nicolas Zea 2015/02/27 21:33:21 nit: s/send/sent
fgorski 2015/02/27 22:12:19 Done.
111 DispatchMessageCallback dispatch_message_callback_;
112
105 // Clock for timestamping status changes. 113 // Clock for timestamping status changes.
106 scoped_ptr<base::Clock> clock_; 114 scoped_ptr<base::Clock> clock_;
107 115
108 // Currnetly tracked account mappings. 116 // Currnetly tracked account mappings.
109 AccountMappings accounts_; 117 AccountMappings accounts_;
110 118
111 std::vector<GCMClient::AccountTokenInfo> pending_account_tokens_; 119 std::vector<GCMClient::AccountTokenInfo> pending_account_tokens_;
112 120
113 // GCM Registration ID of the account mapper. 121 // GCM Registration ID of the account mapper.
114 std::string registration_id_; 122 std::string registration_id_;
115 123
116 bool initialized_; 124 bool initialized_;
117 125
118 base::WeakPtrFactory<GCMAccountMapper> weak_ptr_factory_; 126 base::WeakPtrFactory<GCMAccountMapper> weak_ptr_factory_;
119 127
120 DISALLOW_COPY_AND_ASSIGN(GCMAccountMapper); 128 DISALLOW_COPY_AND_ASSIGN(GCMAccountMapper);
121 }; 129 };
122 130
123 } // namespace gcm 131 } // namespace gcm
124 132
125 #endif // COMPONENTS_GCM_DRIVER_GCM_ACCOUNT_MAPPER_H_ 133 #endif // COMPONENTS_GCM_DRIVER_GCM_ACCOUNT_MAPPER_H_
OLDNEW
« no previous file with comments | « no previous file | components/gcm_driver/gcm_account_mapper.cc » ('j') | components/gcm_driver/gcm_account_mapper_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698