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

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: Rebase. 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 c1472ef6326c1de774ce5b1a7477b5b4e5dea705..cbd958d391f264a0e6a8665ca3fb3af706d35116 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -65,6 +65,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"
@@ -1907,6 +1908,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);
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | third_party/WebKit/Source/core/page/NetworkStateNotifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698