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

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

Issue 2639703004: mus: Forward user activity from window server to detector. (Closed)
Patch Set: 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(connector);
21 DCHECK(detector);
22
23 // Round UserActivityDetector's notification interval up to the nearest second
24 // (the granularity exposed by UserActivityMonitor).
25 const uint32_t kNotifyIntervalSec = static_cast<uint32_t>(
26 ceil(ui::UserActivityDetector::kNotifyIntervalMs / 1000.0));
27
28 connector->BindInterface(ui::mojom::kServiceName, &user_activity_monitor_);
29 user_activity_monitor_->AddUserActivityObserver(
30 kNotifyIntervalSec,
31 user_activity_observer_binding_.CreateInterfacePtrAndBind());
32 }
33
34 UserActivityForwarder::~UserActivityForwarder() {}
35
36 void UserActivityForwarder::OnUserActivity() {
37 user_activity_detector_->HandleExternalUserActivity();
38 }
39
40 } // namespace mus
41 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698