| 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 #include "chrome/browser/services/gcm/gcm_service.h" | 5 #include "chrome/browser/services/gcm/gcm_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 const std::string& message_id, | 139 const std::string& message_id, |
| 140 GCMClient::Result result) OVERRIDE; | 140 GCMClient::Result result) OVERRIDE; |
| 141 virtual void OnMessageReceived( | 141 virtual void OnMessageReceived( |
| 142 const std::string& app_id, | 142 const std::string& app_id, |
| 143 const GCMClient::IncomingMessage& message) OVERRIDE; | 143 const GCMClient::IncomingMessage& message) OVERRIDE; |
| 144 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; | 144 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; |
| 145 virtual void OnMessageSendError( | 145 virtual void OnMessageSendError( |
| 146 const std::string& app_id, | 146 const std::string& app_id, |
| 147 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; | 147 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; |
| 148 virtual void OnGCMReady() OVERRIDE; | 148 virtual void OnGCMReady() OVERRIDE; |
| 149 virtual void OnActivityRecorded() OVERRIDE; | |
| 150 | 149 |
| 151 // Called on IO thread. | 150 // Called on IO thread. |
| 152 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory, | 151 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory, |
| 153 const base::FilePath& store_path, | 152 const base::FilePath& store_path, |
| 154 const std::vector<std::string>& account_ids, | 153 const std::vector<std::string>& account_ids, |
| 155 const scoped_refptr<net::URLRequestContextGetter>& | 154 const scoped_refptr<net::URLRequestContextGetter>& |
| 156 url_request_context_getter); | 155 url_request_context_getter); |
| 157 void Load(const base::WeakPtr<GCMService>& service); | 156 void Load(const base::WeakPtr<GCMService>& service); |
| 158 void Stop(); | 157 void Stop(); |
| 159 void CheckOut(); | 158 void CheckOut(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 send_error_details)); | 289 send_error_details)); |
| 291 } | 290 } |
| 292 | 291 |
| 293 void GCMService::IOWorker::OnGCMReady() { | 292 void GCMService::IOWorker::OnGCMReady() { |
| 294 content::BrowserThread::PostTask(content::BrowserThread::UI, | 293 content::BrowserThread::PostTask(content::BrowserThread::UI, |
| 295 FROM_HERE, | 294 FROM_HERE, |
| 296 base::Bind(&GCMService::GCMClientReady, | 295 base::Bind(&GCMService::GCMClientReady, |
| 297 service_)); | 296 service_)); |
| 298 } | 297 } |
| 299 | 298 |
| 300 void GCMService::IOWorker::OnActivityRecorded() { | |
| 301 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | |
| 302 // When an activity is recorded, get all the stats and refresh the UI of | |
| 303 // gcm-internals page. | |
| 304 GetGCMStatistics(false); | |
| 305 } | |
| 306 | |
| 307 void GCMService::IOWorker::Load(const base::WeakPtr<GCMService>& service) { | 299 void GCMService::IOWorker::Load(const base::WeakPtr<GCMService>& service) { |
| 308 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 300 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 309 | 301 |
| 310 service_ = service; | 302 service_ = service; |
| 311 gcm_client_->Load(); | 303 gcm_client_->Load(); |
| 312 } | 304 } |
| 313 | 305 |
| 314 void GCMService::IOWorker::Stop() { | 306 void GCMService::IOWorker::Stop() { |
| 315 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 307 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 316 | 308 |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 return iter == app_handlers_.end() ? &default_app_handler_ : iter->second; | 841 return iter == app_handlers_.end() ? &default_app_handler_ : iter->second; |
| 850 } | 842 } |
| 851 | 843 |
| 852 void GCMService::GetGCMStatisticsFinished( | 844 void GCMService::GetGCMStatisticsFinished( |
| 853 GCMClient::GCMStatistics stats) { | 845 GCMClient::GCMStatistics stats) { |
| 854 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 846 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 855 request_gcm_statistics_callback_.Run(stats); | 847 request_gcm_statistics_callback_.Run(stats); |
| 856 } | 848 } |
| 857 | 849 |
| 858 } // namespace gcm | 850 } // namespace gcm |
| OLD | NEW |