| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 double timeOrigin, | 97 double timeOrigin, |
| 98 std::unique_ptr<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, | 98 std::unique_ptr<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, |
| 99 WorkerClients* workerClients) | 99 WorkerClients* workerClients) |
| 100 : WorkerGlobalScope(url, | 100 : WorkerGlobalScope(url, |
| 101 userAgent, | 101 userAgent, |
| 102 thread, | 102 thread, |
| 103 timeOrigin, | 103 timeOrigin, |
| 104 std::move(starterOriginPrivilegeData), | 104 std::move(starterOriginPrivilegeData), |
| 105 workerClients), | 105 workerClients), |
| 106 m_didEvaluateScript(false), | 106 m_didEvaluateScript(false), |
| 107 m_hadErrorInTopLevelEventHandler(false), | |
| 108 m_eventNestingLevel(0), | |
| 109 m_scriptCount(0), | 107 m_scriptCount(0), |
| 110 m_scriptTotalSize(0), | 108 m_scriptTotalSize(0), |
| 111 m_scriptCachedMetadataTotalSize(0) {} | 109 m_scriptCachedMetadataTotalSize(0) {} |
| 112 | 110 |
| 113 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() {} | 111 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() {} |
| 114 | 112 |
| 115 void ServiceWorkerGlobalScope::countScript(size_t scriptSize, | 113 void ServiceWorkerGlobalScope::countScript(size_t scriptSize, |
| 116 size_t cachedMetadataSize) { | 114 size_t cachedMetadataSize) { |
| 117 ++m_scriptCount; | 115 ++m_scriptCount; |
| 118 m_scriptTotalSize += scriptSize; | 116 m_scriptTotalSize += scriptSize; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); | 191 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
| 194 } | 192 } |
| 195 return WorkerGlobalScope::addEventListenerInternal(eventType, listener, | 193 return WorkerGlobalScope::addEventListenerInternal(eventType, listener, |
| 196 options); | 194 options); |
| 197 } | 195 } |
| 198 | 196 |
| 199 const AtomicString& ServiceWorkerGlobalScope::interfaceName() const { | 197 const AtomicString& ServiceWorkerGlobalScope::interfaceName() const { |
| 200 return EventTargetNames::ServiceWorkerGlobalScope; | 198 return EventTargetNames::ServiceWorkerGlobalScope; |
| 201 } | 199 } |
| 202 | 200 |
| 203 DispatchEventResult ServiceWorkerGlobalScope::dispatchEventInternal( | |
| 204 Event* event) { | |
| 205 m_eventNestingLevel++; | |
| 206 DispatchEventResult dispatchResult = | |
| 207 WorkerGlobalScope::dispatchEventInternal(event); | |
| 208 if (event->interfaceName() == EventNames::ErrorEvent && | |
| 209 m_eventNestingLevel == 2) | |
| 210 m_hadErrorInTopLevelEventHandler = true; | |
| 211 m_eventNestingLevel--; | |
| 212 return dispatchResult; | |
| 213 } | |
| 214 | |
| 215 void ServiceWorkerGlobalScope::dispatchExtendableEvent( | 201 void ServiceWorkerGlobalScope::dispatchExtendableEvent( |
| 216 Event* event, | 202 Event* event, |
| 217 WaitUntilObserver* observer) { | 203 WaitUntilObserver* observer) { |
| 218 ASSERT(m_eventNestingLevel == 0); | |
| 219 m_hadErrorInTopLevelEventHandler = false; | |
| 220 | |
| 221 observer->willDispatchEvent(); | 204 observer->willDispatchEvent(); |
| 222 dispatchEvent(event); | 205 dispatchEvent(event); |
| 223 | 206 |
| 224 // Check if the worker thread is forcibly terminated during the event | 207 // Check if the worker thread is forcibly terminated during the event |
| 225 // because of timeout etc. | 208 // because of timeout etc. |
| 226 if (thread()->isForciblyTerminated()) | 209 observer->didDispatchEvent(thread()->isForciblyTerminated()); |
| 227 m_hadErrorInTopLevelEventHandler = true; | |
| 228 | |
| 229 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler); | |
| 230 } | 210 } |
| 231 | 211 |
| 232 DEFINE_TRACE(ServiceWorkerGlobalScope) { | 212 DEFINE_TRACE(ServiceWorkerGlobalScope) { |
| 233 visitor->trace(m_clients); | 213 visitor->trace(m_clients); |
| 234 visitor->trace(m_registration); | 214 visitor->trace(m_registration); |
| 235 WorkerGlobalScope::trace(visitor); | 215 WorkerGlobalScope::trace(visitor); |
| 236 } | 216 } |
| 237 | 217 |
| 238 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls, | 218 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls, |
| 239 ExceptionState& exceptionState) { | 219 ExceptionState& exceptionState) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 254 } | 234 } |
| 255 | 235 |
| 256 void ServiceWorkerGlobalScope::exceptionThrown(ErrorEvent* event) { | 236 void ServiceWorkerGlobalScope::exceptionThrown(ErrorEvent* event) { |
| 257 WorkerGlobalScope::exceptionThrown(event); | 237 WorkerGlobalScope::exceptionThrown(event); |
| 258 if (WorkerThreadDebugger* debugger = | 238 if (WorkerThreadDebugger* debugger = |
| 259 WorkerThreadDebugger::from(thread()->isolate())) | 239 WorkerThreadDebugger::from(thread()->isolate())) |
| 260 debugger->exceptionThrown(thread(), event); | 240 debugger->exceptionThrown(thread(), event); |
| 261 } | 241 } |
| 262 | 242 |
| 263 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |