| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "bindings/core/v8/ScriptState.h" | 37 #include "bindings/core/v8/ScriptState.h" |
| 38 #include "bindings/core/v8/V8ThrowException.h" | 38 #include "bindings/core/v8/V8ThrowException.h" |
| 39 #include "core/dom/ExceptionCode.h" | 39 #include "core/dom/ExceptionCode.h" |
| 40 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
| 41 #include "core/fetch/MemoryCache.h" | 41 #include "core/fetch/MemoryCache.h" |
| 42 #include "core/fetch/ResourceLoaderOptions.h" | 42 #include "core/fetch/ResourceLoaderOptions.h" |
| 43 #include "core/inspector/ConsoleMessage.h" | 43 #include "core/inspector/ConsoleMessage.h" |
| 44 #include "core/inspector/WorkerInspectorController.h" | 44 #include "core/inspector/WorkerInspectorController.h" |
| 45 #include "core/loader/ThreadableLoader.h" | 45 #include "core/loader/ThreadableLoader.h" |
| 46 #include "core/workers/WorkerClients.h" | 46 #include "core/workers/WorkerClients.h" |
| 47 #include "core/workers/WorkerThreadStartupData.h" | 47 #include "core/workers/WorkerScriptStartupData.h" |
| 48 #include "modules/EventTargetModules.h" | 48 #include "modules/EventTargetModules.h" |
| 49 #include "modules/cachestorage/CacheStorage.h" | 49 #include "modules/cachestorage/CacheStorage.h" |
| 50 #include "modules/cachestorage/InspectorCacheStorageAgent.h" | 50 #include "modules/cachestorage/InspectorCacheStorageAgent.h" |
| 51 #include "modules/fetch/GlobalFetch.h" | 51 #include "modules/fetch/GlobalFetch.h" |
| 52 #include "modules/serviceworkers/ServiceWorkerClients.h" | 52 #include "modules/serviceworkers/ServiceWorkerClients.h" |
| 53 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 53 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 54 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 54 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 55 #include "modules/serviceworkers/ServiceWorkerScript.h" |
| 55 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h" | 56 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h" |
| 56 #include "modules/serviceworkers/ServiceWorkerThread.h" | |
| 57 #include "modules/serviceworkers/WaitUntilObserver.h" | 57 #include "modules/serviceworkers/WaitUntilObserver.h" |
| 58 #include "platform/Histogram.h" | 58 #include "platform/Histogram.h" |
| 59 #include "platform/network/ResourceRequest.h" | 59 #include "platform/network/ResourceRequest.h" |
| 60 #include "platform/weborigin/DatabaseIdentifier.h" | 60 #include "platform/weborigin/DatabaseIdentifier.h" |
| 61 #include "platform/weborigin/KURL.h" | 61 #include "platform/weborigin/KURL.h" |
| 62 #include "public/platform/Platform.h" | 62 #include "public/platform/Platform.h" |
| 63 #include "public/platform/WebURL.h" | 63 #include "public/platform/WebURL.h" |
| 64 #include "wtf/CurrentTime.h" | 64 #include "wtf/CurrentTime.h" |
| 65 | 65 |
| 66 namespace blink { | 66 namespace blink { |
| 67 | 67 |
| 68 PassRefPtrWillBeRawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::creat
e(ServiceWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> startupData) | 68 PassRefPtrWillBeRawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::creat
e(ServiceWorkerScript* script, PassOwnPtr<WorkerScriptStartupData> startupData) |
| 69 { | 69 { |
| 70 // Note: startupData is finalized on return. After the relevant parts has be
en | 70 // Note: startupData is finalized on return. After the relevant parts has be
en |
| 71 // passed along to the created 'context'. | 71 // passed along to the created 'context'. |
| 72 RefPtrWillBeRawPtr<ServiceWorkerGlobalScope> context = adoptRefWillBeNoop(ne
w ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, t
hread, monotonicallyIncreasingTime(), startupData->m_starterOriginPrivilegeData.
release(), startupData->m_workerClients.release())); | 72 RefPtrWillBeRawPtr<ServiceWorkerGlobalScope> context = adoptRefWillBeNoop(ne
w ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, s
cript, monotonicallyIncreasingTime(), startupData->m_starterOriginPrivilegeData.
release(), startupData->m_workerClients.release())); |
| 73 | 73 |
| 74 context->setV8CacheOptions(startupData->m_v8CacheOptions); | 74 context->setV8CacheOptions(startupData->m_v8CacheOptions); |
| 75 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit
yPolicyHeaders); | 75 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit
yPolicyHeaders); |
| 76 | 76 |
| 77 return context.release(); | 77 return context.release(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String
& userAgent, ServiceWorkerThread* thread, double timeOrigin, PassOwnPtr<Security
Origin::PrivilegeData> starterOriginPrivilegeData, PassOwnPtrWillBeRawPtr<Worker
Clients> workerClients) | 80 ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String
& userAgent, ServiceWorkerScript* script, double timeOrigin, PassOwnPtr<Security
Origin::PrivilegeData> starterOriginPrivilegeData, PassOwnPtrWillBeRawPtr<Worker
Clients> workerClients) |
| 81 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivile
geData, workerClients) | 81 : WorkerGlobalScope(url, userAgent, script, timeOrigin, starterOriginPrivile
geData, workerClients) |
| 82 , m_didEvaluateScript(false) | 82 , m_didEvaluateScript(false) |
| 83 , m_hadErrorInTopLevelEventHandler(false) | 83 , m_hadErrorInTopLevelEventHandler(false) |
| 84 , m_eventNestingLevel(0) | 84 , m_eventNestingLevel(0) |
| 85 , m_scriptCount(0) | 85 , m_scriptCount(0) |
| 86 , m_scriptTotalSize(0) | 86 , m_scriptTotalSize(0) |
| 87 , m_scriptCachedMetadataTotalSize(0) | 87 , m_scriptCachedMetadataTotalSize(0) |
| 88 { | 88 { |
| 89 } | 89 } |
| 90 | 90 |
| 91 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() | 91 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return result; | 177 return result; |
| 178 } | 178 } |
| 179 | 179 |
| 180 void ServiceWorkerGlobalScope::dispatchExtendableEvent(PassRefPtrWillBeRawPtr<Ev
ent> event, WaitUntilObserver* observer) | 180 void ServiceWorkerGlobalScope::dispatchExtendableEvent(PassRefPtrWillBeRawPtr<Ev
ent> event, WaitUntilObserver* observer) |
| 181 { | 181 { |
| 182 ASSERT(m_eventNestingLevel == 0); | 182 ASSERT(m_eventNestingLevel == 0); |
| 183 m_hadErrorInTopLevelEventHandler = false; | 183 m_hadErrorInTopLevelEventHandler = false; |
| 184 | 184 |
| 185 observer->willDispatchEvent(); | 185 observer->willDispatchEvent(); |
| 186 dispatchEvent(event); | 186 dispatchEvent(event); |
| 187 if (thread()->terminated()) | 187 if (workerScript()->terminated()) |
| 188 m_hadErrorInTopLevelEventHandler = true; | 188 m_hadErrorInTopLevelEventHandler = true; |
| 189 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler); | 189 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler); |
| 190 } | 190 } |
| 191 | 191 |
| 192 DEFINE_TRACE(ServiceWorkerGlobalScope) | 192 DEFINE_TRACE(ServiceWorkerGlobalScope) |
| 193 { | 193 { |
| 194 visitor->trace(m_clients); | 194 visitor->trace(m_clients); |
| 195 visitor->trace(m_registration); | 195 visitor->trace(m_registration); |
| 196 WorkerGlobalScope::trace(visitor); | 196 WorkerGlobalScope::trace(visitor); |
| 197 } | 197 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta
dataSize) | 223 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta
dataSize) |
| 224 { | 224 { |
| 225 ++m_scriptCount; | 225 ++m_scriptCount; |
| 226 m_scriptTotalSize += scriptSize; | 226 m_scriptTotalSize += scriptSize; |
| 227 m_scriptCachedMetadataTotalSize += cachedMetadataSize; | 227 m_scriptCachedMetadataTotalSize += cachedMetadataSize; |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace blink | 230 } // namespace blink |
| OLD | NEW |