From 719f1eec7fb8d9fa2837bdffd35820c15cc11535 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Tue, 11 Mar 2014 02:16:05 +0000 Subject: Revert 256085 "Change flag for PowerManagerClient" Broke all tests on CrOS: http://build.chromium.org/p/chromium.chromiumos/buildstatus?builder=Linux%20ChromiumOS%20Tests%20%282%29&number=22204 > Change flag for PowerManagerClient > > Replace the generic --enable-stub-interactive with a power manager > specific --power-stub flag. > > This was separated out of an earlier CL that became network specific. > > BUG=350170 > R=derat@chromium.org, jennyz@chromium.org > > Review URL: https://codereview.chromium.org/189623002 TBR=stevenjb@chromium.org Review URL: https://codereview.chromium.org/193993003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256096 0039d316-1c4b-4281-b951-d872f2087c98 --- chromeos/chromeos_switches.cc | 8 ++--- chromeos/chromeos_switches.h | 2 +- chromeos/dbus/power_manager_client.cc | 62 +++++++++-------------------------- 3 files changed, 20 insertions(+), 52 deletions(-) (limited to 'chromeos') diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index db89283..cb862c9 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -83,6 +83,9 @@ const char kEnableCarrierSwitching[] = "enable-carrier-switching"; const char kEnableNetworkPortalNotification[] = "enable-network-portal-notification"; +// Enable "interactive" mode for stub implemenations (e.g. PowerManagerClient) +const char kEnableStubInteractive[] = "enable-stub-interactive"; + // Enables touchpad three-finger-click as middle button. const char kEnableTouchpadThreeFingerClick[] = "enable-touchpad-three-finger-click"; @@ -162,11 +165,6 @@ const char kOobeSkipPostLogin[] = "oobe-skip-postlogin"; // Interval at which we check for total time on OOBE. const char kOobeTimerInterval[] = "oobe-timer-interval"; -// Specifies power stub behavior: -// 'cycle=2' - Cycles power states every 2 seconds. -// See FakeDBusThreadManager::ParsePowerCommandLineSwitch for full details. -const char kPowerStub[] = "power-stub"; - // Specifies network stub behavior. If this switch is not specified, // ethernet, wifi and vpn are enabled by default, and transitions occur // instantaneously. Multiple options can be comma separated (no spaces). diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 807793c..f8b928b 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -44,6 +44,7 @@ CHROMEOS_EXPORT extern const char kEnableCarrierSwitching[]; CHROMEOS_EXPORT extern const char kEnableKioskMode[]; CHROMEOS_EXPORT extern const char kEnableNetworkPortalNotification[]; CHROMEOS_EXPORT extern const char kEnableRequestTabletSite[]; +CHROMEOS_EXPORT extern const char kEnableStubInteractive[]; CHROMEOS_EXPORT extern const char kEnableTouchpadThreeFingerClick[]; CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentInitialModulus[]; CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentModulusLimit[]; @@ -64,7 +65,6 @@ CHROMEOS_EXPORT extern const char kLoginUser[]; CHROMEOS_EXPORT extern const char kNaturalScrollDefault[]; CHROMEOS_EXPORT extern const char kOobeSkipPostLogin[]; CHROMEOS_EXPORT extern const char kOobeTimerInterval[]; -CHROMEOS_EXPORT extern const char kPowerStub[]; CHROMEOS_EXPORT extern const char kShillStub[]; CHROMEOS_EXPORT extern const char kSkipHWIDCheck[]; CHROMEOS_EXPORT extern const char kSmsTestMessages[]; diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc index 4335b6a..9019dd9 100644 --- a/chromeos/dbus/power_manager_client.cc +++ b/chromeos/dbus/power_manager_client.cc @@ -14,8 +14,6 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/observer_list.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_split.h" #include "base/strings/stringprintf.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" @@ -656,22 +654,20 @@ class PowerManagerClientImpl : public PowerManagerClient { DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl); }; -// The fake PowerManagerClient implementation used on Linux desktop. This -// can simulate a battery draining/charging, etc, for testing UI. -class FakePowerManagerClient : public PowerManagerClient { +// The PowerManagerClient implementation used on Linux desktop, +// which does nothing. +class PowerManagerClientStubImpl : public PowerManagerClient { public: - FakePowerManagerClient() + PowerManagerClientStubImpl() : discharging_(true), battery_percentage_(40), brightness_(50.0), pause_count_(2), cycle_count_(0), num_pending_suspend_readiness_callbacks_(0), - weak_ptr_factory_(this) { - ParseCommandLineSwitch(); - } + weak_ptr_factory_(this) {} - virtual ~FakePowerManagerClient() {} + virtual ~PowerManagerClientStubImpl() {} int num_pending_suspend_readiness_callbacks() const { return num_pending_suspend_readiness_callbacks_; @@ -679,11 +675,12 @@ class FakePowerManagerClient : public PowerManagerClient { // PowerManagerClient overrides: virtual void Init(dbus::Bus* bus) OVERRIDE { - if (power_cycle_delay_ != base::TimeDelta()) { + if (CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kEnableStubInteractive)) { + const int kStatusUpdateMs = 1000; update_timer_.Start(FROM_HERE, - power_cycle_delay_, - this, - &FakePowerManagerClient::UpdateStatus); + base::TimeDelta::FromMilliseconds(kStatusUpdateMs), this, + &PowerManagerClientStubImpl::UpdateStatus); } } @@ -731,7 +728,7 @@ class FakePowerManagerClient : public PowerManagerClient { virtual void RequestStatusUpdate() OVERRIDE { base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&FakePowerManagerClient::UpdateStatus, + base::Bind(&PowerManagerClientStubImpl::UpdateStatus, weak_ptr_factory_.GetWeakPtr())); } @@ -746,7 +743,7 @@ class FakePowerManagerClient : public PowerManagerClient { virtual void SetIsProjecting(bool is_projecting) OVERRIDE {} virtual base::Closure GetSuspendReadinessCallback() OVERRIDE { num_pending_suspend_readiness_callbacks_++; - return base::Bind(&FakePowerManagerClient::HandleSuspendReadiness, + return base::Bind(&PowerManagerClientStubImpl::HandleSuspendReadiness, weak_ptr_factory_.GetWeakPtr()); } virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE { @@ -833,40 +830,13 @@ class FakePowerManagerClient : public PowerManagerClient { BrightnessChanged(brightness_level, user_initiated)); } - void ParseCommandLineSwitch() { - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kPowerStub)) { - std::string option_str = - command_line->GetSwitchValueASCII(switches::kPowerStub); - base::StringPairs string_pairs; - base::SplitStringIntoKeyValuePairs(option_str, '=', ',', &string_pairs); - for (base::StringPairs::iterator iter = string_pairs.begin(); - iter != string_pairs.end(); ++iter) { - ParseOption((*iter).first, (*iter).second); - } - return; - } - } - - bool ParseOption(const std::string& arg0, const std::string& arg1) { - if (arg0 == "cycle" || arg0 == "interactive") { - int seconds = 1; - if (!arg1.empty()) - base::StringToInt(arg1, &seconds); - power_cycle_delay_ = base::TimeDelta::FromSeconds(seconds); - return true; - } - return false; - } - - base::TimeDelta power_cycle_delay_; // Time over which to cycle power state bool discharging_; int battery_percentage_; double brightness_; int pause_count_; int cycle_count_; ObserverList observers_; - base::RepeatingTimer update_timer_; + base::RepeatingTimer update_timer_; power_manager::PowerSupplyProperties props_; // Number of callbacks returned by GetSuspendReadinessCallback() but not yet @@ -875,7 +845,7 @@ class FakePowerManagerClient : public PowerManagerClient { // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_; }; PowerManagerClient::PowerManagerClient() { @@ -890,7 +860,7 @@ PowerManagerClient* PowerManagerClient::Create( if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) return new PowerManagerClientImpl(); DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); - return new FakePowerManagerClient(); + return new PowerManagerClientStubImpl(); } } // namespace chromeos -- cgit v1.1