| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #if ENABLE(WORKERS) | 7 #if ENABLE(WORKERS) |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 | 10 |
| 11 #include "DedicatedWorkerThread.h" | 11 #include "DedicatedWorkerThread.h" |
| 12 #include "ErrorEvent.h" |
| 12 #include "Frame.h" | 13 #include "Frame.h" |
| 13 #include "FrameLoaderClient.h" | 14 #include "FrameLoaderClient.h" |
| 14 #include "GenericWorkerTask.h" | 15 #include "GenericWorkerTask.h" |
| 16 #include "MessageEvent.h" |
| 15 #include "MessagePort.h" | 17 #include "MessagePort.h" |
| 16 #include "MessagePortChannel.h" | 18 #include "MessagePortChannel.h" |
| 17 #include "ScriptExecutionContext.h" | 19 #include "ScriptExecutionContext.h" |
| 20 #include "Worker.h" |
| 21 #include "WorkerContext.h" |
| 18 #include "WorkerContextExecutionProxy.h" | 22 #include "WorkerContextExecutionProxy.h" |
| 19 #include "WorkerMessagingProxy.h" | 23 #include "WorkerMessagingProxy.h" |
| 20 #include "Worker.h" | |
| 21 #include "WorkerContext.h" | |
| 22 #include <wtf/Threading.h> | 24 #include <wtf/Threading.h> |
| 23 | 25 |
| 24 #undef LOG | 26 #undef LOG |
| 25 | 27 |
| 26 #include "webkit/glue/webworkerclient_impl.h" | 28 #include "webkit/glue/webworkerclient_impl.h" |
| 27 | 29 |
| 28 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 29 #include "webkit/api/public/WebFrameClient.h" | 31 #include "webkit/api/public/WebFrameClient.h" |
| 30 #include "webkit/api/public/WebKit.h" | 32 #include "webkit/api/public/WebKit.h" |
| 31 #include "webkit/api/public/WebKitClient.h" | 33 #include "webkit/api/public/WebKitClient.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 if (WTF::currentThread() != worker_thread_id_) { | 232 if (WTF::currentThread() != worker_thread_id_) { |
| 231 script_execution_context_->postTask( | 233 script_execution_context_->postTask( |
| 232 WebCore::createCallbackTask(&PostExceptionToWorkerObjectTask, this, | 234 WebCore::createCallbackTask(&PostExceptionToWorkerObjectTask, this, |
| 233 webkit_glue::WebStringToString(error_message), | 235 webkit_glue::WebStringToString(error_message), |
| 234 line_number, | 236 line_number, |
| 235 webkit_glue::WebStringToString(source_url))); | 237 webkit_glue::WebStringToString(source_url))); |
| 236 return; | 238 return; |
| 237 } | 239 } |
| 238 | 240 |
| 239 bool handled = false; | 241 bool handled = false; |
| 240 handled = worker_->dispatchScriptErrorEvent( | 242 handled = worker_->dispatchEvent( |
| 241 webkit_glue::WebStringToString(error_message), | 243 WebCore::ErrorEvent::create(webkit_glue::WebStringToString(error_message), |
| 242 webkit_glue::WebStringToString(source_url), | 244 webkit_glue::WebStringToString(source_url), |
| 243 line_number); | 245 line_number)); |
| 244 if (!handled) | 246 if (!handled) |
| 245 script_execution_context_->reportException( | 247 script_execution_context_->reportException( |
| 246 webkit_glue::WebStringToString(error_message), | 248 webkit_glue::WebStringToString(error_message), |
| 247 line_number, | 249 line_number, |
| 248 webkit_glue::WebStringToString(source_url)); | 250 webkit_glue::WebStringToString(source_url)); |
| 249 } | 251 } |
| 250 | 252 |
| 251 void WebWorkerClientImpl::postConsoleMessageToWorkerObject( | 253 void WebWorkerClientImpl::postConsoleMessageToWorkerObject( |
| 252 int destination_id, | 254 int destination_id, |
| 253 int source_id, | 255 int source_id, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 342 |
| 341 void WebWorkerClientImpl::PostMessageToWorkerObjectTask( | 343 void WebWorkerClientImpl::PostMessageToWorkerObjectTask( |
| 342 WebCore::ScriptExecutionContext* context, | 344 WebCore::ScriptExecutionContext* context, |
| 343 WebWorkerClientImpl* this_ptr, | 345 WebWorkerClientImpl* this_ptr, |
| 344 const WebCore::String& message, | 346 const WebCore::String& message, |
| 345 WTF::PassOwnPtr<WebCore::MessagePortChannelArray> channels) { | 347 WTF::PassOwnPtr<WebCore::MessagePortChannelArray> channels) { |
| 346 | 348 |
| 347 if (this_ptr->worker_) { | 349 if (this_ptr->worker_) { |
| 348 WTF::OwnPtr<WebCore::MessagePortArray> ports = | 350 WTF::OwnPtr<WebCore::MessagePortArray> ports = |
| 349 WebCore::MessagePort::entanglePorts(*context, channels.release()); | 351 WebCore::MessagePort::entanglePorts(*context, channels.release()); |
| 350 this_ptr->worker_->dispatchMessage(message, ports.release()); | 352 this_ptr->worker_->dispatchEvent( |
| 353 WebCore::MessageEvent::create(ports.release(), message)); |
| 351 } | 354 } |
| 352 } | 355 } |
| 353 | 356 |
| 354 void WebWorkerClientImpl::PostExceptionToWorkerObjectTask( | 357 void WebWorkerClientImpl::PostExceptionToWorkerObjectTask( |
| 355 WebCore::ScriptExecutionContext* context, | 358 WebCore::ScriptExecutionContext* context, |
| 356 WebWorkerClientImpl* this_ptr, | 359 WebWorkerClientImpl* this_ptr, |
| 357 const WebCore::String& error_message, | 360 const WebCore::String& error_message, |
| 358 int line_number, | 361 int line_number, |
| 359 const WebCore::String& source_url) { | 362 const WebCore::String& source_url) { |
| 360 bool handled = false; | 363 bool handled = false; |
| 361 if (this_ptr->worker_) | 364 if (this_ptr->worker_) |
| 362 handled = this_ptr->worker_->dispatchScriptErrorEvent( | 365 handled = this_ptr->worker_->dispatchEvent( |
| 363 error_message, source_url, line_number); | 366 WebCore::ErrorEvent::create(error_message, source_url, line_number)); |
| 364 if (!handled) | 367 if (!handled) |
| 365 this_ptr->script_execution_context_->reportException( | 368 this_ptr->script_execution_context_->reportException( |
| 366 error_message, line_number, source_url); | 369 error_message, line_number, source_url); |
| 367 } | 370 } |
| 368 | 371 |
| 369 void WebWorkerClientImpl::PostConsoleMessageToWorkerObjectTask( | 372 void WebWorkerClientImpl::PostConsoleMessageToWorkerObjectTask( |
| 370 WebCore::ScriptExecutionContext* context, | 373 WebCore::ScriptExecutionContext* context, |
| 371 WebWorkerClientImpl* this_ptr, | 374 WebWorkerClientImpl* this_ptr, |
| 372 int destination_id, | 375 int destination_id, |
| 373 int source_id, | 376 int source_id, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 393 } | 396 } |
| 394 | 397 |
| 395 void WebWorkerClientImpl::ReportPendingActivityTask( | 398 void WebWorkerClientImpl::ReportPendingActivityTask( |
| 396 WebCore::ScriptExecutionContext* context, | 399 WebCore::ScriptExecutionContext* context, |
| 397 WebWorkerClientImpl* this_ptr, | 400 WebWorkerClientImpl* this_ptr, |
| 398 bool has_pending_activity) { | 401 bool has_pending_activity) { |
| 399 this_ptr->worker_context_had_pending_activity_ = has_pending_activity; | 402 this_ptr->worker_context_had_pending_activity_ = has_pending_activity; |
| 400 } | 403 } |
| 401 | 404 |
| 402 #endif | 405 #endif |
| OLD | NEW |