Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Side by Side Diff: chromeos/dbus/fake_power_manager_client.cc

Issue 543303002: chromeos: power: Refactor RendererFreezer and add tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include base/macros.h Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/fake_power_manager_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8 #include "base/bind_helpers.h"
7 #include "base/time/time.h" 9 #include "base/time/time.h"
8 #include "chromeos/dbus/power_manager/policy.pb.h" 10 #include "chromeos/dbus/power_manager/policy.pb.h"
9 11
10 namespace chromeos { 12 namespace chromeos {
11 13
12 FakePowerManagerClient::FakePowerManagerClient() 14 FakePowerManagerClient::FakePowerManagerClient()
13 : num_request_restart_calls_(0), 15 : num_request_restart_calls_(0),
14 num_request_shutdown_calls_(0), 16 num_request_shutdown_calls_(0),
15 num_set_policy_calls_(0), 17 num_set_policy_calls_(0),
16 num_set_is_projecting_calls_(0), 18 num_set_is_projecting_calls_(0),
19 num_pending_suspend_readiness_callbacks_(0),
17 is_projecting_(false) { 20 is_projecting_(false) {
18 } 21 }
19 22
20 FakePowerManagerClient::~FakePowerManagerClient() { 23 FakePowerManagerClient::~FakePowerManagerClient() {
21 } 24 }
22 25
23 void FakePowerManagerClient::Init(dbus::Bus* bus) { 26 void FakePowerManagerClient::Init(dbus::Bus* bus) {
24 } 27 }
25 28
26 void FakePowerManagerClient::AddObserver(Observer* observer) { 29 void FakePowerManagerClient::AddObserver(Observer* observer) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 policy_ = policy; 81 policy_ = policy;
79 ++num_set_policy_calls_; 82 ++num_set_policy_calls_;
80 } 83 }
81 84
82 void FakePowerManagerClient::SetIsProjecting(bool is_projecting) { 85 void FakePowerManagerClient::SetIsProjecting(bool is_projecting) {
83 ++num_set_is_projecting_calls_; 86 ++num_set_is_projecting_calls_;
84 is_projecting_ = is_projecting; 87 is_projecting_ = is_projecting;
85 } 88 }
86 89
87 base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() { 90 base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() {
88 return base::Closure(); 91 ++num_pending_suspend_readiness_callbacks_;
92
93 return base::Bind(&FakePowerManagerClient::HandleSuspendReadiness,
94 base::Unretained(this));
89 } 95 }
90 96
91 int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() { 97 int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() {
92 return 0; 98 return num_pending_suspend_readiness_callbacks_;
93 } 99 }
94 100
95 void FakePowerManagerClient::SendSuspendImminent() { 101 void FakePowerManagerClient::SendSuspendImminent() {
96 FOR_EACH_OBSERVER(Observer, observers_, SuspendImminent()); 102 FOR_EACH_OBSERVER(Observer, observers_, SuspendImminent());
97 } 103 }
98 104
99 void FakePowerManagerClient::SendSuspendDone() { 105 void FakePowerManagerClient::SendSuspendDone() {
100 FOR_EACH_OBSERVER(Observer, observers_, SuspendDone(base::TimeDelta())); 106 FOR_EACH_OBSERVER(Observer, observers_, SuspendDone(base::TimeDelta()));
101 } 107 }
102 108
103 void FakePowerManagerClient::SendDarkSuspendImminent() { 109 void FakePowerManagerClient::SendDarkSuspendImminent() {
104 FOR_EACH_OBSERVER(Observer, observers_, DarkSuspendImminent()); 110 FOR_EACH_OBSERVER(Observer, observers_, DarkSuspendImminent());
105 } 111 }
106 112
107 void FakePowerManagerClient::SendPowerButtonEvent( 113 void FakePowerManagerClient::SendPowerButtonEvent(
108 bool down, 114 bool down,
109 const base::TimeTicks& timestamp) { 115 const base::TimeTicks& timestamp) {
110 FOR_EACH_OBSERVER(Observer, observers_, 116 FOR_EACH_OBSERVER(Observer, observers_,
111 PowerButtonEventReceived(down, timestamp)); 117 PowerButtonEventReceived(down, timestamp));
112 } 118 }
113 119
120 void FakePowerManagerClient::HandleSuspendReadiness() {
121 CHECK(num_pending_suspend_readiness_callbacks_ > 0);
122
123 --num_pending_suspend_readiness_callbacks_;
124 }
125
114 } // namespace chromeos 126 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_power_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698