diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 01:13:37 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 01:13:37 +0000 |
commit | 30447b6a5d6109d455f2c6262454105d5adf8f94 (patch) | |
tree | 3ef69964f7cf3e10d662af94f88e05288e16ad8c /chrome/worker | |
parent | 6eca5f19ffabd672349df42595551e7a4b1da987 (diff) | |
download | chromium_src-30447b6a5d6109d455f2c6262454105d5adf8f94.zip chromium_src-30447b6a5d6109d455f2c6262454105d5adf8f94.tar.gz chromium_src-30447b6a5d6109d455f2c6262454105d5adf8f94.tar.bz2 |
Added lifecycle management and sharing support for SharedWorkers. SharedWorkers
can now outlive their parent pages and can be shared by multiple instances
across multiple tabs.
BUG=26233
TEST=ui tests
Review URL: http://codereview.chromium.org/390017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker')
-rw-r--r-- | chrome/worker/websharedworker_stub.cc | 10 | ||||
-rw-r--r-- | chrome/worker/websharedworker_stub.h | 1 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.cc | 3 | ||||
-rw-r--r-- | chrome/worker/worker_uitest.cc | 14 |
4 files changed, 18 insertions, 10 deletions
diff --git a/chrome/worker/websharedworker_stub.cc b/chrome/worker/websharedworker_stub.cc index 3c7aa3e..7c9646e 100644 --- a/chrome/worker/websharedworker_stub.cc +++ b/chrome/worker/websharedworker_stub.cc @@ -13,7 +13,8 @@ WebSharedWorkerStub::WebSharedWorkerStub( const string16& name, int route_id) : WebWorkerStubBase(route_id), - name_(name) { + name_(name), + started_(false) { // TODO(atwilson): Add support for NaCl when they support MessagePorts. impl_ = WebKit::WebSharedWorker::create(client()); @@ -35,10 +36,16 @@ void WebSharedWorkerStub::OnMessageReceived(const IPC::Message& message) { void WebSharedWorkerStub::OnStartWorkerContext( const GURL& url, const string16& user_agent, const string16& source_code) { + // Ignore multiple attempts to start this worker (can happen if two pages + // try to start it simultaneously). + if (started_) + return; impl_->startWorkerContext(url, name_, user_agent, source_code); + started_ = true; } void WebSharedWorkerStub::OnConnect(int sent_message_port_id, int routing_id) { + DCHECK(started_); WebKit::WebMessagePortChannel* channel = new WebMessagePortChannelImpl(routing_id, sent_message_port_id); impl_->connect(channel, NULL); @@ -49,4 +56,5 @@ void WebSharedWorkerStub::OnTerminateWorkerContext() { // Call the client to make sure context exits. EnsureWorkerContextTerminates(); + started_ = false; } diff --git a/chrome/worker/websharedworker_stub.h b/chrome/worker/websharedworker_stub.h index f7a26f3..426aaad 100644 --- a/chrome/worker/websharedworker_stub.h +++ b/chrome/worker/websharedworker_stub.h @@ -33,6 +33,7 @@ class WebSharedWorkerStub : public WebWorkerStubBase { WebKit::WebSharedWorker* impl_; string16 name_; + bool started_; DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub); }; diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index 8519c23..6ba589f 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -92,8 +92,7 @@ void WebWorkerClientProxy::reportPendingActivity(bool has_pending_activity) { } void WebWorkerClientProxy::workerContextClosed() { - // TODO(atwilson): Notify WorkerProcessHost that the worker context is closing - // (needed for shared workers so we don't allow new connections). + Send(new WorkerHostMsg_WorkerContextClosed(route_id_)); } void WebWorkerClientProxy::workerContextDestroyed() { diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc index 793f889..7b46995 100644 --- a/chrome/worker/worker_uitest.cc +++ b/chrome/worker/worker_uitest.cc @@ -116,25 +116,25 @@ TEST_F(WorkerTest, WorkerFastLayoutTests) { RunLayoutTest(kLayoutTestFiles[i], false); } -TEST_F(WorkerTest, SharedWorkerFastLayoutTests) { +TEST_F(WorkerTest, DISABLED_SharedWorkerFastLayoutTests) { static const char* kLayoutTestFiles[] = { "shared-worker-constructor.html", - // Enable remaining SharedWorker tests when functionality is - // complete (http://crbug.com/26899) "shared-worker-context-gc.html", "shared-worker-event-listener.html", - //"shared-worker-exception.html", - //"shared-worker-frame-lifecycle.html", + "shared-worker-exception.html", "shared-worker-gc.html", + // Lifecycle tests rely on layoutTestController.workerThreadCount which is + // not currently implemented. + //"shared-worker-frame-lifecycle.html", //"shared-worker-lifecycle.html", "shared-worker-load-error.html", "shared-worker-location.html", - //"shared-worker-name.html", + "shared-worker-name.html", "shared-worker-navigator.html", "shared-worker-replace-global-constructor.html", "shared-worker-replace-self.html", "shared-worker-script-error.html", - //"shared-worker-shared.html", + "shared-worker-shared.html", "shared-worker-simple.html", }; |