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

Unified Diff: metrics_daemon.cc

Issue 2698002: Update metrics daemon to use new power manager signals for locking (4 of 7). (Closed) Base URL: ssh://git@chromiumos-git/metrics.git
Patch Set: Update to master Created 10 years, 7 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 | « metrics_daemon.h ('k') | metrics_daemon_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: metrics_daemon.cc
diff --git a/metrics_daemon.cc b/metrics_daemon.cc
index 04ad68631d5249aef47ba98f116a1567803cc10d..5ccc69487e6ed86b4b6df5a954a1950fb1b4195a 100644
--- a/metrics_daemon.cc
+++ b/metrics_daemon.cc
@@ -16,8 +16,7 @@ using base::TimeTicks;
#define SAFE_MESSAGE(e) (e.message ? e.message : "unknown error")
#define DBUS_IFACE_FLIMFLAM_MANAGER "org.chromium.flimflam.Manager"
-#define DBUS_IFACE_POWER_MANAGER "org.chromium.Power.Manager"
-#define DBUS_IFACE_SCREENSAVER_MANAGER "org.chromium.ScreenSaver.Manager"
+#define DBUS_IFACE_POWER_MANAGER "org.chromium.PowerManager"
#define DBUS_IFACE_SESSION_MANAGER "org.chromium.SessionManagerInterface"
// File to aggregate daily usage before sending to UMA.
@@ -63,13 +62,7 @@ const char* MetricsDaemon::kDBusMatches_[] = {
"type='signal',"
"interface='" DBUS_IFACE_POWER_MANAGER "',"
- "path='/',"
- "member='PowerStateChanged'",
-
- "type='signal',"
- "interface='" DBUS_IFACE_SCREENSAVER_MANAGER "',"
- "path='/',"
- "member='LockStateChanged'",
+ "path='/'"
"type='signal',"
"sender='org.chromium.SessionManager',"
@@ -91,12 +84,6 @@ const char* MetricsDaemon::kPowerStates_[] = {
};
// static
-const char* MetricsDaemon::kScreenSaverStates_[] = {
-#define STATE(name, capname) #name,
-#include "screensaver_states.h"
-};
-
-// static
const char* MetricsDaemon::kSessionStates_[] = {
#define STATE(name, capname) #name,
#include "session_states.h"
@@ -181,19 +168,16 @@ DBusHandlerResult MetricsDaemon::MessageFilter(DBusConnection* connection,
dbus_message_iter_get_basic(&iter, &state_name);
daemon->NetStateChanged(state_name, ticks);
} else if (strcmp(interface, DBUS_IFACE_POWER_MANAGER) == 0) {
- CHECK(strcmp(dbus_message_get_member(message),
- "PowerStateChanged") == 0);
-
- char* state_name;
- dbus_message_iter_get_basic(&iter, &state_name);
- daemon->PowerStateChanged(state_name, now);
- } else if (strcmp(interface, DBUS_IFACE_SCREENSAVER_MANAGER) == 0) {
- CHECK(strcmp(dbus_message_get_member(message),
- "LockStateChanged") == 0);
-
- char* state_name;
- dbus_message_iter_get_basic(&iter, &state_name);
- daemon->ScreenSaverStateChanged(state_name, now);
+ const char* member = dbus_message_get_member(message);
+ if (strcmp(member, "ScreenIsLocked") == 0) {
+ daemon->SetUserActiveState(false, now);
+ } else if (strcmp(member, "ScreenIsUnlocked") == 0) {
+ daemon->SetUserActiveState(true, now);
+ } else if (strcmp(member, "PowerStateChanged") == 0) {
+ char* state_name;
+ dbus_message_iter_get_basic(&iter, &state_name);
+ daemon->PowerStateChanged(state_name, now);
+ }
} else if (strcmp(interface, DBUS_IFACE_SESSION_MANAGER) == 0) {
CHECK(strcmp(dbus_message_get_member(message),
"SessionStateChanged") == 0);
@@ -265,23 +249,6 @@ MetricsDaemon::LookupPowerState(const char* state_name) {
return kUnknownPowerState;
}
-void MetricsDaemon::ScreenSaverStateChanged(const char* state_name, Time now) {
- DLOG(INFO) << "screen-saver state: " << state_name;
- screensaver_state_ = LookupScreenSaverState(state_name);
- SetUserActiveState(screensaver_state_ == kScreenSaverStateUnlocked, now);
-}
-
-MetricsDaemon::ScreenSaverState
-MetricsDaemon::LookupScreenSaverState(const char* state_name) {
- for (int i = 0; i < kNumberScreenSaverStates; i++) {
- if (strcmp(state_name, kScreenSaverStates_[i]) == 0) {
- return static_cast<ScreenSaverState>(i);
- }
- }
- DLOG(WARNING) << "unknown screen-saver state: " << state_name;
- return kUnknownScreenSaverState;
-}
-
void MetricsDaemon::SessionStateChanged(const char* state_name, Time now) {
DLOG(INFO) << "user session state: " << state_name;
session_state_ = LookupSessionState(state_name);
« no previous file with comments | « metrics_daemon.h ('k') | metrics_daemon_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698