| 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 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace gcm { | 38 namespace gcm { |
| 39 | 39 |
| 40 class GCMAccountMapper; | 40 class GCMAccountMapper; |
| 41 class GCMAppHandler; | 41 class GCMAppHandler; |
| 42 class GCMClientFactory; | 42 class GCMClientFactory; |
| 43 class GCMDelayedTaskController; | 43 class GCMDelayedTaskController; |
| 44 | 44 |
| 45 // GCMDriver implementation for desktop and Chrome OS, using GCMClient. | 45 // GCMDriver implementation for desktop and Chrome OS, using GCMClient. |
| 46 class GCMDriverDesktop : public GCMDriver { | 46 class GCMDriverDesktop : public GCMDriver, |
| 47 public InstanceIDStore { |
| 47 public: | 48 public: |
| 48 GCMDriverDesktop( | 49 GCMDriverDesktop( |
| 49 scoped_ptr<GCMClientFactory> gcm_client_factory, | 50 scoped_ptr<GCMClientFactory> gcm_client_factory, |
| 50 const GCMClient::ChromeBuildInfo& chrome_build_info, | 51 const GCMClient::ChromeBuildInfo& chrome_build_info, |
| 51 const std::string& channel_status_request_url, | 52 const std::string& channel_status_request_url, |
| 52 const std::string& user_agent, | 53 const std::string& user_agent, |
| 53 PrefService* prefs, | 54 PrefService* prefs, |
| 54 const base::FilePath& store_path, | 55 const base::FilePath& store_path, |
| 55 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 56 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 56 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, | 57 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 bool clear_logs) override; | 77 bool clear_logs) override; |
| 77 void SetGCMRecording(const GetGCMStatisticsCallback& callback, | 78 void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
| 78 bool recording) override; | 79 bool recording) override; |
| 79 void SetAccountTokens( | 80 void SetAccountTokens( |
| 80 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; | 81 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; |
| 81 void UpdateAccountMapping(const AccountMapping& account_mapping) override; | 82 void UpdateAccountMapping(const AccountMapping& account_mapping) override; |
| 82 void RemoveAccountMapping(const std::string& account_id) override; | 83 void RemoveAccountMapping(const std::string& account_id) override; |
| 83 base::Time GetLastTokenFetchTime() override; | 84 base::Time GetLastTokenFetchTime() override; |
| 84 void SetLastTokenFetchTime(const base::Time& time) override; | 85 void SetLastTokenFetchTime(const base::Time& time) override; |
| 85 void WakeFromSuspendForHeartbeat(bool wake) override; | 86 void WakeFromSuspendForHeartbeat(bool wake) override; |
| 87 InstanceIDStore* GetInstanceIDStore() override; |
| 88 |
| 89 // InstanceIDStore overrides: |
| 90 void AddInstanceIDData(const std::string& app_id, |
| 91 const std::string& instance_id_data) override; |
| 92 void RemoveInstanceIDData(const std::string& app_id) override; |
| 93 void GetInstanceIDData(const std::string& app_id, |
| 94 const GetInstanceIDDataCallback& callback) override; |
| 86 | 95 |
| 87 // Exposed for testing purpose. | 96 // Exposed for testing purpose. |
| 88 bool gcm_enabled() const { return gcm_enabled_; } | 97 bool gcm_enabled() const { return gcm_enabled_; } |
| 89 GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() { | 98 GCMChannelStatusSyncer* gcm_channel_status_syncer_for_testing() { |
| 90 return gcm_channel_status_syncer_.get(); | 99 return gcm_channel_status_syncer_.get(); |
| 91 } | 100 } |
| 92 | 101 |
| 93 protected: | 102 protected: |
| 94 // GCMDriver implementation: | 103 // GCMDriver implementation: |
| 95 GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) override; | 104 GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) override; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 123 void MessageSendError(const std::string& app_id, | 132 void MessageSendError(const std::string& app_id, |
| 124 const GCMClient::SendErrorDetails& send_error_details); | 133 const GCMClient::SendErrorDetails& send_error_details); |
| 125 void SendAcknowledged(const std::string& app_id, | 134 void SendAcknowledged(const std::string& app_id, |
| 126 const std::string& message_id); | 135 const std::string& message_id); |
| 127 void GCMClientReady(const std::vector<AccountMapping>& account_mappings, | 136 void GCMClientReady(const std::vector<AccountMapping>& account_mappings, |
| 128 const base::Time& last_token_fetch_time); | 137 const base::Time& last_token_fetch_time); |
| 129 void OnConnected(const net::IPEndPoint& ip_endpoint); | 138 void OnConnected(const net::IPEndPoint& ip_endpoint); |
| 130 void OnDisconnected(); | 139 void OnDisconnected(); |
| 131 | 140 |
| 132 void GetGCMStatisticsFinished(const GCMClient::GCMStatistics& stats); | 141 void GetGCMStatisticsFinished(const GCMClient::GCMStatistics& stats); |
| 142 void GetInstanceIDDataFinished(const std::string& app_id, |
| 143 const std::string& instance_id_data); |
| 133 | 144 |
| 134 scoped_ptr<GCMChannelStatusSyncer> gcm_channel_status_syncer_; | 145 scoped_ptr<GCMChannelStatusSyncer> gcm_channel_status_syncer_; |
| 135 | 146 |
| 136 // Flag to indicate whether the user is signed in to a GAIA account. | 147 // Flag to indicate whether the user is signed in to a GAIA account. |
| 137 bool signed_in_; | 148 bool signed_in_; |
| 138 | 149 |
| 139 // Flag to indicate if GCM is started. | 150 // Flag to indicate if GCM is started. |
| 140 bool gcm_started_; | 151 bool gcm_started_; |
| 141 | 152 |
| 142 // Flag to indicate if GCM is enabled. | 153 // Flag to indicate if GCM is enabled. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 165 // sending heartbeat messages. | 176 // sending heartbeat messages. |
| 166 bool wake_from_suspend_enabled_; | 177 bool wake_from_suspend_enabled_; |
| 167 | 178 |
| 168 // For all the work occurring on the IO thread. Must be destroyed on the IO | 179 // For all the work occurring on the IO thread. Must be destroyed on the IO |
| 169 // thread. | 180 // thread. |
| 170 scoped_ptr<IOWorker> io_worker_; | 181 scoped_ptr<IOWorker> io_worker_; |
| 171 | 182 |
| 172 // Callback for GetGCMStatistics. | 183 // Callback for GetGCMStatistics. |
| 173 GetGCMStatisticsCallback request_gcm_statistics_callback_; | 184 GetGCMStatisticsCallback request_gcm_statistics_callback_; |
| 174 | 185 |
| 186 // Callbacks for GetInstanceIDData. |
| 187 std::map<std::string, GetInstanceIDDataCallback> |
| 188 get_instance_id_data_callbacks_; |
| 189 |
| 175 // Used to pass a weak pointer to the IO worker. | 190 // Used to pass a weak pointer to the IO worker. |
| 176 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; | 191 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; |
| 177 | 192 |
| 178 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); | 193 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); |
| 179 }; | 194 }; |
| 180 | 195 |
| 181 } // namespace gcm | 196 } // namespace gcm |
| 182 | 197 |
| 183 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ | 198 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ |
| OLD | NEW |