summaryrefslogtreecommitdiffstats
path: root/chrome/worker
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/worker')
-rw-r--r--chrome/worker/websharedworker_stub.cc24
-rw-r--r--chrome/worker/websharedworker_stub.h4
-rw-r--r--chrome/worker/worker_uitest.cc4
3 files changed, 28 insertions, 4 deletions
diff --git a/chrome/worker/websharedworker_stub.cc b/chrome/worker/websharedworker_stub.cc
index 232f842..f398244 100644
--- a/chrome/worker/websharedworker_stub.cc
+++ b/chrome/worker/websharedworker_stub.cc
@@ -46,13 +46,29 @@ void WebSharedWorkerStub::OnStartWorkerContext(
return;
impl_->startWorkerContext(url, name_, user_agent, source_code);
started_ = true;
+
+ // Process any pending connections.
+ for (PendingConnectInfoList::const_iterator iter = pending_connects_.begin();
+ iter != pending_connects_.end();
+ ++iter) {
+ OnConnect(iter->first, iter->second);
+ }
+ pending_connects_.clear();
}
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);
+ if (started_) {
+ WebKit::WebMessagePortChannel* channel =
+ new WebMessagePortChannelImpl(routing_id, sent_message_port_id);
+ impl_->connect(channel, NULL);
+ } else {
+ // If two documents try to load a SharedWorker at the same time, the
+ // WorkerMsg_Connect for one of the documents can come in before the
+ // worker is started. Just queue up the connect and deliver it once the
+ // worker starts.
+ PendingConnectInfo pending_connect(sent_message_port_id, routing_id);
+ pending_connects_.push_back(pending_connect);
+ }
}
void WebSharedWorkerStub::OnTerminateWorkerContext() {
diff --git a/chrome/worker/websharedworker_stub.h b/chrome/worker/websharedworker_stub.h
index 37ab640..ad5a547 100644
--- a/chrome/worker/websharedworker_stub.h
+++ b/chrome/worker/websharedworker_stub.h
@@ -36,6 +36,10 @@ class WebSharedWorkerStub : public WebWorkerStubBase {
string16 name_;
bool started_;
+ typedef std::pair<int, int> PendingConnectInfo;
+ typedef std::vector<PendingConnectInfo> PendingConnectInfoList;
+ PendingConnectInfoList pending_connects_;
+
DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub);
};
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc
index 775eb94..297dcc1 100644
--- a/chrome/worker/worker_uitest.cc
+++ b/chrome/worker/worker_uitest.cc
@@ -283,6 +283,10 @@ TEST_F(WorkerTest, WorkerTimeout) {
RunWorkerFastLayoutTest("worker-timeout.html");
}
+TEST_F(WorkerTest, SharedWorkerInIframe) {
+ RunWorkerFastLayoutTest("shared-worker-in-iframe.html");
+}
+
// http://crbug.com/27636 - incorrect URL_MISMATCH exceptions sometimes get
// generated on the windows try bots. FLAKY on Win.
// http://crbug.com/28445 - flakiness on mac