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

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 1766783003: Expand suspension of idle media players to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notify_pause
Patch Set: Simplify. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/android/webmediaplayer_android.h" 5 #include "content/renderer/media/android/webmediaplayer_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1504
1505 void WebMediaPlayerAndroid::OnWaitingForDecryptionKey() { 1505 void WebMediaPlayerAndroid::OnWaitingForDecryptionKey() {
1506 encrypted_client_->didBlockPlaybackWaitingForKey(); 1506 encrypted_client_->didBlockPlaybackWaitingForKey();
1507 1507
1508 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 1508 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
1509 // when a key has been successfully added (e.g. OnSessionKeysChange() with 1509 // when a key has been successfully added (e.g. OnSessionKeysChange() with
1510 // |has_additional_usable_key| = true). http://crbug.com/461903 1510 // |has_additional_usable_key| = true). http://crbug.com/461903
1511 encrypted_client_->didResumePlaybackBlockedForKey(); 1511 encrypted_client_->didResumePlaybackBlockedForKey();
1512 } 1512 }
1513 1513
1514 void WebMediaPlayerAndroid::OnHidden(bool must_suspend) { 1514 void WebMediaPlayerAndroid::OnHidden() {
1515 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1515 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1516 switches::kDisableMediaSuspend)) { 1516 switches::kDisableMediaSuspend)) {
1517 return; 1517 return;
1518 } 1518 }
1519 1519
1520 OnSuspendRequested(false);
1521 }
1522
1523 void WebMediaPlayerAndroid::OnShown() {}
1524
1525 void WebMediaPlayerAndroid::OnSuspendRequested(bool must_suspend) {
1520 // If we're idle or playing video, pause and release resources; audio only 1526 // If we're idle or playing video, pause and release resources; audio only
1521 // players are allowed to continue playing in the background unless indicated 1527 // players are allowed to continue playing in the background unless indicated
sandersd (OOO until July 31) 2016/03/10 19:37:00 "background" isn't implicitly the correct word her
DaleCurtis 2016/03/10 23:11:36 Removed.
1522 // otherwise by the call. 1528 // otherwise by the call.
1523 if (must_suspend || (paused() && playback_completed_) || hasVideo()) 1529 if (must_suspend || (paused() && playback_completed_) || hasVideo())
1524 SuspendAndReleaseResources(); 1530 SuspendAndReleaseResources();
1525 } 1531 }
1526 1532
1527 void WebMediaPlayerAndroid::OnShown() {}
1528
1529 void WebMediaPlayerAndroid::OnPlay() { 1533 void WebMediaPlayerAndroid::OnPlay() {
1530 play(); 1534 play();
1531 client_->playbackStateChanged(); 1535 client_->playbackStateChanged();
1532 } 1536 }
1533 1537
1534 void WebMediaPlayerAndroid::OnPause() { 1538 void WebMediaPlayerAndroid::OnPause() {
1535 pause(); 1539 pause();
1536 client_->playbackStateChanged(); 1540 client_->playbackStateChanged();
1537 } 1541 }
1538 1542
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; 1665 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER;
1662 } else if (is_hls_url == is_hls) { 1666 } else if (is_hls_url == is_hls) {
1663 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; 1667 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER;
1664 } 1668 }
1665 UMA_HISTOGRAM_ENUMERATION( 1669 UMA_HISTOGRAM_ENUMERATION(
1666 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", 1670 "Media.Android.IsHttpLiveStreamingMediaPredictionResult",
1667 result, PREDICTION_RESULT_MAX); 1671 result, PREDICTION_RESULT_MAX);
1668 } 1672 }
1669 1673
1670 } // namespace content 1674 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698