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

Side by Side Diff: chrome/browser/chromeos/power/light_bar.cc

Issue 589723003: Enable dark_resume_always workaround if the wake-on-packets flag is set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move code to LightBar class 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/power/light_bar.h" 5 #include "chrome/browser/chromeos/power/light_bar.h"
6 6
7 #include <cstring> // needed for strlen() 7 #include <cstring> // needed for strlen()
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "chromeos/chromeos_switches.h" 13 #include "chromeos/chromeos_switches.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 namespace { 18 namespace {
19 const int kDarkSuspendDelaySeconds = 4; 19 const int kDarkSuspendDelaySeconds = 4;
20 const char kLightBarControlPath[] = 20 const char kLightBarControlPath[] =
21 "/sys/devices/virtual/chromeos/cros_ec/lightbar/sequence"; 21 "/sys/devices/virtual/chromeos/cros_ec/lightbar/sequence";
22 const char kKonamiCommand[] = "KONAMI"; 22 const char kKonamiCommand[] = "KONAMI";
23 23
24 // TODO(chirantan): These are used by a temporary workaround for lucid sleep and
25 // should be removed once the proper implementation is ready (crbug.com/414949).
26 const char kDarkResumeAlwaysFile[] = "/sys/power/dark_resume_always";
27 const char kEnableDarkResumeAlways[] = "1";
28
24 } // namespace 29 } // namespace
25 30
26 LightBar::LightBar() 31 LightBar::LightBar()
27 : control_path_(base::FilePath(kLightBarControlPath)), 32 : control_path_(base::FilePath(kLightBarControlPath)),
28 has_light_bar_(base::PathIsWritable(control_path_)) { 33 has_light_bar_(base::PathIsWritable(control_path_)) {
29 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); 34 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
35
36 // Until the kernel can properly detect the wakeup source, we need to use a
37 // hack to tell the kernel to always enter dark resume. Chrome can then
38 // detect any user activity and have the power manager transition out of dark
39 // resume into regular resume. We don't care if the write succeeds or not
40 // because most devices will not have this file.
41 //
42 // TODO(chirantan): Remove this once we can properly detect the wakeup
43 // source (crbug.com/414949).
44 base::WriteFile(base::FilePath(kDarkResumeAlwaysFile),
45 kEnableDarkResumeAlways,
46 strlen(kEnableDarkResumeAlways));
47
Daniel Erat 2014/09/22 19:52:00 nit: delete extra blank line
30 } 48 }
31 49
32 LightBar::~LightBar() { 50 LightBar::~LightBar() {
33 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); 51 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
34 } 52 }
35 53
36 void LightBar::DarkSuspendImminent() { 54 void LightBar::DarkSuspendImminent() {
37 // The plan is to track the progress of push events and then re-suspend as 55 // The plan is to track the progress of push events and then re-suspend as
38 // soon as we know they have been processed. In the meanwhile, we can hack 56 // soon as we know they have been processed. In the meanwhile, we can hack
39 // around this by just having the light bar delay for a long time so that 57 // around this by just having the light bar delay for a long time so that
(...skipping 10 matching lines...) Expand all
50 68
51 if (!has_light_bar_) 69 if (!has_light_bar_)
52 return; 70 return;
53 71
54 if (base::WriteFile(control_path_, kKonamiCommand, strlen(kKonamiCommand)) != 72 if (base::WriteFile(control_path_, kKonamiCommand, strlen(kKonamiCommand)) !=
55 static_cast<int>(strlen(kKonamiCommand))) 73 static_cast<int>(strlen(kKonamiCommand)))
56 PLOG(WARNING) << "Unable to flash light bar during dark resume."; 74 PLOG(WARNING) << "Unable to flash light bar during dark resume.";
57 } 75 }
58 76
59 } // namespace chromeos 77 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698