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

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

Issue 2071793003: Use data saver information to decide whether to preload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay-visibility
Patch Set: keep connection check Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/media/video-preload-datasaver.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 } 1993 }
1994 1994
1995 void HTMLMediaElement::setPreload(const AtomicString& preload) 1995 void HTMLMediaElement::setPreload(const AtomicString& preload)
1996 { 1996 {
1997 MEDIA_LOG << "setPreload(" << (void*)this << ", " << preload << ")"; 1997 MEDIA_LOG << "setPreload(" << (void*)this << ", " << preload << ")";
1998 setAttribute(preloadAttr, preload); 1998 setAttribute(preloadAttr, preload);
1999 } 1999 }
2000 2000
2001 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const 2001 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const
2002 { 2002 {
2003 // Force preload to none for cellular connections. 2003 // Force preload to none for cellular connections or when data saver is expl icitly set.
2004 if (networkStateNotifier().isCellularConnectionType()) { 2004 if (networkStateNotifier().isCellularConnectionType()
2005 || (document().settings() && document().settings()->dataSaverEnabled())) {
2005 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadForcedN one); 2006 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadForcedN one);
2006 return WebMediaPlayer::PreloadNone; 2007 return WebMediaPlayer::PreloadNone;
2007 } 2008 }
2008 2009
2009 const AtomicString& preload = fastGetAttribute(preloadAttr); 2010 const AtomicString& preload = fastGetAttribute(preloadAttr);
2010 if (equalIgnoringCase(preload, "none")) { 2011 if (equalIgnoringCase(preload, "none")) {
2011 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone); 2012 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone);
2012 return WebMediaPlayer::PreloadNone; 2013 return WebMediaPlayer::PreloadNone;
2013 } 2014 }
2014 if (equalIgnoringCase(preload, "metadata")) { 2015 if (equalIgnoringCase(preload, "metadata")) {
(...skipping 18 matching lines...) Expand all
2033 return WebMediaPlayer::PreloadAuto; 2034 return WebMediaPlayer::PreloadAuto;
2034 } 2035 }
2035 2036
2036 String HTMLMediaElement::effectivePreload() const 2037 String HTMLMediaElement::effectivePreload() const
2037 { 2038 {
2038 return preloadTypeToString(effectivePreloadType()); 2039 return preloadTypeToString(effectivePreloadType());
2039 } 2040 }
2040 2041
2041 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const 2042 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const
2042 { 2043 {
2043 if (autoplay()) 2044 if (autoplay() && !isGestureNeededForPlayback())
2044 return WebMediaPlayer::PreloadAuto; 2045 return WebMediaPlayer::PreloadAuto;
2045 2046
2046 WebMediaPlayer::Preload preload = preloadType(); 2047 WebMediaPlayer::Preload preload = preloadType();
2047 if (m_ignorePreloadNone && preload == WebMediaPlayer::PreloadNone) 2048 if (m_ignorePreloadNone && preload == WebMediaPlayer::PreloadNone)
2048 return WebMediaPlayer::PreloadMetaData; 2049 return WebMediaPlayer::PreloadMetaData;
2049 2050
2050 return preload; 2051 return preload;
2051 } 2052 }
2052 2053
2053 ScriptPromise HTMLMediaElement::playForBindings(ScriptState* scriptState) 2054 ScriptPromise HTMLMediaElement::playForBindings(ScriptState* scriptState)
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after
4013 4014
4014 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4015 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4015 { 4016 {
4016 IntRect result; 4017 IntRect result;
4017 if (LayoutObject* object = m_element->layoutObject()) 4018 if (LayoutObject* object = m_element->layoutObject())
4018 result = object->absoluteBoundingBoxRect(); 4019 result = object->absoluteBoundingBoxRect();
4019 return result; 4020 return result;
4020 } 4021 }
4021 4022
4022 } // namespace blink 4023 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/media/video-preload-datasaver.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698