Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp |
| index 76827a89668652c30a26a5156694a0096f837c0d..cd12d6e62446833b7ee084ed542f12e4c1746991 100644 |
| --- a/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp |
| +++ b/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp |
| @@ -47,6 +47,7 @@ |
| #include "core/events/PageTransitionEvent.h" |
| #include "core/events/PopStateEvent.h" |
| #include "core/events/ScopedEventQueue.h" |
| +#include "core/fetch/ResourceFetcher.h" |
| #include "core/frame/BarProp.h" |
| #include "core/frame/DOMVisualViewport.h" |
| #include "core/frame/EventHandlerRegistry.h" |
| @@ -83,6 +84,9 @@ |
| namespace blink { |
| +// Timeout for link preloads to be used after window.onload |
| +static const int unusedPreloadTimeout = 3; |
|
Charlie Harrison
2016/09/14 12:34:58
Make it clear this is in seconds in the name or co
Yoav Weiss
2016/09/14 13:28:31
good call
|
| + |
| class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer>, public SuspendableTimer { |
| USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); |
| public: |
| @@ -260,6 +264,7 @@ bool LocalDOMWindow::allowPopUp() |
| LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) |
| : m_frame(&frame) |
| , m_visualViewport(DOMVisualViewport::create(this)) |
| + , m_unusedPreloadsTimer(this, &LocalDOMWindow::warnUnusedPreloads) |
| , m_shouldPrintWhenFinishedLoading(false) |
| { |
| ThreadState::current()->registerPreFinalizer(this); |
| @@ -1336,6 +1341,14 @@ void LocalDOMWindow::removedEventListener(const AtomicString& eventType, const R |
| } |
| } |
| +void LocalDOMWindow::warnUnusedPreloads(TimerBase* base) |
| +{ |
| + if (frame() && frame()->loader().documentLoader()) { |
| + DCHECK(frame()->loader().documentLoader()->fetcher()); |
| + frame()->loader().documentLoader()->fetcher()->warnUnusedPreloads(); |
| + } |
| +} |
| + |
| void LocalDOMWindow::dispatchLoadEvent() |
| { |
| Event* loadEvent(Event::create(EventTypeNames::load)); |
| @@ -1345,6 +1358,8 @@ void LocalDOMWindow::dispatchLoadEvent() |
| timing.markLoadEventStart(); |
| dispatchEvent(loadEvent, document()); |
| timing.markLoadEventEnd(); |
| + m_unusedPreloadsTimer.startOneShot(unusedPreloadTimeout, BLINK_FROM_HERE); |
|
Charlie Harrison
2016/09/14 12:34:58
I think it makes sense to only dispatch this timer
Yoav Weiss
2016/09/14 13:28:31
It makes sense, but I really don't want to iterate
Charlie Harrison
2016/09/14 13:32:59
That's a good point. A counter is not great but I
|
| + |
| } else { |
|
Charlie Harrison
2016/09/14 12:34:58
Remove empty line.
Yoav Weiss
2016/09/14 13:28:31
sure
|
| dispatchEvent(loadEvent, document()); |
| } |