OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 #include "core/events/Event.h" | 31 #include "core/events/Event.h" |
32 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" | 32 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" |
33 #include "core/dom/Microtask.h" | 33 #include "core/dom/Microtask.h" |
34 #include "core/dom/ScriptLoader.h" | 34 #include "core/dom/ScriptLoader.h" |
35 #include "core/fetch/ScriptResource.h" | 35 #include "core/fetch/ScriptResource.h" |
36 #include "core/frame/LocalFrame.h" | 36 #include "core/frame/LocalFrame.h" |
37 #include "core/html/parser/HTMLInputStream.h" | 37 #include "core/html/parser/HTMLInputStream.h" |
38 #include "core/html/parser/HTMLScriptRunnerHost.h" | 38 #include "core/html/parser/HTMLScriptRunnerHost.h" |
39 #include "core/html/parser/NestingLevelIncrementer.h" | 39 #include "core/html/parser/NestingLevelIncrementer.h" |
40 #include "platform/NotImplemented.h" | 40 #include "platform/NotImplemented.h" |
| 41 #include "public/platform/Platform.h" |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 using namespace HTMLNames; | 45 using namespace HTMLNames; |
45 | 46 |
46 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos
t) | 47 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos
t) |
47 : m_document(document) | 48 : m_document(document) |
48 , m_host(host) | 49 , m_host(host) |
49 , m_scriptNestingLevel(0) | 50 , m_scriptNestingLevel(0) |
50 , m_hasScriptsWaitingForResources(false) | 51 , m_hasScriptsWaitingForResources(false) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); | 160 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); |
160 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem
enter(m_document); | 161 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem
enter(m_document); |
161 if (errorOccurred) | 162 if (errorOccurred) |
162 scriptLoader->dispatchErrorEvent(); | 163 scriptLoader->dispatchErrorEvent(); |
163 else { | 164 else { |
164 ASSERT(isExecutingScript()); | 165 ASSERT(isExecutingScript()); |
165 scriptLoader->executeScript(sourceCode); | 166 scriptLoader->executeScript(sourceCode); |
166 element->dispatchEvent(createScriptLoadEvent()); | 167 element->dispatchEvent(createScriptLoadEvent()); |
167 } | 168 } |
168 } | 169 } |
| 170 if (sourceCode.resource()) { |
| 171 double timeBetweenLoadedAndCompiledMs = (WTF::monotonicallyIncreasingTim
e() - sourceCode.resource()->loadFinishTime()) * 1000; |
| 172 const char* histogramName = pendingScriptType == PendingScriptBlockingPa
rser ? "WebCore.Scripts.ParsingBlocking.TimeBetweenLoadedAndCompiled" : "WebCore
.Scripts.Deferred.TimeBetweenLoadedAndCompiled"; |
| 173 blink::Platform::current()->histogramCustomCounts(histogramName, timeBet
weenLoadedAndCompiledMs, 0, 10000, 50); |
| 174 } |
| 175 |
169 ASSERT(!isExecutingScript()); | 176 ASSERT(!isExecutingScript()); |
170 } | 177 } |
171 | 178 |
172 void HTMLScriptRunner::watchForLoad(PendingScript& pendingScript) | 179 void HTMLScriptRunner::watchForLoad(PendingScript& pendingScript) |
173 { | 180 { |
174 ASSERT(!pendingScript.watchingForLoad()); | 181 ASSERT(!pendingScript.watchingForLoad()); |
175 ASSERT(!pendingScript.resource()->isLoaded()); | 182 ASSERT(!pendingScript.resource()->isLoaded()); |
176 // addClient() will call notifyFinished() if the load is complete. | 183 // addClient() will call notifyFinished() if the load is complete. |
177 // Callers do not expect to be re-entered from this call, so they | 184 // Callers do not expect to be re-entered from this call, so they |
178 // should not become a client of an already-loaded Resource. | 185 // should not become a client of an already-loaded Resource. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return true; | 272 return true; |
266 } | 273 } |
267 | 274 |
268 void HTMLScriptRunner::requestParsingBlockingScript(Element* element) | 275 void HTMLScriptRunner::requestParsingBlockingScript(Element* element) |
269 { | 276 { |
270 if (!requestPendingScript(m_parserBlockingScript, element)) | 277 if (!requestPendingScript(m_parserBlockingScript, element)) |
271 return; | 278 return; |
272 | 279 |
273 ASSERT(m_parserBlockingScript.resource()); | 280 ASSERT(m_parserBlockingScript.resource()); |
274 | 281 |
| 282 blink::Platform::current()->histogramEnumeration("WebCore.Scripts.ParsingBlo
cking.AlreadyLoaded", m_parserBlockingScript.resource()->isLoaded() ? 1 : 0, 2); |
275 // We only care about a load callback if resource is not already | 283 // We only care about a load callback if resource is not already |
276 // in the cache. Callers will attempt to run the m_parserBlockingScript | 284 // in the cache. Callers will attempt to run the m_parserBlockingScript |
277 // if possible before returning control to the parser. | 285 // if possible before returning control to the parser. |
278 if (!m_parserBlockingScript.resource()->isLoaded()) | 286 if (!m_parserBlockingScript.resource()->isLoaded()) |
279 watchForLoad(m_parserBlockingScript); | 287 watchForLoad(m_parserBlockingScript); |
280 } | 288 } |
281 | 289 |
282 void HTMLScriptRunner::requestDeferredScript(Element* element) | 290 void HTMLScriptRunner::requestDeferredScript(Element* element) |
283 { | 291 { |
284 PendingScript pendingScript; | 292 PendingScript pendingScript; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 359 |
352 void HTMLScriptRunner::trace(Visitor* visitor) | 360 void HTMLScriptRunner::trace(Visitor* visitor) |
353 { | 361 { |
354 visitor->trace(m_document); | 362 visitor->trace(m_document); |
355 visitor->trace(m_host); | 363 visitor->trace(m_host); |
356 visitor->trace(m_parserBlockingScript); | 364 visitor->trace(m_parserBlockingScript); |
357 visitor->trace(m_scriptsToExecuteAfterParsing); | 365 visitor->trace(m_scriptsToExecuteAfterParsing); |
358 } | 366 } |
359 | 367 |
360 } | 368 } |
OLD | NEW |