Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: webkit/glue/webworkerclient_impl.cc

Issue 263005: Webkit roll: 49213:49221 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webworkerclient_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (!WTF::isMainThread()) { 147 if (!WTF::isMainThread()) {
148 WebWorkerImpl::DispatchTaskToMainThread( 148 WebWorkerImpl::DispatchTaskToMainThread(
149 WebCore::createCallbackTask(&TerminateWorkerContextTask, this)); 149 WebCore::createCallbackTask(&TerminateWorkerContextTask, this));
150 return; 150 return;
151 } 151 }
152 152
153 webworker_->terminateWorkerContext(); 153 webworker_->terminateWorkerContext();
154 } 154 }
155 155
156 void WebWorkerClientImpl::postMessageToWorkerContext( 156 void WebWorkerClientImpl::postMessageToWorkerContext(
157 const WebCore::String& message, 157 WTF::PassRefPtr<WebCore::SerializedScriptValue> message,
158 WTF::PassOwnPtr<WebCore::MessagePortChannelArray> channels) { 158 WTF::PassOwnPtr<WebCore::MessagePortChannelArray> channels) {
159 // Worker.terminate() could be called from JS before the context is started. 159 // Worker.terminate() could be called from JS before the context is started.
160 if (asked_to_terminate_) 160 if (asked_to_terminate_)
161 return; 161 return;
162 162
163 ++unconfirmed_message_count_; 163 ++unconfirmed_message_count_;
164 164
165 if (!WTF::isMainThread()) { 165 if (!WTF::isMainThread()) {
166 WebWorkerImpl::DispatchTaskToMainThread( 166 WebWorkerImpl::DispatchTaskToMainThread(
167 WebCore::createCallbackTask( 167 WebCore::createCallbackTask(
168 &PostMessageToWorkerContextTask, this, message, channels)); 168 &PostMessageToWorkerContextTask, this, message->toString(), channels ));
Dmitry Titov 2009/10/07 04:06:51 80
169 return; 169 return;
170 } 170 }
171 171
172 WebMessagePortChannelArray webchannels(channels.get() ? channels->size() : 0); 172 WebMessagePortChannelArray webchannels(channels.get() ? channels->size() : 0);
173 173
174 for (size_t i = 0; i < webchannels.size(); ++i) { 174 for (size_t i = 0; i < webchannels.size(); ++i) {
175 WebMessagePortChannel* webchannel = 175 WebMessagePortChannel* webchannel =
176 (*channels)[i]->channel()->webChannelRelease(); 176 (*channels)[i]->channel()->webChannelRelease();
177 webchannel->setClient(0); 177 webchannel->setClient(0);
178 webchannels[i] = webchannel; 178 webchannels[i] = webchannel;
179 } 179 }
180 180
181 webworker_->postMessageToWorkerContext( 181 webworker_->postMessageToWorkerContext(
182 webkit_glue::StringToWebString(message), webchannels); 182 webkit_glue::StringToWebString(message->toString()), webchannels);
183 } 183 }
184 184
185 bool WebWorkerClientImpl::hasPendingActivity() const { 185 bool WebWorkerClientImpl::hasPendingActivity() const {
186 return !asked_to_terminate_ && 186 return !asked_to_terminate_ &&
187 (unconfirmed_message_count_ || worker_context_had_pending_activity_); 187 (unconfirmed_message_count_ || worker_context_had_pending_activity_);
188 } 188 }
189 189
190 void WebWorkerClientImpl::workerObjectDestroyed() { 190 void WebWorkerClientImpl::workerObjectDestroyed() {
191 if (WTF::isMainThread()) { 191 if (WTF::isMainThread()) {
192 webworker_->workerObjectDestroyed(); 192 webworker_->workerObjectDestroyed();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 void WebWorkerClientImpl::PostMessageToWorkerObjectTask( 343 void WebWorkerClientImpl::PostMessageToWorkerObjectTask(
344 WebCore::ScriptExecutionContext* context, 344 WebCore::ScriptExecutionContext* context,
345 WebWorkerClientImpl* this_ptr, 345 WebWorkerClientImpl* this_ptr,
346 const WebCore::String& message, 346 const WebCore::String& message,
347 WTF::PassOwnPtr<WebCore::MessagePortChannelArray> channels) { 347 WTF::PassOwnPtr<WebCore::MessagePortChannelArray> channels) {
348 348
349 if (this_ptr->worker_) { 349 if (this_ptr->worker_) {
350 WTF::OwnPtr<WebCore::MessagePortArray> ports = 350 WTF::OwnPtr<WebCore::MessagePortArray> ports =
351 WebCore::MessagePort::entanglePorts(*context, channels.release()); 351 WebCore::MessagePort::entanglePorts(*context, channels.release());
352 WTF::RefPtr<WebCore::SerializedScriptValue> serialized_message =
353 WebCore::SerializedScriptValue::create(message);
352 this_ptr->worker_->dispatchEvent( 354 this_ptr->worker_->dispatchEvent(
353 WebCore::MessageEvent::create(ports.release(), message)); 355 WebCore::MessageEvent::create(ports.release(), serialized_message.releas e()));
Dmitry Titov 2009/10/07 04:06:51 80
354 } 356 }
355 } 357 }
356 358
357 void WebWorkerClientImpl::PostExceptionToWorkerObjectTask( 359 void WebWorkerClientImpl::PostExceptionToWorkerObjectTask(
358 WebCore::ScriptExecutionContext* context, 360 WebCore::ScriptExecutionContext* context,
359 WebWorkerClientImpl* this_ptr, 361 WebWorkerClientImpl* this_ptr,
360 const WebCore::String& error_message, 362 const WebCore::String& error_message,
361 int line_number, 363 int line_number,
362 const WebCore::String& source_url) { 364 const WebCore::String& source_url) {
363 bool handled = false; 365 bool handled = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 398 }
397 399
398 void WebWorkerClientImpl::ReportPendingActivityTask( 400 void WebWorkerClientImpl::ReportPendingActivityTask(
399 WebCore::ScriptExecutionContext* context, 401 WebCore::ScriptExecutionContext* context,
400 WebWorkerClientImpl* this_ptr, 402 WebWorkerClientImpl* this_ptr,
401 bool has_pending_activity) { 403 bool has_pending_activity) {
402 this_ptr->worker_context_had_pending_activity_ = has_pending_activity; 404 this_ptr->worker_context_had_pending_activity_ = has_pending_activity;
403 } 405 }
404 406
405 #endif 407 #endif
OLDNEW
« no previous file with comments | « webkit/glue/webworkerclient_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698