Chromium Code Reviews| OLD | NEW |
|---|---|
| (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>( | |
| 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 } | |
|
James Cook
2017/01/18 17:01:38
If this class sticks around, could it get a trivia
Daniel Erat
2017/01/18 18:54:20
hmm. is there any way to exercise the calls to Bin
James Cook
2017/01/18 20:17:32
I don't know how to exercise the BindInterface bit
| |
| 41 | |
| 42 } // namespace mus | |
| 43 } // namespace ash | |
| OLD | NEW |