diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 20:37:26 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 20:37:26 +0000 |
commit | 57faa082d2daf0fe9f474dcbcc6199d42e8bf3d3 (patch) | |
tree | a9ba6ccb2e7fcb71f9b6e4caadb5f8fa8e382c3c /chrome | |
parent | 2b966e88039084ef87b273cb0dfeb60c8dab4d4c (diff) | |
download | chromium_src-57faa082d2daf0fe9f474dcbcc6199d42e8bf3d3.zip chromium_src-57faa082d2daf0fe9f474dcbcc6199d42e8bf3d3.tar.gz chromium_src-57faa082d2daf0fe9f474dcbcc6199d42e8bf3d3.tar.bz2 |
Queue up connect messages while waiting for the shared worker to start.
BUG=37100
TEST=added new ui test
Review URL: http://codereview.chromium.org/1047006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/worker/websharedworker_stub.cc | 24 | ||||
-rw-r--r-- | chrome/worker/websharedworker_stub.h | 4 | ||||
-rw-r--r-- | chrome/worker/worker_uitest.cc | 4 |
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 |