OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "content/browser/service_worker/embedded_worker_instance.h" | 9 #include "content/browser/service_worker/embedded_worker_instance.h" |
10 #include "content/browser/service_worker/embedded_worker_registry.h" | 10 #include "content/browser/service_worker/embedded_worker_registry.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 virtual void TearDownOnIOThread() OVERRIDE { | 148 virtual void TearDownOnIOThread() OVERRIDE { |
149 if (worker_) { | 149 if (worker_) { |
150 worker_->RemoveListener(this); | 150 worker_->RemoveListener(this); |
151 worker_.reset(); | 151 worker_.reset(); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 void StartOnIOThread() { | 155 void StartOnIOThread() { |
156 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 156 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
157 worker_ = wrapper()->context()->embedded_worker_registry()->CreateWorker(); | 157 const GURL scope = embedded_test_server()->GetURL("/*"); |
| 158 worker_ = |
| 159 wrapper()->context()->embedded_worker_registry()->CreateWorker(scope); |
158 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker_->status()); | 160 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker_->status()); |
159 worker_->AddListener(this); | 161 worker_->AddListener(this); |
160 | 162 |
161 AssociateRendererProcessToWorker(worker_.get()); | 163 AssociateRendererProcessToWorker(worker_.get()); |
162 | 164 |
163 const int64 service_worker_version_id = 33L; | 165 const int64 service_worker_version_id = 33L; |
164 const GURL scope = embedded_test_server()->GetURL("/*"); | |
165 const GURL script_url = embedded_test_server()->GetURL( | 166 const GURL script_url = embedded_test_server()->GetURL( |
166 "/service_worker/worker.js"); | 167 "/service_worker/worker.js"); |
167 std::vector<int> processes; | 168 std::vector<int> processes; |
168 processes.push_back( | 169 processes.push_back( |
169 shell()->web_contents()->GetRenderProcessHost()->GetID()); | 170 shell()->web_contents()->GetRenderProcessHost()->GetID()); |
170 worker_->Start( | 171 worker_->Start( |
171 service_worker_version_id, | 172 service_worker_version_id, |
172 scope, | |
173 script_url, | 173 script_url, |
174 processes, | 174 processes, |
175 base::Bind(&EmbeddedWorkerBrowserTest::StartOnIOThread2, this)); | 175 base::Bind(&EmbeddedWorkerBrowserTest::StartOnIOThread2, this)); |
176 } | 176 } |
177 void StartOnIOThread2(ServiceWorkerStatusCode status) { | 177 void StartOnIOThread2(ServiceWorkerStatusCode status) { |
178 last_worker_status_ = worker_->status(); | 178 last_worker_status_ = worker_->status(); |
179 EXPECT_EQ(SERVICE_WORKER_OK, status); | 179 EXPECT_EQ(SERVICE_WORKER_OK, status); |
180 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, last_worker_status_); | 180 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, last_worker_status_); |
181 | 181 |
182 if (status != SERVICE_WORKER_OK && !done_closure_.is_null()) | 182 if (status != SERVICE_WORKER_OK && !done_closure_.is_null()) |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, | 645 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, |
646 this, | 646 this, |
647 embedded_test_server()->GetURL("/service_worker/empty.html"), | 647 embedded_test_server()->GetURL("/service_worker/empty.html"), |
648 &status, | 648 &status, |
649 &script_url)); | 649 &script_url)); |
650 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); | 650 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 } // namespace content | 654 } // namespace content |
OLD | NEW |