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

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

Issue 1366883002: [Reland] Post loading tasks on the appropriate WebFrameScheduler's queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android compile 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) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, 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 22 matching lines...) Expand all
33 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" 33 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h"
34 #include "core/dom/Microtask.h" 34 #include "core/dom/Microtask.h"
35 #include "core/dom/ScriptLoader.h" 35 #include "core/dom/ScriptLoader.h"
36 #include "core/fetch/ScriptResource.h" 36 #include "core/fetch/ScriptResource.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
38 #include "core/html/parser/HTMLInputStream.h" 38 #include "core/html/parser/HTMLInputStream.h"
39 #include "core/html/parser/HTMLScriptRunnerHost.h" 39 #include "core/html/parser/HTMLScriptRunnerHost.h"
40 #include "core/html/parser/NestingLevelIncrementer.h" 40 #include "core/html/parser/NestingLevelIncrementer.h"
41 #include "platform/NotImplemented.h" 41 #include "platform/NotImplemented.h"
42 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
43 #include "public/platform/WebFrameScheduler.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 using namespace HTMLNames; 47 using namespace HTMLNames;
47 48
48 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos t) 49 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos t)
49 : m_document(document) 50 : m_document(document)
50 , m_host(host) 51 , m_host(host)
51 , m_scriptNestingLevel(0) 52 , m_scriptNestingLevel(0)
52 , m_hasScriptsWaitingForResources(false) 53 , m_hasScriptsWaitingForResources(false)
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 281
281 ASSERT(m_parserBlockingScript.resource()); 282 ASSERT(m_parserBlockingScript.resource());
282 283
283 // We only care about a load callback if resource is not already 284 // We only care about a load callback if resource is not already
284 // in the cache. Callers will attempt to run the m_parserBlockingScript 285 // in the cache. Callers will attempt to run the m_parserBlockingScript
285 // if possible before returning control to the parser. 286 // if possible before returning control to the parser.
286 if (!m_parserBlockingScript.isReady()) { 287 if (!m_parserBlockingScript.isReady()) {
287 if (m_document->frame()) { 288 if (m_document->frame()) {
288 ScriptState* scriptState = ScriptState::forMainWorld(m_document->fra me()); 289 ScriptState* scriptState = ScriptState::forMainWorld(m_document->fra me());
289 if (scriptState->contextIsValid()) 290 if (scriptState->contextIsValid())
290 ScriptStreamer::startStreaming(m_parserBlockingScript, PendingSc ript::ParsingBlocking, m_document->frame()->settings(), scriptState); 291 ScriptStreamer::startStreaming(m_parserBlockingScript, PendingSc ript::ParsingBlocking, m_document->frame()->settings(), scriptState, m_document- >frame()->frameScheduler()->loadingTaskRunner());
Sami 2015/09/30 13:03:16 nit: use the new accessor here?
alex clarke (OOO till 29th) 2015/09/30 13:37:17 Done.
291 } 292 }
292 293
293 m_parserBlockingScript.watchForLoad(this); 294 m_parserBlockingScript.watchForLoad(this);
294 } 295 }
295 } 296 }
296 297
297 void HTMLScriptRunner::requestDeferredScript(Element* element) 298 void HTMLScriptRunner::requestDeferredScript(Element* element)
298 { 299 {
299 PendingScript pendingScript; 300 PendingScript pendingScript;
300 if (!requestPendingScript(pendingScript, element)) 301 if (!requestPendingScript(pendingScript, element))
301 return; 302 return;
302 303
303 if (m_document->frame() && !pendingScript.isReady()) { 304 if (m_document->frame() && !pendingScript.isReady()) {
304 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame() ); 305 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame() );
305 if (scriptState->contextIsValid()) 306 if (scriptState->contextIsValid())
306 ScriptStreamer::startStreaming(pendingScript, PendingScript::Deferre d, m_document->frame()->settings(), scriptState); 307 ScriptStreamer::startStreaming(pendingScript, PendingScript::Deferre d, m_document->frame()->settings(), scriptState, m_document->frame()->frameSched uler()->loadingTaskRunner());
Sami 2015/09/30 13:03:16 Ditto.
alex clarke (OOO till 29th) 2015/09/30 13:37:17 Done.
307 } 308 }
308 309
309 ASSERT(pendingScript.resource()); 310 ASSERT(pendingScript.resource());
310 m_scriptsToExecuteAfterParsing.append(pendingScript); 311 m_scriptsToExecuteAfterParsing.append(pendingScript);
311 } 312 }
312 313
313 bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Elemen t* script) const 314 bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Elemen t* script) const
314 { 315 {
315 ASSERT(!pendingScript.element()); 316 ASSERT(!pendingScript.element());
316 pendingScript.setElement(script); 317 pendingScript.setElement(script);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 373
373 DEFINE_TRACE(HTMLScriptRunner) 374 DEFINE_TRACE(HTMLScriptRunner)
374 { 375 {
375 visitor->trace(m_document); 376 visitor->trace(m_document);
376 visitor->trace(m_host); 377 visitor->trace(m_host);
377 visitor->trace(m_parserBlockingScript); 378 visitor->trace(m_parserBlockingScript);
378 visitor->trace(m_scriptsToExecuteAfterParsing); 379 visitor->trace(m_scriptsToExecuteAfterParsing);
379 } 380 }
380 381
381 } // namespace blink 382 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698