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