| 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 "components/gcm_driver/gcm_driver_desktop.h" | 5 #include "components/gcm_driver/gcm_driver_desktop.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "components/gcm_driver/gcm_account_mapper.h" | 17 #include "components/gcm_driver/gcm_account_mapper.h" |
| 18 #include "components/gcm_driver/gcm_app_handler.h" | 18 #include "components/gcm_driver/gcm_app_handler.h" |
| 19 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 19 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
| 20 #include "components/gcm_driver/gcm_client_factory.h" | 20 #include "components/gcm_driver/gcm_client_factory.h" |
| 21 #include "components/gcm_driver/gcm_delayed_task_controller.h" | 21 #include "components/gcm_driver/gcm_delayed_task_controller.h" |
| 22 #include "components/gcm_driver/system_encryptor.h" | 22 #include "components/gcm_driver/system_encryptor.h" |
| 23 #include "google_apis/gcm/engine/account_mapping.h" | 23 #include "google_apis/gcm/engine/account_mapping.h" |
| 24 #include "net/base/ip_endpoint.h" | 24 #include "net/base/ip_endpoint.h" |
| 25 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 26 | 26 |
| 27 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
| 28 #include "components/timers/alarm_timer.h" | 28 #include "components/timers/alarm_timer_chromeos.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 namespace gcm { | 31 namespace gcm { |
| 32 | 32 |
| 33 class GCMDriverDesktop::IOWorker : public GCMClient::Delegate { | 33 class GCMDriverDesktop::IOWorker : public GCMClient::Delegate { |
| 34 public: | 34 public: |
| 35 // Called on UI thread. | 35 // Called on UI thread. |
| 36 IOWorker(const scoped_refptr<base::SequencedTaskRunner>& ui_thread, | 36 IOWorker(const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
| 37 const scoped_refptr<base::SequencedTaskRunner>& io_thread); | 37 const scoped_refptr<base::SequencedTaskRunner>& io_thread); |
| 38 virtual ~IOWorker(); | 38 virtual ~IOWorker(); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 if (gcm_client_.get()) | 337 if (gcm_client_.get()) |
| 338 gcm_client_->SetLastTokenFetchTime(time); | 338 gcm_client_->SetLastTokenFetchTime(time); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void GCMDriverDesktop::IOWorker::WakeFromSuspendForHeartbeat(bool wake) { | 341 void GCMDriverDesktop::IOWorker::WakeFromSuspendForHeartbeat(bool wake) { |
| 342 #if defined(OS_CHROMEOS) | 342 #if defined(OS_CHROMEOS) |
| 343 DCHECK(io_thread_->RunsTasksOnCurrentThread()); | 343 DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
| 344 | 344 |
| 345 scoped_ptr<base::Timer> timer; | 345 scoped_ptr<base::Timer> timer; |
| 346 if (wake) | 346 if (wake) |
| 347 timer.reset(new timers::AlarmTimer(true, false)); | 347 timer.reset(new timers::SimpleAlarmTimer()); |
| 348 else | 348 else |
| 349 timer.reset(new base::Timer(true, false)); | 349 timer.reset(new base::Timer(true, false)); |
| 350 | 350 |
| 351 gcm_client_->UpdateHeartbeatTimer(timer.Pass()); | 351 gcm_client_->UpdateHeartbeatTimer(timer.Pass()); |
| 352 #endif | 352 #endif |
| 353 } | 353 } |
| 354 | 354 |
| 355 GCMDriverDesktop::GCMDriverDesktop( | 355 GCMDriverDesktop::GCMDriverDesktop( |
| 356 scoped_ptr<GCMClientFactory> gcm_client_factory, | 356 scoped_ptr<GCMClientFactory> gcm_client_factory, |
| 357 const GCMClient::ChromeBuildInfo& chrome_build_info, | 357 const GCMClient::ChromeBuildInfo& chrome_build_info, |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 836 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
| 837 | 837 |
| 838 // Normally request_gcm_statistics_callback_ would not be null. | 838 // Normally request_gcm_statistics_callback_ would not be null. |
| 839 if (!request_gcm_statistics_callback_.is_null()) | 839 if (!request_gcm_statistics_callback_.is_null()) |
| 840 request_gcm_statistics_callback_.Run(stats); | 840 request_gcm_statistics_callback_.Run(stats); |
| 841 else | 841 else |
| 842 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; | 842 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; |
| 843 } | 843 } |
| 844 | 844 |
| 845 } // namespace gcm | 845 } // namespace gcm |
| OLD | NEW |