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