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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 private: | 108 private: |
109 RefPtr<SerializedScriptValue> m_message; | 109 RefPtr<SerializedScriptValue> m_message; |
110 OwnPtr<MessagePortChannelArray> m_channels; | 110 OwnPtr<MessagePortChannelArray> m_channels; |
111 WorkerMessagingProxy* m_messagingProxy; | 111 WorkerMessagingProxy* m_messagingProxy; |
112 }; | 112 }; |
113 | 113 |
114 class WorkerExceptionTask : public ScriptExecutionContext::Task { | 114 class WorkerExceptionTask : public ScriptExecutionContext::Task { |
115 public: | 115 public: |
116 static PassOwnPtr<WorkerExceptionTask> create(const String& errorMessage, in
t lineNumber, const String& sourceURL, WorkerMessagingProxy* messagingProxy) | 116 static PassOwnPtr<WorkerExceptionTask> create(const String& errorMessage, in
t lineNumber, int columnNumber, const String& sourceURL, WorkerMessagingProxy* m
essagingProxy) |
117 { | 117 { |
118 return adoptPtr(new WorkerExceptionTask(errorMessage, lineNumber, source
URL, messagingProxy)); | 118 return adoptPtr(new WorkerExceptionTask(errorMessage, lineNumber, column
Number, sourceURL, messagingProxy)); |
119 } | 119 } |
120 | 120 |
121 private: | 121 private: |
122 WorkerExceptionTask(const String& errorMessage, int lineNumber, const String
& sourceURL, WorkerMessagingProxy* messagingProxy) | 122 WorkerExceptionTask(const String& errorMessage, int lineNumber, int columnNu
mber, const String& sourceURL, WorkerMessagingProxy* messagingProxy) |
123 : m_errorMessage(errorMessage.isolatedCopy()) | 123 : m_errorMessage(errorMessage.isolatedCopy()) |
124 , m_lineNumber(lineNumber) | 124 , m_lineNumber(lineNumber) |
| 125 , m_columnNumber(columnNumber) |
125 , m_sourceURL(sourceURL.isolatedCopy()) | 126 , m_sourceURL(sourceURL.isolatedCopy()) |
126 , m_messagingProxy(messagingProxy) | 127 , m_messagingProxy(messagingProxy) |
127 { | 128 { |
128 } | 129 } |
129 | 130 |
130 virtual void performTask(ScriptExecutionContext* context) | 131 virtual void performTask(ScriptExecutionContext* context) |
131 { | 132 { |
132 Worker* workerObject = m_messagingProxy->workerObject(); | 133 Worker* workerObject = m_messagingProxy->workerObject(); |
133 if (!workerObject) | 134 if (!workerObject) |
134 return; | 135 return; |
135 | 136 |
136 // We don't bother checking the askedToTerminate() flag here, because ex
ceptions should *always* be reported even if the thread is terminated. | 137 // We don't bother checking the askedToTerminate() flag here, because ex
ceptions should *always* be reported even if the thread is terminated. |
137 // This is intentionally different than the behavior in MessageWorkerTas
k, because terminated workers no longer deliver messages (section 4.6 of the Web
Worker spec), but they do report exceptions. | 138 // This is intentionally different than the behavior in MessageWorkerTas
k, because terminated workers no longer deliver messages (section 4.6 of the Web
Worker spec), but they do report exceptions. |
138 | 139 |
139 bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_er
rorMessage, m_sourceURL, m_lineNumber)); | 140 bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_er
rorMessage, m_sourceURL, m_lineNumber, m_columnNumber)); |
140 if (!errorHandled) | 141 if (!errorHandled) |
141 context->reportException(m_errorMessage, m_lineNumber, m_sourceURL,
0); | 142 context->reportException(m_errorMessage, m_lineNumber, m_columnNumbe
r, m_sourceURL, 0); |
142 } | 143 } |
143 | 144 |
144 String m_errorMessage; | 145 String m_errorMessage; |
145 int m_lineNumber; | 146 int m_lineNumber; |
| 147 int m_columnNumber; |
146 String m_sourceURL; | 148 String m_sourceURL; |
147 WorkerMessagingProxy* m_messagingProxy; | 149 WorkerMessagingProxy* m_messagingProxy; |
148 }; | 150 }; |
149 | 151 |
150 class WorkerGlobalScopeDestroyedTask : public ScriptExecutionContext::Task { | 152 class WorkerGlobalScopeDestroyedTask : public ScriptExecutionContext::Task { |
151 public: | 153 public: |
152 static PassOwnPtr<WorkerGlobalScopeDestroyedTask> create(WorkerMessagingProx
y* messagingProxy) | 154 static PassOwnPtr<WorkerGlobalScopeDestroyedTask> create(WorkerMessagingProx
y* messagingProxy) |
153 { | 155 { |
154 return adoptPtr(new WorkerGlobalScopeDestroyedTask(messagingProxy)); | 156 return adoptPtr(new WorkerGlobalScopeDestroyedTask(messagingProxy)); |
155 } | 157 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return true; | 300 return true; |
299 } | 301 } |
300 | 302 |
301 void WorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::T
ask> task) | 303 void WorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::T
ask> task) |
302 { | 304 { |
303 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. | 305 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. |
304 ASSERT(m_scriptExecutionContext->isDocument()); | 306 ASSERT(m_scriptExecutionContext->isDocument()); |
305 m_scriptExecutionContext->postTask(task); | 307 m_scriptExecutionContext->postTask(task); |
306 } | 308 } |
307 | 309 |
308 void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessag
e, int lineNumber, const String& sourceURL) | 310 void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessag
e, int lineNumber, int columnNumber, const String& sourceURL) |
309 { | 311 { |
310 m_scriptExecutionContext->postTask(WorkerExceptionTask::create(errorMessage,
lineNumber, sourceURL, this)); | 312 m_scriptExecutionContext->postTask(WorkerExceptionTask::create(errorMessage,
lineNumber, columnNumber, sourceURL, this)); |
311 } | 313 } |
312 | 314 |
313 static void postConsoleMessageTask(ScriptExecutionContext* context, WorkerMessag
ingProxy* messagingProxy, MessageSource source, MessageLevel level, const String
& message, unsigned lineNumber, const String& sourceURL) | 315 static void postConsoleMessageTask(ScriptExecutionContext* context, WorkerMessag
ingProxy* messagingProxy, MessageSource source, MessageLevel level, const String
& message, unsigned lineNumber, const String& sourceURL) |
314 { | 316 { |
315 if (messagingProxy->askedToTerminate()) | 317 if (messagingProxy->askedToTerminate()) |
316 return; | 318 return; |
317 context->addConsoleMessage(source, level, message, sourceURL, lineNumber); | 319 context->addConsoleMessage(source, level, message, sourceURL, lineNumber); |
318 } | 320 } |
319 | 321 |
320 void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source
, MessageLevel level, const String& message, int lineNumber, const String& sourc
eURL) | 322 void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source
, MessageLevel level, const String& message, int lineNumber, const String& sourc
eURL) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 466 |
465 m_workerThreadHadPendingActivity = hasPendingActivity; | 467 m_workerThreadHadPendingActivity = hasPendingActivity; |
466 } | 468 } |
467 | 469 |
468 bool WorkerMessagingProxy::hasPendingActivity() const | 470 bool WorkerMessagingProxy::hasPendingActivity() const |
469 { | 471 { |
470 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; | 472 return (m_unconfirmedMessageCount || m_workerThreadHadPendingActivity) && !m
_askedToTerminate; |
471 } | 473 } |
472 | 474 |
473 } // namespace WebCore | 475 } // namespace WebCore |
OLD | NEW |