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