| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return m_registration; | 123 return m_registration; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void ServiceWorkerGlobalScope::close(ExceptionState& exceptionState) | 126 void ServiceWorkerGlobalScope::close(ExceptionState& exceptionState) |
| 127 { | 127 { |
| 128 exceptionState.throwDOMException(InvalidAccessError, "Not supported."); | 128 exceptionState.throwDOMException(InvalidAccessError, "Not supported."); |
| 129 } | 129 } |
| 130 | 130 |
| 131 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState) | 131 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState) |
| 132 { | 132 { |
| 133 ExecutionContext* executionContext = scriptState->executionContext(); | 133 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
| 134 // FIXME: short-term fix, see details at: https://codereview.chromium.org/53
5193002/. | 134 // FIXME: short-term fix, see details at: https://codereview.chromium.org/53
5193002/. |
| 135 if (!executionContext) | 135 if (!executionContext) |
| 136 return ScriptPromise(); | 136 return ScriptPromise(); |
| 137 | 137 |
| 138 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 138 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 139 ScriptPromise promise = resolver->promise(); | 139 ScriptPromise promise = resolver->promise(); |
| 140 | 140 |
| 141 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Call
backPromiseAdapter<void, void>(resolver)); | 141 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Call
backPromiseAdapter<void, void>(resolver)); |
| 142 return promise; | 142 return promise; |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ServiceWorkerGlobalScope::setRegistration(WebPassOwnPtr<WebServiceWorkerReg
istration::Handle> handle) | 145 void ServiceWorkerGlobalScope::setRegistration(WebPassOwnPtr<WebServiceWorkerReg
istration::Handle> handle) |
| 146 { | 146 { |
| 147 if (!executionContext()) | 147 if (!getExecutionContext()) |
| 148 return; | 148 return; |
| 149 m_registration = ServiceWorkerRegistration::getOrCreate(executionContext(),
handle.release()); | 149 m_registration = ServiceWorkerRegistration::getOrCreate(getExecutionContext(
), handle.release()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool ServiceWorkerGlobalScope::addEventListenerInternal(const AtomicString& even
tType, PassRefPtrWillBeRawPtr<EventListener> listener, const EventListenerOption
s& options) | 152 bool ServiceWorkerGlobalScope::addEventListenerInternal(const AtomicString& even
tType, PassRefPtrWillBeRawPtr<EventListener> listener, const EventListenerOption
s& options) |
| 153 { | 153 { |
| 154 if (m_didEvaluateScript) { | 154 if (m_didEvaluateScript) { |
| 155 if (eventType == EventTypeNames::install) { | 155 if (eventType == EventTypeNames::install) { |
| 156 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(JSMessageSource, WarningMessageLevel, "Event handler of 'install' event m
ust be added on the initial evaluation of worker script."); | 156 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(JSMessageSource, WarningMessageLevel, "Event handler of 'install' event m
ust be added on the initial evaluation of worker script."); |
| 157 addMessageToWorkerConsole(consoleMessage.release()); | 157 addMessageToWorkerConsole(consoleMessage.release()); |
| 158 } else if (eventType == EventTypeNames::activate) { | 158 } else if (eventType == EventTypeNames::activate) { |
| 159 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(JSMessageSource, WarningMessageLevel, "Event handler of 'activate' event
must be added on the initial evaluation of worker script."); | 159 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(JSMessageSource, WarningMessageLevel, "Event handler of 'activate' event
must be added on the initial evaluation of worker script."); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 visitor->trace(m_registration); | 196 visitor->trace(m_registration); |
| 197 WorkerGlobalScope::trace(visitor); | 197 WorkerGlobalScope::trace(visitor); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls, Excepti
onState& exceptionState) | 200 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls, Excepti
onState& exceptionState) |
| 201 { | 201 { |
| 202 // Bust the MemoryCache to ensure script requests reach the browser-side | 202 // Bust the MemoryCache to ensure script requests reach the browser-side |
| 203 // and get added to and retrieved from the ServiceWorker's script cache. | 203 // and get added to and retrieved from the ServiceWorker's script cache. |
| 204 // FIXME: Revisit in light of the solution to crbug/388375. | 204 // FIXME: Revisit in light of the solution to crbug/388375. |
| 205 for (Vector<String>::const_iterator it = urls.begin(); it != urls.end(); ++i
t) | 205 for (Vector<String>::const_iterator it = urls.begin(); it != urls.end(); ++i
t) |
| 206 executionContext()->removeURLFromMemoryCache(completeURL(*it)); | 206 getExecutionContext()->removeURLFromMemoryCache(completeURL(*it)); |
| 207 WorkerGlobalScope::importScripts(urls, exceptionState); | 207 WorkerGlobalScope::importScripts(urls, exceptionState); |
| 208 } | 208 } |
| 209 | 209 |
| 210 PassOwnPtrWillBeRawPtr<CachedMetadataHandler> ServiceWorkerGlobalScope::createWo
rkerScriptCachedMetadataHandler(const KURL& scriptURL, const Vector<char>* metaD
ata) | 210 PassOwnPtrWillBeRawPtr<CachedMetadataHandler> ServiceWorkerGlobalScope::createWo
rkerScriptCachedMetadataHandler(const KURL& scriptURL, const Vector<char>* metaD
ata) |
| 211 { | 211 { |
| 212 return ServiceWorkerScriptCachedMetadataHandler::create(this, scriptURL, met
aData); | 212 return ServiceWorkerScriptCachedMetadataHandler::create(this, scriptURL, met
aData); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage,
int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe
fPtr<ScriptCallStack> callStack) | 215 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage,
int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe
fPtr<ScriptCallStack> callStack) |
| 216 { | 216 { |
| 217 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL,
lineNumber, columnNumber, callStack); | 217 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL,
lineNumber, columnNumber, callStack); |
| 218 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J
SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNu
mber); | 218 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J
SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNu
mber); |
| 219 consoleMessage->setScriptId(scriptId); | 219 consoleMessage->setScriptId(scriptId); |
| 220 consoleMessage->setCallStack(callStack); | 220 consoleMessage->setCallStack(callStack); |
| 221 addMessageToWorkerConsole(consoleMessage.release()); | 221 addMessageToWorkerConsole(consoleMessage.release()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta
dataSize) | 224 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta
dataSize) |
| 225 { | 225 { |
| 226 ++m_scriptCount; | 226 ++m_scriptCount; |
| 227 m_scriptTotalSize += scriptSize; | 227 m_scriptTotalSize += scriptSize; |
| 228 m_scriptCachedMetadataTotalSize += cachedMetadataSize; | 228 m_scriptCachedMetadataTotalSize += cachedMetadataSize; |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace blink | 231 } // namespace blink |
| OLD | NEW |