summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webworkerclient_impl.cc
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 22:06:43 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 22:06:43 +0000
commitd9056166ac600fd4c261d81a9da1f5ba855e6bd8 (patch)
tree148e4e04c47a1c0b65dbd3f022040259e85acfb9 /webkit/glue/webworkerclient_impl.cc
parent1a616d92fc1bdafcceda50939e6a5b72f4885a98 (diff)
downloadchromium_src-d9056166ac600fd4c261d81a9da1f5ba855e6bd8.zip
chromium_src-d9056166ac600fd4c261d81a9da1f5ba855e6bd8.tar.gz
chromium_src-d9056166ac600fd4c261d81a9da1f5ba855e6bd8.tar.bz2
Hook up WebKit worker with Chromium.
Review URL: http://codereview.chromium.org/39147 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webworkerclient_impl.cc')
-rw-r--r--webkit/glue/webworkerclient_impl.cc32
1 files changed, 25 insertions, 7 deletions
diff --git a/webkit/glue/webworkerclient_impl.cc b/webkit/glue/webworkerclient_impl.cc
index d140681..c75bff4 100644
--- a/webkit/glue/webworkerclient_impl.cc
+++ b/webkit/glue/webworkerclient_impl.cc
@@ -55,7 +55,10 @@ WebCore::WorkerContextProxy* WebCore::WorkerContextProxy::create(
WebWorkerClientImpl::WebWorkerClientImpl(WebCore::Worker* worker)
- : worker_(worker) {
+ : worker_(worker),
+ asked_to_terminate_(false),
+ unconfirmed_message_count_(0),
+ worker_context_had_pending_activity_(false) {
}
WebWorkerClientImpl::~WebWorkerClientImpl() {
@@ -75,20 +78,23 @@ void WebWorkerClientImpl::startWorkerContext(
}
void WebWorkerClientImpl::terminateWorkerContext() {
+ if (asked_to_terminate_)
+ return;
+ asked_to_terminate_ = true;
+
webworker_->TerminateWorkerContext();
}
void WebWorkerClientImpl::postMessageToWorkerContext(
const WebCore::String& message) {
+ ++unconfirmed_message_count_;
webworker_->PostMessageToWorkerContext(
webkit_glue::StringToString16(message));
}
bool WebWorkerClientImpl::hasPendingActivity() const {
- // TODO(jianli): we should use the same logic from WorkerMessagingProxy
- // here, so that we don't do a synchronous IPC.
- // Until then, always return true.
- return true;
+ return !asked_to_terminate_ &&
+ (unconfirmed_message_count_ || worker_context_had_pending_activity_);
}
void WebWorkerClientImpl::workerObjectDestroyed() {
@@ -96,14 +102,17 @@ void WebWorkerClientImpl::workerObjectDestroyed() {
}
void WebWorkerClientImpl::PostMessageToWorkerObject(const string16& message) {
- // TODO(jianli): this method, and the ones below, need to implement
- // WorkerObjectProxy.
+ worker_->dispatchMessage(webkit_glue::String16ToString(message));
}
void WebWorkerClientImpl::PostExceptionToWorkerObject(
const string16& error_message,
int line_number,
const string16& source_url) {
+ worker_->scriptExecutionContext()->reportException(
+ webkit_glue::String16ToString(error_message),
+ line_number,
+ webkit_glue::String16ToString(source_url));
}
void WebWorkerClientImpl::PostConsoleMessageToWorkerObject(
@@ -113,12 +122,21 @@ void WebWorkerClientImpl::PostConsoleMessageToWorkerObject(
const string16& message,
int line_number,
const string16& source_url) {
+ worker_->scriptExecutionContext()->addMessage(
+ static_cast<WebCore::MessageDestination>(destination),
+ static_cast<WebCore::MessageSource>(source),
+ static_cast<WebCore::MessageLevel>(level),
+ webkit_glue::String16ToString(message),
+ line_number,
+ webkit_glue::String16ToString(source_url));
}
void WebWorkerClientImpl::ConfirmMessageFromWorkerObject(bool has_pending_activity) {
+ --unconfirmed_message_count_;
}
void WebWorkerClientImpl::ReportPendingActivity(bool has_pending_activity) {
+ worker_context_had_pending_activity_ = has_pending_activity;
}
void WebWorkerClientImpl::WorkerContextDestroyed() {