OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 14 matching lines...) Expand all Loading... |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/workers/WorkerGlobalScope.h" | 29 #include "core/workers/WorkerGlobalScope.h" |
30 | 30 |
31 #include "bindings/core/v8/ExceptionState.h" | 31 #include "bindings/core/v8/ExceptionState.h" |
32 #include "bindings/core/v8/ScheduledAction.h" | 32 #include "bindings/core/v8/ScheduledAction.h" |
33 #include "bindings/core/v8/ScriptSourceCode.h" | 33 #include "bindings/core/v8/ScriptSourceCode.h" |
34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
| 35 #include "bindings/core/v8/V8CacheOptions.h" |
35 #include "core/dom/ActiveDOMObject.h" | 36 #include "core/dom/ActiveDOMObject.h" |
36 #include "core/dom/AddConsoleMessageTask.h" | 37 #include "core/dom/AddConsoleMessageTask.h" |
37 #include "core/dom/ContextLifecycleNotifier.h" | 38 #include "core/dom/ContextLifecycleNotifier.h" |
38 #include "core/dom/DOMURL.h" | 39 #include "core/dom/DOMURL.h" |
39 #include "core/dom/ExceptionCode.h" | 40 #include "core/dom/ExceptionCode.h" |
40 #include "core/dom/MessagePort.h" | 41 #include "core/dom/MessagePort.h" |
41 #include "core/events/ErrorEvent.h" | 42 #include "core/events/ErrorEvent.h" |
42 #include "core/events/Event.h" | 43 #include "core/events/Event.h" |
43 #include "core/frame/DOMTimer.h" | 44 #include "core/frame/DOMTimer.h" |
44 #include "core/frame/DOMTimerCoordinator.h" | 45 #include "core/frame/DOMTimerCoordinator.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Notify parent that this context is closed. Parent is responsible for
calling WorkerThread::stop(). | 78 // Notify parent that this context is closed. Parent is responsible for
calling WorkerThread::stop(). |
78 workerGlobalScope->thread()->workerReportingProxy().workerGlobalScopeClo
sed(); | 79 workerGlobalScope->thread()->workerReportingProxy().workerGlobalScopeClo
sed(); |
79 } | 80 } |
80 | 81 |
81 virtual bool isCleanupTask() const { return true; } | 82 virtual bool isCleanupTask() const { return true; } |
82 }; | 83 }; |
83 | 84 |
84 WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, W
orkerThread* thread, double timeOrigin, const SecurityOrigin* starterOrigin, Pas
sOwnPtrWillBeRawPtr<WorkerClients> workerClients) | 85 WorkerGlobalScope::WorkerGlobalScope(const KURL& url, const String& userAgent, W
orkerThread* thread, double timeOrigin, const SecurityOrigin* starterOrigin, Pas
sOwnPtrWillBeRawPtr<WorkerClients> workerClients) |
85 : m_url(url) | 86 : m_url(url) |
86 , m_userAgent(userAgent) | 87 , m_userAgent(userAgent) |
| 88 , m_v8CacheOptions(V8CacheOptionsDefault) |
87 , m_script(adoptPtr(new WorkerScriptController(*this))) | 89 , m_script(adoptPtr(new WorkerScriptController(*this))) |
88 , m_thread(thread) | 90 , m_thread(thread) |
89 , m_workerInspectorController(adoptRefWillBeNoop(new WorkerInspectorControll
er(this))) | 91 , m_workerInspectorController(adoptRefWillBeNoop(new WorkerInspectorControll
er(this))) |
90 , m_closing(false) | 92 , m_closing(false) |
91 , m_eventQueue(WorkerEventQueue::create(this)) | 93 , m_eventQueue(WorkerEventQueue::create(this)) |
92 , m_workerClients(workerClients) | 94 , m_workerClients(workerClients) |
93 , m_timeOrigin(timeOrigin) | 95 , m_timeOrigin(timeOrigin) |
94 , m_messageStorage(ConsoleMessageStorage::create()) | 96 , m_messageStorage(ConsoleMessageStorage::create()) |
95 , m_workerExceptionUniqueIdentifier(0) | 97 , m_workerExceptionUniqueIdentifier(0) |
96 { | 98 { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 259 |
258 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. | 260 // If the fetching attempt failed, throw a NetworkError exception and ab
ort all these steps. |
259 if (scriptLoader->failed()) { | 261 if (scriptLoader->failed()) { |
260 exceptionState.throwDOMException(NetworkError, "The script at '" + c
ompleteURL.elidedString() + "' failed to load."); | 262 exceptionState.throwDOMException(NetworkError, "The script at '" + c
ompleteURL.elidedString() + "' failed to load."); |
261 return; | 263 return; |
262 } | 264 } |
263 | 265 |
264 InspectorInstrumentation::scriptImported(&executionContext, scriptLoader
->identifier(), scriptLoader->script()); | 266 InspectorInstrumentation::scriptImported(&executionContext, scriptLoader
->identifier(), scriptLoader->script()); |
265 | 267 |
266 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = nullptr; | 268 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = nullptr; |
267 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent); | 269 OwnPtr<Vector<char>> cachedMetaData(scriptLoader->releaseCachedMetadata(
)); |
| 270 OwnPtr<CachedMetadataHandler> handler(createWorkerScriptCachedMetadataHa
ndler(completeURL, cachedMetaData.get())); |
| 271 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader
->responseURL()), &errorEvent, handler.get(), m_v8CacheOptions); |
268 if (errorEvent) { | 272 if (errorEvent) { |
269 m_script->rethrowExceptionFromImportedScript(errorEvent.release(), e
xceptionState); | 273 m_script->rethrowExceptionFromImportedScript(errorEvent.release(), e
xceptionState); |
270 return; | 274 return; |
271 } | 275 } |
272 } | 276 } |
273 } | 277 } |
274 | 278 |
275 EventTarget* WorkerGlobalScope::errorEventTarget() | 279 EventTarget* WorkerGlobalScope::errorEventTarget() |
276 { | 280 { |
277 return this; | 281 return this; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 visitor->trace(m_timers); | 376 visitor->trace(m_timers); |
373 visitor->trace(m_messageStorage); | 377 visitor->trace(m_messageStorage); |
374 visitor->trace(m_pendingMessages); | 378 visitor->trace(m_pendingMessages); |
375 HeapSupplementable<WorkerGlobalScope>::trace(visitor); | 379 HeapSupplementable<WorkerGlobalScope>::trace(visitor); |
376 #endif | 380 #endif |
377 ExecutionContext::trace(visitor); | 381 ExecutionContext::trace(visitor); |
378 EventTargetWithInlineData::trace(visitor); | 382 EventTargetWithInlineData::trace(visitor); |
379 } | 383 } |
380 | 384 |
381 } // namespace blink | 385 } // namespace blink |
OLD | NEW |