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 "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <tuple> | 8 #include <tuple> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersionTest); | 285 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersionTest); |
286 }; | 286 }; |
287 | 287 |
288 class MessageReceiverDisallowStart : public MessageReceiver { | 288 class MessageReceiverDisallowStart : public MessageReceiver { |
289 public: | 289 public: |
290 MessageReceiverDisallowStart() : MessageReceiver() {} | 290 MessageReceiverDisallowStart() : MessageReceiver() {} |
291 ~MessageReceiverDisallowStart() override {} | 291 ~MessageReceiverDisallowStart() override {} |
292 | 292 |
293 enum class StartMode { STALL, FAIL, SUCCEED }; | 293 enum class StartMode { STALL, FAIL, SUCCEED }; |
294 | 294 |
295 void OnStartWorker( | 295 void OnStartWorker(int embedded_worker_id, |
296 int embedded_worker_id, | 296 int64_t service_worker_version_id, |
297 int64_t service_worker_version_id, | 297 const GURL& scope, |
298 const GURL& scope, | 298 const GURL& script_url, |
299 const GURL& script_url, | 299 bool pause_after_download, |
300 bool pause_after_download, | 300 mojom::ServiceWorkerEventDispatcherRequest request, |
301 mojom::ServiceWorkerEventDispatcherRequest request) override { | 301 mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo |
| 302 instance_host) override { |
302 switch (mode_) { | 303 switch (mode_) { |
303 case StartMode::STALL: | 304 case StartMode::STALL: |
304 break; // Do nothing. | 305 break; // Do nothing. |
305 case StartMode::FAIL: | 306 case StartMode::FAIL: |
306 ASSERT_EQ(current_mock_instance_index_ + 1, | 307 ASSERT_EQ(current_mock_instance_index_ + 1, |
307 mock_instance_clients()->size()); | 308 mock_instance_clients()->size()); |
308 // Remove the connection by peer | 309 // Remove the connection by peer |
309 mock_instance_clients()->at(current_mock_instance_index_).reset(); | 310 mock_instance_clients()->at(current_mock_instance_index_).reset(); |
310 break; | 311 break; |
311 case StartMode::SUCCEED: | 312 case StartMode::SUCCEED: |
312 MessageReceiver::OnStartWorker( | 313 MessageReceiver::OnStartWorker( |
313 embedded_worker_id, service_worker_version_id, scope, script_url, | 314 embedded_worker_id, service_worker_version_id, scope, script_url, |
314 pause_after_download, std::move(request)); | 315 pause_after_download, std::move(request), std::move(instance_host)); |
315 break; | 316 break; |
316 } | 317 } |
317 current_mock_instance_index_++; | 318 current_mock_instance_index_++; |
318 } | 319 } |
319 | 320 |
320 void set_start_mode(StartMode mode) { mode_ = mode; } | 321 void set_start_mode(StartMode mode) { mode_ = mode; } |
321 | 322 |
322 private: | 323 private: |
323 uint32_t current_mock_instance_index_ = 0; | 324 uint32_t current_mock_instance_index_ = 0; |
324 StartMode mode_ = StartMode::STALL; | 325 StartMode mode_ = StartMode::STALL; |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 // Should not have timed out, so error callback should not have been | 1606 // Should not have timed out, so error callback should not have been |
1606 // called and FinishRequest should return true. | 1607 // called and FinishRequest should return true. |
1607 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1608 EXPECT_EQ(SERVICE_WORKER_OK, status); |
1608 EXPECT_TRUE(version_->FinishRequest(request_id1, true /* was_handled */, | 1609 EXPECT_TRUE(version_->FinishRequest(request_id1, true /* was_handled */, |
1609 base::Time::Now())); | 1610 base::Time::Now())); |
1610 EXPECT_TRUE(version_->FinishRequest(request_id2, true /* was_handled */, | 1611 EXPECT_TRUE(version_->FinishRequest(request_id2, true /* was_handled */, |
1611 base::Time::Now())); | 1612 base::Time::Now())); |
1612 } | 1613 } |
1613 | 1614 |
1614 } // namespace content | 1615 } // namespace content |
OLD | NEW |