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

Unified Diff: ash/system/chromeos/power/video_activity_notifier.cc

Issue 2732813002: chromeos: Move files in //ash/common to //ash, part 1 (Closed)
Patch Set: rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/power/video_activity_notifier.cc
diff --git a/ash/system/chromeos/power/video_activity_notifier.cc b/ash/system/chromeos/power/video_activity_notifier.cc
deleted file mode 100644
index 3c194264c5b4dfc7552544fb3c34e86f0b2d8602..0000000000000000000000000000000000000000
--- a/ash/system/chromeos/power/video_activity_notifier.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2013 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/system/chromeos/power/video_activity_notifier.h"
-
-#include "ash/common/session/session_state_delegate.h"
-#include "ash/common/wm_shell.h"
-#include "ash/shell.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/power_manager_client.h"
-
-namespace ash {
-namespace {
-
-// Minimum number of seconds between repeated notifications of the same state.
-// This should be less than powerd's timeout for determining whether video is
-// still active for the purposes of controlling the keyboard backlight.
-const int kNotifyIntervalSec = 5;
-
-} // namespace
-
-VideoActivityNotifier::VideoActivityNotifier(VideoDetector* detector)
- : detector_(detector),
- video_state_(detector->state()),
- screen_is_locked_(
- Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
- detector_->AddObserver(this);
- WmShell::Get()->AddShellObserver(this);
-
- MaybeNotifyPowerManager();
- UpdateTimer();
-}
-
-VideoActivityNotifier::~VideoActivityNotifier() {
- WmShell::Get()->RemoveShellObserver(this);
- detector_->RemoveObserver(this);
-}
-
-void VideoActivityNotifier::OnVideoStateChanged(VideoDetector::State state) {
- if (video_state_ != state) {
- video_state_ = state;
- MaybeNotifyPowerManager();
- UpdateTimer();
- }
-}
-
-void VideoActivityNotifier::OnLockStateChanged(bool locked) {
- if (screen_is_locked_ != locked) {
- screen_is_locked_ = locked;
- MaybeNotifyPowerManager();
- UpdateTimer();
- }
-}
-
-bool VideoActivityNotifier::TriggerTimeoutForTest() {
- if (!notify_timer_.IsRunning())
- return false;
-
- MaybeNotifyPowerManager();
- return true;
-}
-
-void VideoActivityNotifier::UpdateTimer() {
- if (!should_notify_power_manager()) {
- notify_timer_.Stop();
- } else {
- notify_timer_.Start(FROM_HERE,
- base::TimeDelta::FromSeconds(kNotifyIntervalSec), this,
- &VideoActivityNotifier::MaybeNotifyPowerManager);
- }
-}
-
-void VideoActivityNotifier::MaybeNotifyPowerManager() {
- if (should_notify_power_manager()) {
- chromeos::DBusThreadManager::Get()
- ->GetPowerManagerClient()
- ->NotifyVideoActivity(video_state_ ==
- VideoDetector::State::PLAYING_FULLSCREEN);
- }
-}
-
-} // namespace ash
« no previous file with comments | « ash/system/chromeos/power/video_activity_notifier.h ('k') | ash/system/chromeos/power/video_activity_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698