blob: d0880628cc06ccb697f13d6948f6e4f53d8b1e5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright (c) 2012 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 "chrome/browser/chromeos/power/video_activity_notifier.h"
#include "ash/shell.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
namespace {
// Minimum number of seconds between notifications.
const int kNotifyIntervalSec = 5;
} // namespace
namespace chromeos {
VideoActivityNotifier::VideoActivityNotifier() {
ash::Shell::GetInstance()->video_detector()->AddObserver(this);
}
VideoActivityNotifier::~VideoActivityNotifier() {
ash::Shell::GetInstance()->video_detector()->RemoveObserver(this);
}
void VideoActivityNotifier::OnVideoDetected() {
base::TimeTicks now = base::TimeTicks::Now();
// InSeconds() truncates rather than rounding, so it's fine for this
// comparison.
if (last_notify_time_.is_null() ||
(now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) {
DBusThreadManager::Get()->GetPowerManagerClient()->NotifyVideoActivity(now);
last_notify_time_ = now;
}
}
} // namespace chromeos
|