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_DESKTOP_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace extensions { | 30 namespace extensions { |
31 class ExtensionGCMAppHandlerTest; | 31 class ExtensionGCMAppHandlerTest; |
32 } | 32 } |
33 | 33 |
34 namespace net { | 34 namespace net { |
35 class URLRequestContextGetter; | 35 class URLRequestContextGetter; |
36 } | 36 } |
37 | 37 |
38 namespace gcm { | 38 namespace gcm { |
39 | 39 |
| 40 class GCMAccountMapper; |
40 class GCMAppHandler; | 41 class GCMAppHandler; |
41 class GCMClientFactory; | 42 class GCMClientFactory; |
42 class GCMDelayedTaskController; | 43 class GCMDelayedTaskController; |
43 | 44 |
44 // GCMDriver implementation for desktop and Chrome OS, using GCMClient. | 45 // GCMDriver implementation for desktop and Chrome OS, using GCMClient. |
45 class GCMDriverDesktop : public GCMDriver { | 46 class GCMDriverDesktop : public GCMDriver { |
46 public: | 47 public: |
47 GCMDriverDesktop( | 48 GCMDriverDesktop( |
48 scoped_ptr<GCMClientFactory> gcm_client_factory, | 49 scoped_ptr<GCMClientFactory> gcm_client_factory, |
49 const GCMClient::ChromeBuildInfo& chrome_build_info, | 50 const GCMClient::ChromeBuildInfo& chrome_build_info, |
(...skipping 18 matching lines...) Expand all Loading... |
68 GCMConnectionObserver* observer) OVERRIDE; | 69 GCMConnectionObserver* observer) OVERRIDE; |
69 virtual void Enable() OVERRIDE; | 70 virtual void Enable() OVERRIDE; |
70 virtual void Disable() OVERRIDE; | 71 virtual void Disable() OVERRIDE; |
71 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE; | 72 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE; |
72 virtual bool IsStarted() const OVERRIDE; | 73 virtual bool IsStarted() const OVERRIDE; |
73 virtual bool IsConnected() const OVERRIDE; | 74 virtual bool IsConnected() const OVERRIDE; |
74 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, | 75 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
75 bool clear_logs) OVERRIDE; | 76 bool clear_logs) OVERRIDE; |
76 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, | 77 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
77 bool recording) OVERRIDE; | 78 bool recording) OVERRIDE; |
| 79 virtual void SetAccountTokens( |
| 80 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) OVERRIDE; |
78 virtual void UpdateAccountMapping( | 81 virtual void UpdateAccountMapping( |
79 const AccountMapping& account_mapping) OVERRIDE; | 82 const AccountMapping& account_mapping) OVERRIDE; |
80 virtual void RemoveAccountMapping(const std::string& account_id) OVERRIDE; | 83 virtual void RemoveAccountMapping(const std::string& account_id) OVERRIDE; |
81 | 84 |
82 // GCMDriverDesktop specific implementation. | |
83 // Sets a list of accounts with OAuth2 tokens for the next checkin. | |
84 // |account_tokens| maps email addresses to OAuth2 access tokens. | |
85 // |account_removed| indicates that an account has been removed since the | |
86 // last time the callback was called, which triggers an immediate checkin, | |
87 // to ensure that association between device and account is removed. | |
88 void SetAccountsForCheckin( | |
89 const std::map<std::string, std::string>& account_tokens); | |
90 | |
91 // Exposed for testing purpose. | 85 // Exposed for testing purpose. |
92 bool gcm_enabled() const { return gcm_enabled_; } | 86 bool gcm_enabled() const { return gcm_enabled_; } |
93 GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() { | 87 GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() { |
94 return gcm_channel_status_syncer_.get(); | 88 return gcm_channel_status_syncer_.get(); |
95 } | 89 } |
96 | 90 |
97 protected: | 91 protected: |
98 // GCMDriver implementation: | 92 // GCMDriver implementation: |
99 virtual GCMClient::Result EnsureStarted() OVERRIDE; | 93 virtual GCMClient::Result EnsureStarted() OVERRIDE; |
100 virtual void RegisterImpl( | 94 virtual void RegisterImpl( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 145 |
152 // Flag to indicate the last known state of the GCM client. Because this | 146 // Flag to indicate the last known state of the GCM client. Because this |
153 // flag lives on the UI thread, while the GCM client lives on the IO thread, | 147 // flag lives on the UI thread, while the GCM client lives on the IO thread, |
154 // it may be out of date while connection changes are happening. | 148 // it may be out of date while connection changes are happening. |
155 bool connected_; | 149 bool connected_; |
156 | 150 |
157 // List of observers to notify when connection state changes. | 151 // List of observers to notify when connection state changes. |
158 // Makes sure list is empty on destruction. | 152 // Makes sure list is empty on destruction. |
159 ObserverList<GCMConnectionObserver, true> connection_observer_list_; | 153 ObserverList<GCMConnectionObserver, true> connection_observer_list_; |
160 | 154 |
| 155 // Account mapper. Only works when user is signed in. |
| 156 scoped_ptr<GCMAccountMapper> account_mapper_; |
| 157 |
161 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 158 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
162 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 159 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
163 | 160 |
164 scoped_ptr<GCMDelayedTaskController> delayed_task_controller_; | 161 scoped_ptr<GCMDelayedTaskController> delayed_task_controller_; |
165 | 162 |
166 // For all the work occurring on the IO thread. Must be destroyed on the IO | 163 // For all the work occurring on the IO thread. Must be destroyed on the IO |
167 // thread. | 164 // thread. |
168 scoped_ptr<IOWorker> io_worker_; | 165 scoped_ptr<IOWorker> io_worker_; |
169 | 166 |
170 // Callback for GetGCMStatistics. | 167 // Callback for GetGCMStatistics. |
171 GetGCMStatisticsCallback request_gcm_statistics_callback_; | 168 GetGCMStatisticsCallback request_gcm_statistics_callback_; |
172 | 169 |
173 // Used to pass a weak pointer to the IO worker. | 170 // Used to pass a weak pointer to the IO worker. |
174 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; | 171 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; |
175 | 172 |
176 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); | 173 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); |
177 }; | 174 }; |
178 | 175 |
179 } // namespace gcm | 176 } // namespace gcm |
180 | 177 |
181 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ | 178 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ |
OLD | NEW |