Make m_executeScriptsWaitingForResourcesTimer a loading task

We would like to be able to prioritize loading tasks, but in order to
do that we need to make sure loading tasks are posted to the right queue
to make sure tasks run in the expected order.  If this task is posted as
a timer, and loading tasks are prioritzed, it's possible
FrameHostMsg_DidStopLoading will be sent before the corresponding
FrameHostMsg_DidStartLoading ipc which causes various browser tests to
break.

BUG=497761,510398

Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=201563

Review URL: https://codereview.chromium.org/1312353004

git-svn-id: svn://svn.chromium.org/blink/trunk@201654 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 06bc8bb1
......@@ -212,6 +212,7 @@
#include "public/platform/Platform.h"
#include "wtf/CurrentTime.h"
#include "wtf/DateMath.h"
#include "wtf/Functional.h"
#include "wtf/HashFunctions.h"
#include "wtf/MainThread.h"
#include "wtf/StdLibExtras.h"
......@@ -365,6 +366,25 @@ private:
}
};
} // namespace blink
namespace WTF {
#if ENABLE(OILPAN)
// NOTE this is to prevent Document::m_executeScriptsWaitingForResourcesTask from leaking.
template<>
struct PointerParamStorageTraits<blink::Document*, true> {
using StorageType = blink::CrossThreadWeakPersistent<blink::Document>;
static StorageType wrap(blink::Document* value) { return value; }
static blink::Document* unwrap(const StorageType& value) { return value.get(); }
};
#endif
} // namespace WTF
namespace blink {
Document::Document(const DocumentInit& initializer, DocumentClassFlags documentClasses)
: ContainerNode(0, CreateDocument)
, TreeScope(*this)
......@@ -381,7 +401,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
, m_paginatedForScreen(false)
, m_compatibilityMode(NoQuirksMode)
, m_compatibilityModeLocked(false)
, m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWaitingForResourcesTimerFired)
, m_executeScriptsWaitingForResourcesTask(WTF::bind(&Document::executeScriptsWaitingForResources, this))
, m_hasAutofocused(false)
, m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired)
, m_domTreeVersion(++s_globalTreeVersion)
......@@ -2961,7 +2981,8 @@ void Document::didRemoveAllPendingStylesheet()
void Document::didLoadAllScriptBlockingResources()
{
m_executeScriptsWaitingForResourcesTimer.startOneShot(0, FROM_HERE);
Platform::current()->currentThread()->scheduler()->postLoadingTask(
FROM_HERE, m_executeScriptsWaitingForResourcesTask.cancelAndCreate());
if (frame())
frame()->loader().client()->didRemoveAllPendingStylesheet();
......@@ -2970,7 +2991,7 @@ void Document::didLoadAllScriptBlockingResources()
view()->processUrlFragment(m_url);
}
void Document::executeScriptsWaitingForResourcesTimerFired(Timer<Document>*)
void Document::executeScriptsWaitingForResources()
{
if (!isRenderingReady())
return;
......
......@@ -57,6 +57,7 @@
#include "platform/Length.h"
#include "platform/Timer.h"
#include "platform/heap/Handle.h"
#include "platform/scheduler/CancellableTaskFactory.h"
#include "platform/weborigin/KURL.h"
#include "platform/weborigin/ReferrerPolicy.h"
#include "public/platform/WebFocusType.h"
......@@ -1125,7 +1126,7 @@ private:
void updateFocusAppearanceTimerFired(Timer<Document>*);
void updateBaseURL();
void executeScriptsWaitingForResourcesTimerFired(Timer<Document>*);
void executeScriptsWaitingForResources();
void loadEventDelayTimerFired(Timer<Document>*);
void pluginLoadingTimerFired(Timer<Document>*);
......@@ -1199,7 +1200,7 @@ private:
CompatibilityMode m_compatibilityMode;
bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
Timer<Document> m_executeScriptsWaitingForResourcesTimer;
CancellableTaskFactory m_executeScriptsWaitingForResourcesTask;
bool m_hasAutofocused;
Timer<Document> m_clearFocusedElementTimer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment