| Index: ash/mus/user_activity_forwarder.cc
|
| diff --git a/ash/mus/user_activity_forwarder.cc b/ash/mus/user_activity_forwarder.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0406d1ab24fbdf5a5aae13493a1d27458f2cab7c
|
| --- /dev/null
|
| +++ b/ash/mus/user_activity_forwarder.cc
|
| @@ -0,0 +1,41 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ash/mus/user_activity_forwarder.h"
|
| +
|
| +#include <cmath>
|
| +
|
| +#include "services/service_manager/public/cpp/connector.h"
|
| +#include "services/ui/public/interfaces/constants.mojom.h"
|
| +#include "ui/base/user_activity/user_activity_detector.h"
|
| +
|
| +namespace ash {
|
| +namespace mus {
|
| +
|
| +UserActivityForwarder::UserActivityForwarder(
|
| + service_manager::Connector* connector,
|
| + ui::UserActivityDetector* detector)
|
| + : user_activity_observer_binding_(this), user_activity_detector_(detector) {
|
| + DCHECK(connector);
|
| + DCHECK(detector);
|
| +
|
| + // Round UserActivityDetector's notification interval up to the nearest second
|
| + // (the granularity exposed by UserActivityMonitor).
|
| + const uint32_t kNotifyIntervalSec = static_cast<uint32_t>(
|
| + ceil(ui::UserActivityDetector::kNotifyIntervalMs / 1000.0));
|
| +
|
| + connector->BindInterface(ui::mojom::kServiceName, &user_activity_monitor_);
|
| + user_activity_monitor_->AddUserActivityObserver(
|
| + kNotifyIntervalSec,
|
| + user_activity_observer_binding_.CreateInterfacePtrAndBind());
|
| +}
|
| +
|
| +UserActivityForwarder::~UserActivityForwarder() {}
|
| +
|
| +void UserActivityForwarder::OnUserActivity() {
|
| + user_activity_detector_->HandleExternalUserActivity();
|
| +}
|
| +
|
| +} // namespace mus
|
| +} // namespace ash
|
|
|