summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/power_manager_client.cc
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/dbus/power_manager_client.cc
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/dbus/power_manager_client.cc')
-rw-r--r--chromeos/dbus/power_manager_client.cc36
1 files changed, 31 insertions, 5 deletions
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_;