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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 1381613003: Defer media loading while on cellular networks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 2 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: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index 269ceaaede30595688baea1c854efcbf59834178..b9dc9c0d90b3e4b334cde69453de330230567070 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -66,6 +66,7 @@
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
#include "core/page/ChromeClient.h"
+#include "core/page/NetworkStateNotifier.h"
#include "platform/ContentType.h"
#include "platform/Logging.h"
#include "platform/MIMETypeFromURL.h"
@@ -1935,6 +1936,12 @@ void HTMLMediaElement::setPreload(const AtomicString& preload)
WebMediaPlayer::Preload HTMLMediaElement::preloadType() const
{
+ // Force preload to none for cellular connections.
+ if (networkStateNotifier().connectionType() == WebConnectionTypeCellular) {
+ UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadForcedNone);
+ return WebMediaPlayer::PreloadNone;
+ }
+
const AtomicString& preload = fastGetAttribute(preloadAttr);
if (equalIgnoringCase(preload, "none")) {
UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone);

Powered by Google App Engine
This is Rietveld 408576698