diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-06 02:11:58 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-06 02:11:58 +0000 |
commit | cfb8c047aae384eb1e6c27c047832ff41a8764b3 (patch) | |
tree | e4ecc7853bc3314c83f3855eca620c6b9f478748 /webkit/glue/webworkerclient_impl.cc | |
parent | ad615eb3ff51a7d75c065498460e060ad17028ca (diff) | |
download | chromium_src-cfb8c047aae384eb1e6c27c047832ff41a8764b3.zip chromium_src-cfb8c047aae384eb1e6c27c047832ff41a8764b3.tar.gz chromium_src-cfb8c047aae384eb1e6c27c047832ff41a8764b3.tar.bz2 |
Fix lifetime control for worker and worker context.
Review URL: http://codereview.chromium.org/40197
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webworkerclient_impl.cc')
-rw-r--r-- | webkit/glue/webworkerclient_impl.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/webkit/glue/webworkerclient_impl.cc b/webkit/glue/webworkerclient_impl.cc index c75bff4..11ccfca 100644 --- a/webkit/glue/webworkerclient_impl.cc +++ b/webkit/glue/webworkerclient_impl.cc @@ -10,6 +10,7 @@ #include "Frame.h" #include "FrameLoaderClient.h" +#include "ScriptExecutionContext.h" #include "WorkerMessagingProxy.h" #include "Worker.h" @@ -55,7 +56,8 @@ WebCore::WorkerContextProxy* WebCore::WorkerContextProxy::create( WebWorkerClientImpl::WebWorkerClientImpl(WebCore::Worker* worker) - : worker_(worker), + : script_execution_context_(worker->scriptExecutionContext()), + worker_(worker), asked_to_terminate_(false), unconfirmed_message_count_(0), worker_context_had_pending_activity_(false) { @@ -99,6 +101,9 @@ bool WebWorkerClientImpl::hasPendingActivity() const { void WebWorkerClientImpl::workerObjectDestroyed() { webworker_->WorkerObjectDestroyed(); + + // The lifetime of this proxy is controlled by the worker. + delete this; } void WebWorkerClientImpl::PostMessageToWorkerObject(const string16& message) { @@ -109,7 +114,7 @@ void WebWorkerClientImpl::PostExceptionToWorkerObject( const string16& error_message, int line_number, const string16& source_url) { - worker_->scriptExecutionContext()->reportException( + script_execution_context_->reportException( webkit_glue::String16ToString(error_message), line_number, webkit_glue::String16ToString(source_url)); @@ -122,7 +127,7 @@ void WebWorkerClientImpl::PostConsoleMessageToWorkerObject( const string16& message, int line_number, const string16& source_url) { - worker_->scriptExecutionContext()->addMessage( + script_execution_context_->addMessage( static_cast<WebCore::MessageDestination>(destination), static_cast<WebCore::MessageSource>(source), static_cast<WebCore::MessageLevel>(level), @@ -140,7 +145,6 @@ void WebWorkerClientImpl::ReportPendingActivity(bool has_pending_activity) { } void WebWorkerClientImpl::WorkerContextDestroyed() { - delete this; } #endif |