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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 1276143002: Defer media loading while on cellular networks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Cleanup. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "core/html/track/TextTrackList.h" 59 #include "core/html/track/TextTrackList.h"
60 #include "core/html/track/VideoTrack.h" 60 #include "core/html/track/VideoTrack.h"
61 #include "core/html/track/VideoTrackList.h" 61 #include "core/html/track/VideoTrackList.h"
62 #include "core/inspector/ConsoleMessage.h" 62 #include "core/inspector/ConsoleMessage.h"
63 #include "core/layout/LayoutVideo.h" 63 #include "core/layout/LayoutVideo.h"
64 #include "core/layout/LayoutView.h" 64 #include "core/layout/LayoutView.h"
65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
66 #include "core/loader/FrameLoader.h" 66 #include "core/loader/FrameLoader.h"
67 #include "core/loader/FrameLoaderClient.h" 67 #include "core/loader/FrameLoaderClient.h"
68 #include "core/page/ChromeClient.h" 68 #include "core/page/ChromeClient.h"
69 #include "core/page/NetworkStateNotifier.h"
69 #include "platform/ContentType.h" 70 #include "platform/ContentType.h"
70 #include "platform/Logging.h" 71 #include "platform/Logging.h"
71 #include "platform/MIMETypeFromURL.h" 72 #include "platform/MIMETypeFromURL.h"
72 #include "platform/MIMETypeRegistry.h" 73 #include "platform/MIMETypeRegistry.h"
73 #include "platform/RuntimeEnabledFeatures.h" 74 #include "platform/RuntimeEnabledFeatures.h"
74 #include "platform/UserGestureIndicator.h" 75 #include "platform/UserGestureIndicator.h"
75 #include "platform/graphics/GraphicsLayer.h" 76 #include "platform/graphics/GraphicsLayer.h"
76 #include "platform/weborigin/SecurityOrigin.h" 77 #include "platform/weborigin/SecurityOrigin.h"
77 #include "public/platform/Platform.h" 78 #include "public/platform/Platform.h"
78 #include "public/platform/WebContentDecryptionModule.h" 79 #include "public/platform/WebContentDecryptionModule.h"
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 1930
1930 void HTMLMediaElement::setPreload(const AtomicString& preload) 1931 void HTMLMediaElement::setPreload(const AtomicString& preload)
1931 { 1932 {
1932 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data()); 1933 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data());
1933 setAttribute(preloadAttr, preload); 1934 setAttribute(preloadAttr, preload);
1934 } 1935 }
1935 1936
1936 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const 1937 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const
1937 { 1938 {
1938 const AtomicString& preload = fastGetAttribute(preloadAttr); 1939 const AtomicString& preload = fastGetAttribute(preloadAttr);
1940
1941 WebMediaPlayer::Preload preloadType;
1939 if (equalIgnoringCase(preload, "none")) { 1942 if (equalIgnoringCase(preload, "none")) {
1940 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone); 1943 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone);
1941 return WebMediaPlayer::PreloadNone; 1944 preloadType = WebMediaPlayer::PreloadNone;
1942 } 1945 } else if (equalIgnoringCase(preload, "metadata")) {
1943 if (equalIgnoringCase(preload, "metadata")) {
1944 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadMetadat a); 1946 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadMetadat a);
1945 return WebMediaPlayer::PreloadMetaData; 1947 preloadType = WebMediaPlayer::PreloadMetaData;
1946 } 1948 } else if (equalIgnoringCase(preload, "auto")) {
1947 if (equalIgnoringCase(preload, "auto")) {
1948 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadAuto); 1949 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadAuto);
1949 return WebMediaPlayer::PreloadAuto; 1950 preloadType = WebMediaPlayer::PreloadAuto;
1951 } else {
1952 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault );
1953
1954 // "The attribute's missing value default is user-agent defined, though the
1955 // Metadata state is suggested as a compromise between reducing server l oad
1956 // and providing an optimal user experience."
1957
1958 // The spec does not define an invalid value default:
1959 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950
1960
1961 // TODO(philipj): Try to make "metadata" the default preload state:
1962 // https://crbug.com/310450
1963 preloadType = WebMediaPlayer::PreloadAuto;
1950 } 1964 }
1951 1965
1952 // "The attribute's missing value default is user-agent defined, though the 1966 // Force preload to none for cellular connections.
1953 // Metadata state is suggested as a compromise between reducing server load 1967 if (networkStateNotifier().connectionType() == WebConnectionTypeCellular)
1954 // and providing an optimal user experience." 1968 preloadType = WebMediaPlayer::PreloadNone;
philipj_slow 2015/09/30 11:19:30 Making this an early return to avoid even looking
DaleCurtis 2015/09/30 16:18:19 I didn't do that so that we could keep the use cou
philipj_slow 2015/10/01 09:49:06 Hmm, good point, but if they're counted without be
1955 1969
1956 // The spec does not define an invalid value default: 1970 return preloadType;
1957 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950
1958
1959 // TODO(philipj): Try to make "metadata" the default preload state:
1960 // https://crbug.com/310450
1961 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault);
1962 return WebMediaPlayer::PreloadAuto;
1963 } 1971 }
1964 1972
1965 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const 1973 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const
1966 { 1974 {
1967 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); 1975 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType();
1968 } 1976 }
1969 1977
1970 void HTMLMediaElement::play() 1978 void HTMLMediaElement::play()
1971 { 1979 {
1972 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); 1980 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this);
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
3814 visitor->trace(m_client); 3822 visitor->trace(m_client);
3815 } 3823 }
3816 3824
3817 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) 3825 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl)
3818 { 3826 {
3819 visitor->trace(m_client); 3827 visitor->trace(m_client);
3820 } 3828 }
3821 #endif 3829 #endif
3822 3830
3823 } 3831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698