| 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 "core/fetch/MemoryCache.h" | 37 #include "core/fetch/MemoryCache.h" |
| 38 #include "core/fetch/ResourceLoaderOptions.h" | 38 #include "core/fetch/ResourceLoaderOptions.h" |
| 39 #include "core/inspector/ConsoleMessage.h" | 39 #include "core/inspector/ConsoleMessage.h" |
| 40 #include "core/inspector/ScriptCallStack.h" | 40 #include "core/inspector/ScriptCallStack.h" |
| 41 #include "core/inspector/WorkerInspectorController.h" | 41 #include "core/inspector/WorkerInspectorController.h" |
| 42 #include "core/loader/ThreadableLoader.h" | 42 #include "core/loader/ThreadableLoader.h" |
| 43 #include "core/workers/WorkerClients.h" | 43 #include "core/workers/WorkerClients.h" |
| 44 #include "core/workers/WorkerThreadStartupData.h" | 44 #include "core/workers/WorkerThreadStartupData.h" |
| 45 #include "modules/EventTargetModules.h" | 45 #include "modules/EventTargetModules.h" |
| 46 #include "modules/fetch/GlobalFetch.h" | 46 #include "modules/fetch/GlobalFetch.h" |
| 47 #include "modules/serviceworkers/CacheStorage.h" | |
| 48 #include "modules/serviceworkers/InspectorServiceWorkerCacheAgent.h" | 47 #include "modules/serviceworkers/InspectorServiceWorkerCacheAgent.h" |
| 49 #include "modules/serviceworkers/ServiceWorkerClients.h" | 48 #include "modules/serviceworkers/ServiceWorkerClients.h" |
| 50 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 49 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 51 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 50 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 52 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h" | 51 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h" |
| 53 #include "modules/serviceworkers/ServiceWorkerThread.h" | 52 #include "modules/serviceworkers/ServiceWorkerThread.h" |
| 54 #include "modules/serviceworkers/WaitUntilObserver.h" | 53 #include "modules/serviceworkers/WaitUntilObserver.h" |
| 55 #include "platform/network/ResourceRequest.h" | 54 #include "platform/network/ResourceRequest.h" |
| 56 #include "platform/weborigin/DatabaseIdentifier.h" | 55 #include "platform/weborigin/DatabaseIdentifier.h" |
| 57 #include "platform/weborigin/KURL.h" | 56 #include "platform/weborigin/KURL.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 { | 109 { |
| 111 if (Platform* platform = Platform::current()) { | 110 if (Platform* platform = Platform::current()) { |
| 112 platform->histogramCustomCounts("ServiceWorker.ScriptCount", m_scriptCou
nt, 1, 1000, 50); | 111 platform->histogramCustomCounts("ServiceWorker.ScriptCount", m_scriptCou
nt, 1, 1000, 50); |
| 113 platform->histogramCustomCounts("ServiceWorker.ScriptTotalSize", m_scrip
tTotalSize, 1000, 5000000, 50); | 112 platform->histogramCustomCounts("ServiceWorker.ScriptTotalSize", m_scrip
tTotalSize, 1000, 5000000, 50); |
| 114 if (m_scriptCachedMetadataTotalSize) | 113 if (m_scriptCachedMetadataTotalSize) |
| 115 platform->histogramCustomCounts("ServiceWorker.ScriptCachedMetadataT
otalSize", m_scriptCachedMetadataTotalSize, 1000, 50000000, 50); | 114 platform->histogramCustomCounts("ServiceWorker.ScriptCachedMetadataT
otalSize", m_scriptCachedMetadataTotalSize, 1000, 50000000, 50); |
| 116 } | 115 } |
| 117 m_didEvaluateScript = true; | 116 m_didEvaluateScript = true; |
| 118 } | 117 } |
| 119 | 118 |
| 120 CacheStorage* ServiceWorkerGlobalScope::caches(ExecutionContext* context) | |
| 121 { | |
| 122 if (!m_caches) { | |
| 123 String identifier = createDatabaseIdentifierFromSecurityOrigin(context->
securityOrigin()); | |
| 124 ASSERT(!identifier.isEmpty()); | |
| 125 m_caches = CacheStorage::create(Platform::current()->cacheStorage(identi
fier)); | |
| 126 } | |
| 127 return m_caches; | |
| 128 } | |
| 129 | |
| 130 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const Re
questInfo& input, const Dictionary& init, ExceptionState& exceptionState) | 119 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const Re
questInfo& input, const Dictionary& init, ExceptionState& exceptionState) |
| 131 { | 120 { |
| 132 return GlobalFetch::fetch(scriptState, *this, input, init, exceptionState); | 121 return GlobalFetch::fetch(scriptState, *this, input, init, exceptionState); |
| 133 } | 122 } |
| 134 | 123 |
| 135 ServiceWorkerClients* ServiceWorkerGlobalScope::clients() | 124 ServiceWorkerClients* ServiceWorkerGlobalScope::clients() |
| 136 { | 125 { |
| 137 if (!m_clients) | 126 if (!m_clients) |
| 138 m_clients = ServiceWorkerClients::create(); | 127 m_clients = ServiceWorkerClients::create(); |
| 139 return m_clients; | 128 return m_clients; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 dispatchEvent(event); | 199 dispatchEvent(event); |
| 211 if (thread()->terminated()) | 200 if (thread()->terminated()) |
| 212 m_hadErrorInTopLevelEventHandler = true; | 201 m_hadErrorInTopLevelEventHandler = true; |
| 213 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler); | 202 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler); |
| 214 } | 203 } |
| 215 | 204 |
| 216 DEFINE_TRACE(ServiceWorkerGlobalScope) | 205 DEFINE_TRACE(ServiceWorkerGlobalScope) |
| 217 { | 206 { |
| 218 visitor->trace(m_clients); | 207 visitor->trace(m_clients); |
| 219 visitor->trace(m_registration); | 208 visitor->trace(m_registration); |
| 220 visitor->trace(m_caches); | |
| 221 WorkerGlobalScope::trace(visitor); | 209 WorkerGlobalScope::trace(visitor); |
| 222 } | 210 } |
| 223 | 211 |
| 224 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls, Excepti
onState& exceptionState) | 212 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls, Excepti
onState& exceptionState) |
| 225 { | 213 { |
| 226 // Bust the MemoryCache to ensure script requests reach the browser-side | 214 // Bust the MemoryCache to ensure script requests reach the browser-side |
| 227 // and get added to and retrieved from the ServiceWorker's script cache. | 215 // and get added to and retrieved from the ServiceWorker's script cache. |
| 228 // FIXME: Revisit in light of the solution to crbug/388375. | 216 // FIXME: Revisit in light of the solution to crbug/388375. |
| 229 for (Vector<String>::const_iterator it = urls.begin(); it != urls.end(); ++i
t) | 217 for (Vector<String>::const_iterator it = urls.begin(); it != urls.end(); ++i
t) |
| 230 executionContext()->removeURLFromMemoryCache(completeURL(*it)); | 218 executionContext()->removeURLFromMemoryCache(completeURL(*it)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 246 } | 234 } |
| 247 | 235 |
| 248 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta
dataSize) | 236 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta
dataSize) |
| 249 { | 237 { |
| 250 ++m_scriptCount; | 238 ++m_scriptCount; |
| 251 m_scriptTotalSize += scriptSize; | 239 m_scriptTotalSize += scriptSize; |
| 252 m_scriptCachedMetadataTotalSize += cachedMetadataSize; | 240 m_scriptCachedMetadataTotalSize += cachedMetadataSize; |
| 253 } | 241 } |
| 254 | 242 |
| 255 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |