| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/dbus/fake_power_manager_client.h" | 5 #include "chromeos/dbus/fake_power_manager_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 : power_manager::PowerSupplyProperties_ExternalPower_AC); | 129 : power_manager::PowerSupplyProperties_ExternalPower_AC); |
| 130 break; | 130 break; |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 NotifyObservers(); | 134 NotifyObservers(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() { | 137 base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() { |
| 138 ++num_pending_suspend_readiness_callbacks_; | 138 ++num_pending_suspend_readiness_callbacks_; |
| 139 | |
| 140 return base::Bind(&FakePowerManagerClient::HandleSuspendReadiness, | 139 return base::Bind(&FakePowerManagerClient::HandleSuspendReadiness, |
| 141 base::Unretained(this)); | 140 base::Unretained(this)); |
| 142 } | 141 } |
| 143 | 142 |
| 144 int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() { | 143 int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() { |
| 145 return num_pending_suspend_readiness_callbacks_; | 144 return num_pending_suspend_readiness_callbacks_; |
| 146 } | 145 } |
| 147 | 146 |
| 147 void FakePowerManagerClient::Reset() { |
| 148 observers_.Clear(); |
| 149 policy_ = power_manager::PowerManagementPolicy(); |
| 150 props_ = power_manager::PowerSupplyProperties(); |
| 151 num_request_restart_calls_ = 0; |
| 152 num_request_shutdown_calls_ = 0; |
| 153 num_set_policy_calls_ = 0; |
| 154 num_set_is_projecting_calls_ = 0; |
| 155 num_pending_suspend_readiness_callbacks_ = 0; |
| 156 is_projecting_ = false; |
| 157 video_activity_reports_.clear(); |
| 158 } |
| 159 |
| 148 bool FakePowerManagerClient::PopVideoActivityReport() { | 160 bool FakePowerManagerClient::PopVideoActivityReport() { |
| 149 CHECK(!video_activity_reports_.empty()); | 161 CHECK(!video_activity_reports_.empty()); |
| 150 bool fullscreen = video_activity_reports_.front(); | 162 bool fullscreen = video_activity_reports_.front(); |
| 151 video_activity_reports_.pop_front(); | 163 video_activity_reports_.pop_front(); |
| 152 return fullscreen; | 164 return fullscreen; |
| 153 } | 165 } |
| 154 | 166 |
| 155 void FakePowerManagerClient::SendSuspendImminent() { | 167 void FakePowerManagerClient::SendSuspendImminent() { |
| 156 FOR_EACH_OBSERVER(Observer, observers_, SuspendImminent()); | 168 FOR_EACH_OBSERVER(Observer, observers_, SuspendImminent()); |
| 157 if (render_process_manager_delegate_) | 169 if (render_process_manager_delegate_) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 186 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(props_)); | 198 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(props_)); |
| 187 } | 199 } |
| 188 | 200 |
| 189 void FakePowerManagerClient::HandleSuspendReadiness() { | 201 void FakePowerManagerClient::HandleSuspendReadiness() { |
| 190 CHECK(num_pending_suspend_readiness_callbacks_ > 0); | 202 CHECK(num_pending_suspend_readiness_callbacks_ > 0); |
| 191 | 203 |
| 192 --num_pending_suspend_readiness_callbacks_; | 204 --num_pending_suspend_readiness_callbacks_; |
| 193 } | 205 } |
| 194 | 206 |
| 195 } // namespace chromeos | 207 } // namespace chromeos |
| OLD | NEW |