Chromium Code Reviews| 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 614c6ce029563ab390b6395af1f1e283eed2f81d..849508e0dd1b3f314b3c15de7a6ce1a73713f187 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" |
| @@ -1936,30 +1937,37 @@ void HTMLMediaElement::setPreload(const AtomicString& preload) |
| WebMediaPlayer::Preload HTMLMediaElement::preloadType() const |
| { |
| const AtomicString& preload = fastGetAttribute(preloadAttr); |
| + |
| + WebMediaPlayer::Preload preloadType; |
| if (equalIgnoringCase(preload, "none")) { |
| UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone); |
| - return WebMediaPlayer::PreloadNone; |
| - } |
| - if (equalIgnoringCase(preload, "metadata")) { |
| + preloadType = WebMediaPlayer::PreloadNone; |
| + } else if (equalIgnoringCase(preload, "metadata")) { |
| UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadMetadata); |
| - return WebMediaPlayer::PreloadMetaData; |
| - } |
| - if (equalIgnoringCase(preload, "auto")) { |
| + preloadType = WebMediaPlayer::PreloadMetaData; |
| + } else if (equalIgnoringCase(preload, "auto")) { |
| UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadAuto); |
| - return WebMediaPlayer::PreloadAuto; |
| - } |
| + preloadType = WebMediaPlayer::PreloadAuto; |
| + } else { |
| + UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); |
| + |
| + // "The attribute's missing value default is user-agent defined, though the |
| + // Metadata state is suggested as a compromise between reducing server load |
| + // and providing an optimal user experience." |
| - // "The attribute's missing value default is user-agent defined, though the |
| - // Metadata state is suggested as a compromise between reducing server load |
| - // and providing an optimal user experience." |
| + // The spec does not define an invalid value default: |
| + // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950 |
| + |
| + // TODO(philipj): Try to make "metadata" the default preload state: |
| + // https://crbug.com/310450 |
| + preloadType = WebMediaPlayer::PreloadAuto; |
| + } |
| - // The spec does not define an invalid value default: |
| - // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950 |
| + // Force preload to none for cellular connections. |
| + if (networkStateNotifier().connectionType() == WebConnectionTypeCellular) |
|
philipj_slow
2015/10/01 09:24:07
Make this an early return at the top, which should
philipj_slow
2015/10/01 09:49:49
As pointed out in the other review, this should th
DaleCurtis
2015/10/20 21:56:51
Done -- but to be clear, doing this ruins the rest
philipj_slow
2015/10/21 11:11:29
Right, anyone looking at the stats has to understa
|
| + preloadType = WebMediaPlayer::PreloadNone; |
| - // TODO(philipj): Try to make "metadata" the default preload state: |
| - // https://crbug.com/310450 |
| - UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); |
| - return WebMediaPlayer::PreloadAuto; |
| + return preloadType; |
| } |
| WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |