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

Unified Diff: chrome/worker/websharedworker_stub.cc

Issue 390017: Added lifecycle management and sharing support for SharedWorkers. SharedWorkers (Closed)
Patch Set: Changed WebWorkerBase not not call a virtual function from the destructor Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/worker/websharedworker_stub.cc
diff --git a/chrome/worker/websharedworker_stub.cc b/chrome/worker/websharedworker_stub.cc
index 3c7aa3e0460ec8c5292ffc1ecd17cc6bdaaf626d..7c9646e76a8ad628cde76e774073bc8d1209784b 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;
}

Powered by Google App Engine
This is Rietveld 408576698