summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-19 17:29:04 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-19 17:29:04 +0000
commit9712e76ce7c2f10c797f791702e6e0776f0d9b79 (patch)
tree349b90a5a2d21656f9d6ee505b9746cf0c328374 /chromeos
parentf865e731c52608aecefd6dac2aa94f6b0b543a45 (diff)
downloadchromium_src-9712e76ce7c2f10c797f791702e6e0776f0d9b79.zip
chromium_src-9712e76ce7c2f10c797f791702e6e0776f0d9b79.tar.gz
chromium_src-9712e76ce7c2f10c797f791702e6e0776f0d9b79.tar.bz2
Change flag for PowerManagerClient (Take 2)
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. Original CL: https://codereview.chromium.org/189623002 Added paranoia checks (all trybot tests have passed) BUG=350170 TBR=derat@chromium.org, jennyz@chromium.org Review URL: https://codereview.chromium.org/199283003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/chromeos_switches.cc8
-rw-r--r--chromeos/chromeos_switches.h2
-rw-r--r--chromeos/dbus/power_manager_client.cc36
3 files changed, 37 insertions, 9 deletions
diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc
index 3a437e2..1e0c2c1 100644
--- a/chromeos/chromeos_switches.cc
+++ b/chromeos/chromeos_switches.cc
@@ -77,9 +77,6 @@ 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";
@@ -160,6 +157,11 @@ 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 8b51eda..077f5e4 100644
--- a/chromeos/chromeos_switches.h
+++ b/chromeos/chromeos_switches.h
@@ -42,7 +42,6 @@ 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 kEnterpriseEnableForcedReEnrollment[];
CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentInitialModulus[];
@@ -63,6 +62,7 @@ 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 9019dd9..bd2ec59 100644
--- a/chromeos/dbus/power_manager_client.cc
+++ b/chromeos/dbus/power_manager_client.cc
@@ -14,6 +14,8 @@
#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"
@@ -675,12 +677,12 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
// PowerManagerClient overrides:
virtual void Init(dbus::Bus* bus) OVERRIDE {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kEnableStubInteractive)) {
- const int kStatusUpdateMs = 1000;
+ ParseCommandLineSwitch();
+ if (power_cycle_delay_ != base::TimeDelta()) {
update_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kStatusUpdateMs), this,
- &PowerManagerClientStubImpl::UpdateStatus);
+ power_cycle_delay_,
+ this,
+ &PowerManagerClientStubImpl::UpdateStatus);
}
}
@@ -830,6 +832,30 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
BrightnessChanged(brightness_level, user_initiated));
}
+ void ParseCommandLineSwitch() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (!command_line || !command_line->HasSwitch(switches::kPowerStub))
+ return;
+ 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);
+ }
+ }
+
+ void 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);
+ }
+ }
+
+ base::TimeDelta power_cycle_delay_; // Time over which to cycle power state
bool discharging_;
int battery_percentage_;
double brightness_;