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

Unified Diff: chrome/browser/chromeos/power/light_bar.cc

Issue 566993002: Add lucid sleep flag and debugging helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/power/light_bar.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/power/light_bar.cc
diff --git a/chrome/browser/chromeos/power/light_bar.cc b/chrome/browser/chromeos/power/light_bar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fce9171dcb2b1c05886a0a62b0dd9009d961da35
--- /dev/null
+++ b/chrome/browser/chromeos/power/light_bar.cc
@@ -0,0 +1,59 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/power/light_bar.h"
+
+#include <cstring> // needed for strlen()
+
+#include "base/command_line.h"
+#include "base/file_util.h"
Lei Zhang 2014/09/19 21:08:47 Please be aware that this is going away. Use base/
+#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
+#include "chromeos/chromeos_switches.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+
+namespace chromeos {
+
+namespace {
+const int kDarkSuspendDelaySeconds = 4;
+const char kLightBarControlPath[] =
+ "/sys/devices/virtual/chromeos/cros_ec/lightbar/sequence";
+const char kKonamiCommand[] = "KONAMI";
+
+} // namespace
+
+LightBar::LightBar()
+ : control_path_(base::FilePath(kLightBarControlPath)),
+ has_light_bar_(base::PathIsWritable(control_path_)) {
+ DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
+}
+
+LightBar::~LightBar() {
+ DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
+}
+
+void LightBar::DarkSuspendImminent() {
+ // The plan is to track the progress of push events and then re-suspend as
+ // soon as we know they have been processed. In the meanwhile, we can hack
+ // around this by just having the light bar delay for a long time so that
+ // people can at least start playing around with this feature for their apps.
+ //
+ // TODO(chirantan): Remove this once we can accurately track the progress of
+ // push events.
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ DBusThreadManager::Get()
+ ->GetPowerManagerClient()
+ ->GetSuspendReadinessCallback(),
+ base::TimeDelta::FromSeconds(kDarkSuspendDelaySeconds));
+
+ if (!has_light_bar_)
+ return;
+
+ if (base::WriteFile(control_path_, kKonamiCommand, strlen(kKonamiCommand)) !=
+ static_cast<int>(strlen(kKonamiCommand)))
+ PLOG(WARNING) << "Unable to flash light bar during dark resume.";
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/power/light_bar.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698