| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/public/browser/service_worker_context.h" | 5 #include "content/public/browser/service_worker_context.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) { | 525 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) { |
| 526 const int kRenderProcessId1 = 1; | 526 const int kRenderProcessId1 = 1; |
| 527 const int kRenderProcessId2 = 2; | 527 const int kRenderProcessId2 = 2; |
| 528 const GURL kOrigin1 = GURL("http://www.example.com/"); | 528 const GURL kOrigin1 = GURL("http://www.example.com/"); |
| 529 const GURL kOrigin2 = GURL("https://www.example.com/"); | 529 const GURL kOrigin2 = GURL("https://www.example.com/"); |
| 530 int provider_id = 1; | 530 int provider_id = 1; |
| 531 | 531 |
| 532 // Host1 (provider_id=1): process_id=1, origin1. | 532 // Host1 (provider_id=1): process_id=1, origin1. |
| 533 ServiceWorkerProviderHost* host1(new ServiceWorkerProviderHost( | 533 ServiceWorkerProviderHost* host1(new ServiceWorkerProviderHost( |
| 534 kRenderProcessId1, MSG_ROUTING_NONE, provider_id++, | 534 kRenderProcessId1, MSG_ROUTING_NONE, provider_id++, |
| 535 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); | 535 SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
| 536 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, |
| 537 context()->AsWeakPtr(), nullptr)); |
| 536 host1->SetDocumentUrl(kOrigin1); | 538 host1->SetDocumentUrl(kOrigin1); |
| 537 | 539 |
| 538 // Host2 (provider_id=2): process_id=2, origin2. | 540 // Host2 (provider_id=2): process_id=2, origin2. |
| 539 ServiceWorkerProviderHost* host2(new ServiceWorkerProviderHost( | 541 ServiceWorkerProviderHost* host2(new ServiceWorkerProviderHost( |
| 540 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, | 542 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, |
| 541 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); | 543 SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
| 544 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, |
| 545 context()->AsWeakPtr(), nullptr)); |
| 542 host2->SetDocumentUrl(kOrigin2); | 546 host2->SetDocumentUrl(kOrigin2); |
| 543 | 547 |
| 544 // Host3 (provider_id=3): process_id=2, origin1. | 548 // Host3 (provider_id=3): process_id=2, origin1. |
| 545 ServiceWorkerProviderHost* host3(new ServiceWorkerProviderHost( | 549 ServiceWorkerProviderHost* host3(new ServiceWorkerProviderHost( |
| 546 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, | 550 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, |
| 547 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); | 551 SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
| 552 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, |
| 553 context()->AsWeakPtr(), nullptr)); |
| 548 host3->SetDocumentUrl(kOrigin1); | 554 host3->SetDocumentUrl(kOrigin1); |
| 549 | 555 |
| 550 // Host4 (provider_id=4): process_id=2, origin2, for ServiceWorker. | 556 // Host4 (provider_id=4): process_id=2, origin2, for ServiceWorker. |
| 551 ServiceWorkerProviderHost* host4(new ServiceWorkerProviderHost( | 557 ServiceWorkerProviderHost* host4(new ServiceWorkerProviderHost( |
| 552 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, | 558 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, |
| 553 SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, context()->AsWeakPtr(), nullptr)); | 559 SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, |
| 560 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, |
| 561 context()->AsWeakPtr(), nullptr)); |
| 554 host4->SetDocumentUrl(kOrigin2); | 562 host4->SetDocumentUrl(kOrigin2); |
| 555 | 563 |
| 556 context()->AddProviderHost(base::WrapUnique(host1)); | 564 context()->AddProviderHost(base::WrapUnique(host1)); |
| 557 context()->AddProviderHost(base::WrapUnique(host2)); | 565 context()->AddProviderHost(base::WrapUnique(host2)); |
| 558 context()->AddProviderHost(base::WrapUnique(host3)); | 566 context()->AddProviderHost(base::WrapUnique(host3)); |
| 559 context()->AddProviderHost(base::WrapUnique(host4)); | 567 context()->AddProviderHost(base::WrapUnique(host4)); |
| 560 | 568 |
| 561 // Iterate over all provider hosts. | 569 // Iterate over all provider hosts. |
| 562 std::set<ServiceWorkerProviderHost*> results; | 570 std::set<ServiceWorkerProviderHost*> results; |
| 563 for (auto it = context()->GetProviderHostIterator(); !it->IsAtEnd(); | 571 for (auto it = context()->GetProviderHostIterator(); !it->IsAtEnd(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 EXPECT_EQ(pattern, notifications_[0].pattern); | 704 EXPECT_EQ(pattern, notifications_[0].pattern); |
| 697 EXPECT_EQ(registration_id, notifications_[0].registration_id); | 705 EXPECT_EQ(registration_id, notifications_[0].registration_id); |
| 698 EXPECT_EQ(STORAGE_RECOVERED, notifications_[1].type); | 706 EXPECT_EQ(STORAGE_RECOVERED, notifications_[1].type); |
| 699 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); | 707 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); |
| 700 EXPECT_EQ(pattern, notifications_[2].pattern); | 708 EXPECT_EQ(pattern, notifications_[2].pattern); |
| 701 EXPECT_EQ(registration_id, notifications_[2].registration_id); | 709 EXPECT_EQ(registration_id, notifications_[2].registration_id); |
| 702 } | 710 } |
| 703 | 711 |
| 704 | 712 |
| 705 } // namespace content | 713 } // namespace content |
| OLD | NEW |