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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "content/browser/message_port_service.h" | 7 #include "content/browser/message_port_service.h" |
8 #include "content/browser/service_worker/embedded_worker_registry.h" | 8 #include "content/browser/service_worker/embedded_worker_registry.h" |
9 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 9 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 void SetUp() override { | 151 void SetUp() override { |
152 helper_ = GetMessageReceiver(); | 152 helper_ = GetMessageReceiver(); |
153 | 153 |
154 pattern_ = GURL("http://www.example.com/"); | 154 pattern_ = GURL("http://www.example.com/"); |
155 registration_ = new ServiceWorkerRegistration( | 155 registration_ = new ServiceWorkerRegistration( |
156 pattern_, | 156 pattern_, |
157 1L, | 157 1L, |
158 helper_->context()->AsWeakPtr()); | 158 helper_->context()->AsWeakPtr()); |
159 version_ = new ServiceWorkerVersion( | 159 version_ = new ServiceWorkerVersion( |
160 registration_.get(), | 160 registration_.get(), GURL("http://www.example.com/service_worker.js"), |
161 GURL("http://www.example.com/service_worker.js"), | 161 std::string("2d73e817-7136-4133-8d59-84105fe5417a"), |
162 1L, | |
163 helper_->context()->AsWeakPtr()); | 162 helper_->context()->AsWeakPtr()); |
164 std::vector<ServiceWorkerDatabase::ResourceRecord> records; | 163 std::vector<ServiceWorkerDatabase::ResourceRecord> records; |
165 records.push_back( | 164 records.push_back( |
166 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); | 165 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); |
167 version_->script_cache_map()->SetResources(records); | 166 version_->script_cache_map()->SetResources(records); |
168 | 167 |
169 // Make the registration findable via storage functions. | 168 // Make the registration findable via storage functions. |
170 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 169 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
171 base::RunLoop().RunUntilIdle(); | 170 base::RunLoop().RunUntilIdle(); |
172 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 171 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
(...skipping 30 matching lines...) Expand all Loading... |
203 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersionTest); | 202 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersionTest); |
204 }; | 203 }; |
205 | 204 |
206 class MessageReceiverDisallowStart : public MessageReceiver { | 205 class MessageReceiverDisallowStart : public MessageReceiver { |
207 public: | 206 public: |
208 MessageReceiverDisallowStart() | 207 MessageReceiverDisallowStart() |
209 : MessageReceiver() {} | 208 : MessageReceiver() {} |
210 ~MessageReceiverDisallowStart() override {} | 209 ~MessageReceiverDisallowStart() override {} |
211 | 210 |
212 void OnStartWorker(int embedded_worker_id, | 211 void OnStartWorker(int embedded_worker_id, |
213 int64 service_worker_version_id, | 212 std::string service_worker_version_uuid, |
214 const GURL& scope, | 213 const GURL& scope, |
215 const GURL& script_url, | 214 const GURL& script_url, |
216 bool pause_after_download) override { | 215 bool pause_after_download) override { |
217 // Do nothing. | 216 // Do nothing. |
218 } | 217 } |
219 | 218 |
220 private: | 219 private: |
221 DISALLOW_COPY_AND_ASSIGN(MessageReceiverDisallowStart); | 220 DISALLOW_COPY_AND_ASSIGN(MessageReceiverDisallowStart); |
222 }; | 221 }; |
223 | 222 |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 base::TimeTicks::Now() - | 741 base::TimeTicks::Now() - |
743 base::TimeDelta::FromMinutes( | 742 base::TimeDelta::FromMinutes( |
744 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1); | 743 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1); |
745 version_->timeout_timer_.user_task().Run(); | 744 version_->timeout_timer_.user_task().Run(); |
746 base::RunLoop().RunUntilIdle(); | 745 base::RunLoop().RunUntilIdle(); |
747 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); | 746 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); |
748 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); | 747 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); |
749 } | 748 } |
750 | 749 |
751 } // namespace content | 750 } // namespace content |
OLD | NEW |