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

Side by Side Diff: ash/mus/user_activity_forwarder.cc

Issue 2639703004: mus: Forward user activity from window server to detector. (Closed)
Patch Set: add comments to UserActivityPowerManagerNotifier Created 3 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/mus/user_activity_forwarder.h"
6
7 #include <cmath>
8
9 #include "services/service_manager/public/cpp/connector.h"
10 #include "services/ui/public/interfaces/constants.mojom.h"
11 #include "ui/base/user_activity/user_activity_detector.h"
12
13 namespace ash {
14 namespace mus {
15
16 UserActivityForwarder::UserActivityForwarder(
17 service_manager::Connector* connector,
18 ui::UserActivityDetector* detector)
19 : user_activity_observer_binding_(this), user_activity_detector_(detector) {
20 DCHECK(detector);
21
22 // |connector| is null in some tests.
23 if (connector) {
24 // Round UserActivityDetector's notification interval up to the nearest
25 // second (the granularity exposed by UserActivityMonitor).
26 const uint32_t kNotifyIntervalSec = static_cast<uint32_t>(
sadrul 2017/01/18 22:10:58 constexpr?
Daniel Erat 2017/01/19 01:56:24 i tried this initially, but the UserActivityDetect
27 ceil(ui::UserActivityDetector::kNotifyIntervalMs / 1000.0));
28
29 connector->BindInterface(ui::mojom::kServiceName, &user_activity_monitor_);
30 user_activity_monitor_->AddUserActivityObserver(
31 kNotifyIntervalSec,
32 user_activity_observer_binding_.CreateInterfacePtrAndBind());
33 }
34 }
35
36 UserActivityForwarder::~UserActivityForwarder() {}
37
38 void UserActivityForwarder::OnUserActivity() {
39 user_activity_detector_->HandleExternalUserActivity();
40 }
41
42 } // namespace mus
43 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698