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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 bool IsStarted() const override; | 74 bool IsStarted() const override; |
75 bool IsConnected() const override; | 75 bool IsConnected() const override; |
76 void GetGCMStatistics(const GetGCMStatisticsCallback& callback, | 76 void GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
77 bool clear_logs) override; | 77 bool clear_logs) override; |
78 void SetGCMRecording(const GetGCMStatisticsCallback& callback, | 78 void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
79 bool recording) override; | 79 bool recording) override; |
80 void SetAccountTokens( | 80 void SetAccountTokens( |
81 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; | 81 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; |
82 void UpdateAccountMapping(const AccountMapping& account_mapping) override; | 82 void UpdateAccountMapping(const AccountMapping& account_mapping) override; |
83 void RemoveAccountMapping(const std::string& account_id) override; | 83 void RemoveAccountMapping(const std::string& account_id) override; |
| 84 base::Time GetLastTokenFetchTime() override; |
| 85 void SetLastTokenFetchTime(const base::Time& time) override; |
84 | 86 |
85 // Exposed for testing purpose. | 87 // Exposed for testing purpose. |
86 bool gcm_enabled() const { return gcm_enabled_; } | 88 bool gcm_enabled() const { return gcm_enabled_; } |
87 GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() { | 89 GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() { |
88 return gcm_channel_status_syncer_.get(); | 90 return gcm_channel_status_syncer_.get(); |
89 } | 91 } |
90 | 92 |
91 protected: | 93 protected: |
92 // GCMDriver implementation: | 94 // GCMDriver implementation: |
93 GCMClient::Result EnsureStarted() override; | 95 GCMClient::Result EnsureStarted() override; |
(...skipping 21 matching lines...) Expand all Loading... |
115 const GCMClient::OutgoingMessage& message); | 117 const GCMClient::OutgoingMessage& message); |
116 | 118 |
117 // Callbacks posted from IO thread to UI thread. | 119 // Callbacks posted from IO thread to UI thread. |
118 void MessageReceived(const std::string& app_id, | 120 void MessageReceived(const std::string& app_id, |
119 const GCMClient::IncomingMessage& message); | 121 const GCMClient::IncomingMessage& message); |
120 void MessagesDeleted(const std::string& app_id); | 122 void MessagesDeleted(const std::string& app_id); |
121 void MessageSendError(const std::string& app_id, | 123 void MessageSendError(const std::string& app_id, |
122 const GCMClient::SendErrorDetails& send_error_details); | 124 const GCMClient::SendErrorDetails& send_error_details); |
123 void SendAcknowledged(const std::string& app_id, | 125 void SendAcknowledged(const std::string& app_id, |
124 const std::string& message_id); | 126 const std::string& message_id); |
125 void GCMClientReady( | 127 void GCMClientReady(const std::vector<AccountMapping>& account_mappings, |
126 const std::vector<AccountMapping>& account_mappings); | 128 const base::Time& last_token_fetch_time); |
127 void OnConnected(const net::IPEndPoint& ip_endpoint); | 129 void OnConnected(const net::IPEndPoint& ip_endpoint); |
128 void OnDisconnected(); | 130 void OnDisconnected(); |
129 | 131 |
130 void GetGCMStatisticsFinished(const GCMClient::GCMStatistics& stats); | 132 void GetGCMStatisticsFinished(const GCMClient::GCMStatistics& stats); |
131 | 133 |
132 scoped_ptr<GCMChannelStatusSyncer> gcm_channel_status_syncer_; | 134 scoped_ptr<GCMChannelStatusSyncer> gcm_channel_status_syncer_; |
133 | 135 |
134 // Flag to indicate whether the user is signed in to a GAIA account. | 136 // Flag to indicate whether the user is signed in to a GAIA account. |
135 // TODO(jianli): To be removed when sign-in enforcement is dropped. | 137 // TODO(jianli): To be removed when sign-in enforcement is dropped. |
136 bool signed_in_; | 138 bool signed_in_; |
(...skipping 10 matching lines...) Expand all Loading... |
147 // it may be out of date while connection changes are happening. | 149 // it may be out of date while connection changes are happening. |
148 bool connected_; | 150 bool connected_; |
149 | 151 |
150 // List of observers to notify when connection state changes. | 152 // List of observers to notify when connection state changes. |
151 // Makes sure list is empty on destruction. | 153 // Makes sure list is empty on destruction. |
152 ObserverList<GCMConnectionObserver, true> connection_observer_list_; | 154 ObserverList<GCMConnectionObserver, true> connection_observer_list_; |
153 | 155 |
154 // Account mapper. Only works when user is signed in. | 156 // Account mapper. Only works when user is signed in. |
155 scoped_ptr<GCMAccountMapper> account_mapper_; | 157 scoped_ptr<GCMAccountMapper> account_mapper_; |
156 | 158 |
| 159 // Time of last token fetching. |
| 160 base::Time last_token_fetch_time_; |
| 161 |
157 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 162 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
158 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 163 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
159 | 164 |
160 scoped_ptr<GCMDelayedTaskController> delayed_task_controller_; | 165 scoped_ptr<GCMDelayedTaskController> delayed_task_controller_; |
161 | 166 |
162 // For all the work occurring on the IO thread. Must be destroyed on the IO | 167 // For all the work occurring on the IO thread. Must be destroyed on the IO |
163 // thread. | 168 // thread. |
164 scoped_ptr<IOWorker> io_worker_; | 169 scoped_ptr<IOWorker> io_worker_; |
165 | 170 |
166 // Callback for GetGCMStatistics. | 171 // Callback for GetGCMStatistics. |
167 GetGCMStatisticsCallback request_gcm_statistics_callback_; | 172 GetGCMStatisticsCallback request_gcm_statistics_callback_; |
168 | 173 |
169 // Used to pass a weak pointer to the IO worker. | 174 // Used to pass a weak pointer to the IO worker. |
170 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; | 175 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; |
171 | 176 |
172 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); | 177 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); |
173 }; | 178 }; |
174 | 179 |
175 } // namespace gcm | 180 } // namespace gcm |
176 | 181 |
177 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ | 182 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ |
OLD | NEW |