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 "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) { | 617 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) { |
618 const int kRenderProcessId1 = 1; | 618 const int kRenderProcessId1 = 1; |
619 const int kRenderProcessId2 = 2; | 619 const int kRenderProcessId2 = 2; |
620 const GURL kOrigin1 = GURL("http://www.example.com/"); | 620 const GURL kOrigin1 = GURL("http://www.example.com/"); |
621 const GURL kOrigin2 = GURL("https://www.example.com/"); | 621 const GURL kOrigin2 = GURL("https://www.example.com/"); |
622 int provider_id = 1; | 622 int provider_id = 1; |
623 | 623 |
624 // Host1 (provider_id=1): process_id=1, origin1. | 624 // Host1 (provider_id=1): process_id=1, origin1. |
625 ServiceWorkerProviderHost* host1(new ServiceWorkerProviderHost( | 625 ServiceWorkerProviderHost* host1(new ServiceWorkerProviderHost( |
626 kRenderProcessId1, MSG_ROUTING_NONE, provider_id++, | 626 kRenderProcessId1, MSG_ROUTING_NONE, provider_id++, |
627 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, context()->AsWeakPtr(), nullptr)); | 627 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); |
628 host1->SetDocumentUrl(kOrigin1); | 628 host1->SetDocumentUrl(kOrigin1); |
629 | 629 |
630 // Host2 (provider_id=2): process_id=2, origin2. | 630 // Host2 (provider_id=2): process_id=2, origin2. |
631 ServiceWorkerProviderHost* host2(new ServiceWorkerProviderHost( | 631 ServiceWorkerProviderHost* host2(new ServiceWorkerProviderHost( |
632 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, | 632 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, |
633 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, context()->AsWeakPtr(), nullptr)); | 633 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); |
634 host2->SetDocumentUrl(kOrigin2); | 634 host2->SetDocumentUrl(kOrigin2); |
635 | 635 |
636 // Host3 (provider_id=3): process_id=2, origin1. | 636 // Host3 (provider_id=3): process_id=2, origin1. |
637 ServiceWorkerProviderHost* host3(new ServiceWorkerProviderHost( | 637 ServiceWorkerProviderHost* host3(new ServiceWorkerProviderHost( |
638 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, | 638 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, |
639 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, context()->AsWeakPtr(), nullptr)); | 639 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); |
640 host3->SetDocumentUrl(kOrigin1); | 640 host3->SetDocumentUrl(kOrigin1); |
641 | 641 |
642 // Host4 (provider_id=4): process_id=2, origin2, for ServiceWorker. | 642 // Host4 (provider_id=4): process_id=2, origin2, for ServiceWorker. |
643 ServiceWorkerProviderHost* host4(new ServiceWorkerProviderHost( | 643 ServiceWorkerProviderHost* host4(new ServiceWorkerProviderHost( |
644 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, | 644 kRenderProcessId2, MSG_ROUTING_NONE, provider_id++, |
645 SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, context()->AsWeakPtr(), nullptr)); | 645 SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, context()->AsWeakPtr(), nullptr)); |
646 host4->SetDocumentUrl(kOrigin2); | 646 host4->SetDocumentUrl(kOrigin2); |
647 | 647 |
648 context()->AddProviderHost(make_scoped_ptr(host1)); | 648 context()->AddProviderHost(make_scoped_ptr(host1)); |
649 context()->AddProviderHost(make_scoped_ptr(host2)); | 649 context()->AddProviderHost(make_scoped_ptr(host2)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 EXPECT_EQ(1u, results.size()); | 682 EXPECT_EQ(1u, results.size()); |
683 EXPECT_TRUE(ContainsKey(results, host2)); | 683 EXPECT_TRUE(ContainsKey(results, host2)); |
684 | 684 |
685 context()->RemoveProviderHost(kRenderProcessId1, 1); | 685 context()->RemoveProviderHost(kRenderProcessId1, 1); |
686 context()->RemoveProviderHost(kRenderProcessId2, 2); | 686 context()->RemoveProviderHost(kRenderProcessId2, 2); |
687 context()->RemoveProviderHost(kRenderProcessId2, 3); | 687 context()->RemoveProviderHost(kRenderProcessId2, 3); |
688 context()->RemoveProviderHost(kRenderProcessId2, 4); | 688 context()->RemoveProviderHost(kRenderProcessId2, 4); |
689 } | 689 } |
690 | 690 |
691 } // namespace content | 691 } // namespace content |
OLD | NEW |