Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: content/browser/service_worker/service_worker_context_unittest.cc

Issue 2653493009: Add two interfaces for ServiceWorkerProviderContext/ProviderHost (Closed)
Patch Set: Addressed comments from falken Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 EXPECT_EQ(pattern, notifications_[1].pattern); 576 EXPECT_EQ(pattern, notifications_[1].pattern);
577 EXPECT_EQ(old_registration_id, notifications_[1].registration_id); 577 EXPECT_EQ(old_registration_id, notifications_[1].registration_id);
578 } 578 }
579 579
580 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) { 580 TEST_F(ServiceWorkerContextTest, ProviderHostIterator) {
581 const int kRenderProcessId1 = 1; 581 const int kRenderProcessId1 = 1;
582 const int kRenderProcessId2 = 2; 582 const int kRenderProcessId2 = 2;
583 const GURL kOrigin1 = GURL("http://www.example.com/"); 583 const GURL kOrigin1 = GURL("http://www.example.com/");
584 const GURL kOrigin2 = GURL("https://www.example.com/"); 584 const GURL kOrigin2 = GURL("https://www.example.com/");
585 int provider_id = 1; 585 int provider_id = 1;
586 std::vector<ServiceWorkerRemoteProviderEndpoint> remote_endpoints;
586 587
587 // Host1 (provider_id=1): process_id=1, origin1. 588 // Host1 (provider_id=1): process_id=1, origin1.
589 remote_endpoints.emplace_back();
588 std::unique_ptr<ServiceWorkerProviderHost> host1 = 590 std::unique_ptr<ServiceWorkerProviderHost> host1 =
589 CreateProviderHostForWindow(kRenderProcessId1, provider_id++, 591 CreateProviderHostForWindow(
590 true /* is_parent_frame_secure */, 592 kRenderProcessId1, provider_id++, true /* is_parent_frame_secure */,
591 context()->AsWeakPtr()); 593 context()->AsWeakPtr(), &remote_endpoints.back());
592 host1->SetDocumentUrl(kOrigin1); 594 host1->SetDocumentUrl(kOrigin1);
593 595
594 // Host2 (provider_id=2): process_id=2, origin2. 596 // Host2 (provider_id=2): process_id=2, origin2.
597 remote_endpoints.emplace_back();
595 std::unique_ptr<ServiceWorkerProviderHost> host2 = 598 std::unique_ptr<ServiceWorkerProviderHost> host2 =
596 CreateProviderHostForWindow(kRenderProcessId2, provider_id++, 599 CreateProviderHostForWindow(
597 true /* is_parent_frame_secure */, 600 kRenderProcessId2, provider_id++, true /* is_parent_frame_secure */,
598 context()->AsWeakPtr()); 601 context()->AsWeakPtr(), &remote_endpoints.back());
599 host2->SetDocumentUrl(kOrigin2); 602 host2->SetDocumentUrl(kOrigin2);
600 603
601 // Host3 (provider_id=3): process_id=2, origin1. 604 // Host3 (provider_id=3): process_id=2, origin1.
605 remote_endpoints.emplace_back();
602 std::unique_ptr<ServiceWorkerProviderHost> host3 = 606 std::unique_ptr<ServiceWorkerProviderHost> host3 =
603 CreateProviderHostForWindow(kRenderProcessId2, provider_id++, 607 CreateProviderHostForWindow(
604 true /* is_parent_frame_secure */, 608 kRenderProcessId2, provider_id++, true /* is_parent_frame_secure */,
605 context()->AsWeakPtr()); 609 context()->AsWeakPtr(), &remote_endpoints.back());
606 host3->SetDocumentUrl(kOrigin1); 610 host3->SetDocumentUrl(kOrigin1);
607 611
608 // Host4 (provider_id=4): process_id=2, origin2, for ServiceWorker. 612 // Host4 (provider_id=4): process_id=2, origin2, for ServiceWorker.
613 remote_endpoints.emplace_back();
609 std::unique_ptr<ServiceWorkerProviderHost> host4 = 614 std::unique_ptr<ServiceWorkerProviderHost> host4 =
610 CreateProviderHostForServiceWorkerContext( 615 CreateProviderHostForServiceWorkerContext(
611 kRenderProcessId2, provider_id++, true /* is_parent_frame_secure */, 616 kRenderProcessId2, provider_id++, true /* is_parent_frame_secure */,
612 context()->AsWeakPtr()); 617 context()->AsWeakPtr(), &remote_endpoints.back());
613 host4->SetDocumentUrl(kOrigin2); 618 host4->SetDocumentUrl(kOrigin2);
614 619
615 ServiceWorkerProviderHost* host1_raw = host1.get(); 620 ServiceWorkerProviderHost* host1_raw = host1.get();
616 ServiceWorkerProviderHost* host2_raw = host2.get(); 621 ServiceWorkerProviderHost* host2_raw = host2.get();
617 ServiceWorkerProviderHost* host3_raw = host3.get(); 622 ServiceWorkerProviderHost* host3_raw = host3.get();
618 ServiceWorkerProviderHost* host4_raw = host4.get(); 623 ServiceWorkerProviderHost* host4_raw = host4.get();
619 context()->AddProviderHost(std::move(host1)); 624 context()->AddProviderHost(std::move(host1));
620 context()->AddProviderHost(std::move(host2)); 625 context()->AddProviderHost(std::move(host2));
621 context()->AddProviderHost(std::move(host3)); 626 context()->AddProviderHost(std::move(host3));
622 context()->AddProviderHost(std::move(host4)); 627 context()->AddProviderHost(std::move(host4));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type); 765 EXPECT_EQ(REGISTRATION_STORED, notifications_[2].type);
761 EXPECT_EQ(pattern, notifications_[2].pattern); 766 EXPECT_EQ(pattern, notifications_[2].pattern);
762 EXPECT_EQ(registration_id, notifications_[2].registration_id); 767 EXPECT_EQ(registration_id, notifications_[2].registration_id);
763 } 768 }
764 769
765 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest, 770 INSTANTIATE_TEST_CASE_P(ServiceWorkerContextRecoveryTest,
766 ServiceWorkerContextRecoveryTest, 771 ServiceWorkerContextRecoveryTest,
767 testing::Bool()); 772 testing::Bool());
768 773
769 } // namespace content 774 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698