| 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" |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 base::Unretained(io_worker_.get()), | 634 base::Unretained(io_worker_.get()), |
| 635 account_tokens)); | 635 account_tokens)); |
| 636 } | 636 } |
| 637 | 637 |
| 638 GCMClient::Result GCMDriverDesktop::EnsureStarted() { | 638 GCMClient::Result GCMDriverDesktop::EnsureStarted() { |
| 639 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 639 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
| 640 | 640 |
| 641 if (gcm_started_) | 641 if (gcm_started_) |
| 642 return GCMClient::SUCCESS; | 642 return GCMClient::SUCCESS; |
| 643 | 643 |
| 644 if (!gcm_enabled_) { | 644 if (!gcm_enabled_) |
| 645 // Poll for channel status in order to find out when it is re-enabled when | |
| 646 // GCM is currently disabled. | |
| 647 if (GCMDriver::IsAllowedForAllUsers()) | |
| 648 gcm_channel_status_syncer_->EnsureStarted(); | |
| 649 | |
| 650 return GCMClient::GCM_DISABLED; | 645 return GCMClient::GCM_DISABLED; |
| 651 } | |
| 652 | 646 |
| 653 // Have any app requested the service? | 647 // Have any app requested the service? |
| 654 if (app_handlers().empty()) | 648 if (app_handlers().empty()) |
| 655 return GCMClient::UNKNOWN_ERROR; | 649 return GCMClient::UNKNOWN_ERROR; |
| 656 | 650 |
| 657 // TODO(jianli): To be removed when sign-in enforcement is dropped. | 651 // TODO(jianli): To be removed when sign-in enforcement is dropped. |
| 658 if (!signed_in_ && !GCMDriver::IsAllowedForAllUsers()) | 652 if (!signed_in_ && !GCMDriver::IsAllowedForAllUsers()) |
| 659 return GCMClient::NOT_SIGNED_IN; | 653 return GCMClient::NOT_SIGNED_IN; |
| 660 | 654 |
| 661 DCHECK(!delayed_task_controller_); | 655 DCHECK(!delayed_task_controller_); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 770 |
| 777 // Normally request_gcm_statistics_callback_ would not be null. | 771 // Normally request_gcm_statistics_callback_ would not be null. |
| 778 if (!request_gcm_statistics_callback_.is_null()) | 772 if (!request_gcm_statistics_callback_.is_null()) |
| 779 request_gcm_statistics_callback_.Run(stats); | 773 request_gcm_statistics_callback_.Run(stats); |
| 780 else | 774 else |
| 781 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; | 775 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; |
| 782 } | 776 } |
| 783 | 777 |
| 784 } // namespace gcm | 778 } // namespace gcm |
| 785 | 779 |
| OLD | NEW |