| 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 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/workers/WorkerObjectProxy.h" | 49 #include "core/workers/WorkerObjectProxy.h" |
| 50 #include "core/workers/WorkerThreadStartupData.h" | 50 #include "core/workers/WorkerThreadStartupData.h" |
| 51 #include "platform/heap/Handle.h" | 51 #include "platform/heap/Handle.h" |
| 52 #include "wtf/Functional.h" | 52 #include "wtf/Functional.h" |
| 53 #include "wtf/MainThread.h" | 53 #include "wtf/MainThread.h" |
| 54 | 54 |
| 55 namespace blink { | 55 namespace blink { |
| 56 | 56 |
| 57 namespace { | 57 namespace { |
| 58 | 58 |
| 59 void processExceptionOnWorkerGlobalScope(int exceptionId, bool isHandled, Execut
ionContext* scriptContext) |
| 60 { |
| 61 WorkerGlobalScope* globalScope = toWorkerGlobalScope(scriptContext); |
| 62 globalScope->exceptionHandled(exceptionId, isHandled); |
| 63 } |
| 64 |
| 59 void processMessageOnWorkerGlobalScope(PassRefPtr<SerializedScriptValue> message
, PassOwnPtr<MessagePortChannelArray> channels, WorkerObjectProxy* workerObjectP
roxy, ExecutionContext* scriptContext) | 65 void processMessageOnWorkerGlobalScope(PassRefPtr<SerializedScriptValue> message
, PassOwnPtr<MessagePortChannelArray> channels, WorkerObjectProxy* workerObjectP
roxy, ExecutionContext* scriptContext) |
| 60 { | 66 { |
| 61 WorkerGlobalScope* globalScope = toWorkerGlobalScope(scriptContext); | 67 WorkerGlobalScope* globalScope = toWorkerGlobalScope(scriptContext); |
| 62 MessagePortArray* ports = MessagePort::entanglePorts(*scriptContext, channel
s); | 68 MessagePortArray* ports = MessagePort::entanglePorts(*scriptContext, channel
s); |
| 63 globalScope->dispatchEvent(MessageEvent::create(ports, message)); | 69 globalScope->dispatchEvent(MessageEvent::create(ports, message)); |
| 64 workerObjectProxy->confirmMessageFromWorkerObject(scriptContext->hasPendingA
ctivity()); | 70 workerObjectProxy->confirmMessageFromWorkerObject(scriptContext->hasPendingA
ctivity()); |
| 65 } | 71 } |
| 66 | 72 |
| 67 } // namespace | 73 } // namespace |
| 68 | 74 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void WorkerMessagingProxy::reportException(const String& errorMessage, int lineN
umber, int columnNumber, const String& sourceURL, int exceptionId) | 165 void WorkerMessagingProxy::reportException(const String& errorMessage, int lineN
umber, int columnNumber, const String& sourceURL, int exceptionId) |
| 160 { | 166 { |
| 161 if (!m_workerObject) | 167 if (!m_workerObject) |
| 162 return; | 168 return; |
| 163 | 169 |
| 164 // We don't bother checking the askedToTerminate() flag here, because except
ions should *always* be reported even if the thread is terminated. | 170 // We don't bother checking the askedToTerminate() flag here, because except
ions should *always* be reported even if the thread is terminated. |
| 165 // This is intentionally different than the behavior in MessageWorkerTask, b
ecause terminated workers no longer deliver messages (section 4.6 of the WebWork
er spec), but they do report exceptions. | 171 // This is intentionally different than the behavior in MessageWorkerTask, b
ecause terminated workers no longer deliver messages (section 4.6 of the WebWork
er spec), but they do report exceptions. |
| 166 | 172 |
| 167 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sour
ceURL, lineNumber, columnNumber, nullptr); | 173 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sour
ceURL, lineNumber, columnNumber, nullptr); |
| 168 bool errorHandled = !m_workerObject->dispatchEvent(event); | 174 bool errorHandled = !m_workerObject->dispatchEvent(event); |
| 169 | 175 postTaskToWorkerGlobalScope(createCrossThreadTask(&processExceptionOnWorkerG
lobalScope, exceptionId, errorHandled)); |
| 170 postTaskToWorkerGlobalScope(createCrossThreadTask(&WorkerGlobalScope::except
ionHandled, m_workerThread->workerGlobalScope(), exceptionId, errorHandled)); | |
| 171 } | 176 } |
| 172 | 177 |
| 173 void WorkerMessagingProxy::reportConsoleMessage(MessageSource source, MessageLev
el level, const String& message, int lineNumber, const String& sourceURL) | 178 void WorkerMessagingProxy::reportConsoleMessage(MessageSource source, MessageLev
el level, const String& message, int lineNumber, const String& sourceURL) |
| 174 { | 179 { |
| 175 if (m_askedToTerminate) | 180 if (m_askedToTerminate) |
| 176 return; | 181 return; |
| 177 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. | 182 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. |
| 178 ASSERT(m_executionContext->isDocument()); | 183 ASSERT(m_executionContext->isDocument()); |
| 179 Document* document = toDocument(m_executionContext.get()); | 184 Document* document = toDocument(m_executionContext.get()); |
| 180 LocalFrame* frame = document->frame(); | 185 LocalFrame* frame = document->frame(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 295 |
| 291 // FIXME: This need to be revisited when we support nested worker one day | 296 // FIXME: This need to be revisited when we support nested worker one day |
| 292 ASSERT(m_executionContext->isDocument()); | 297 ASSERT(m_executionContext->isDocument()); |
| 293 Document* document = toDocument(m_executionContext.get()); | 298 Document* document = toDocument(m_executionContext.get()); |
| 294 LocalFrame* frame = document->frame(); | 299 LocalFrame* frame = document->frame(); |
| 295 if (frame) | 300 if (frame) |
| 296 frame->console().adoptWorkerMessagesAfterTermination(this); | 301 frame->console().adoptWorkerMessagesAfterTermination(this); |
| 297 } | 302 } |
| 298 | 303 |
| 299 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |