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

Unified Diff: content/browser/service_worker/service_worker_context_unittest.cc

Issue 2638313002: Manage ServiceWorkerDispatcherHost in ServiceWorkerContextCore (Closed)
Patch Set: Rebase Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_context_unittest.cc
diff --git a/content/browser/service_worker/service_worker_context_unittest.cc b/content/browser/service_worker/service_worker_context_unittest.cc
index 761edd799e9691f856f1b9aa0f117dd93ab879f5..1a49d8bc99a4354c31a417d87e74ffcc721c700a 100644
--- a/content/browser/service_worker/service_worker_context_unittest.cc
+++ b/content/browser/service_worker/service_worker_context_unittest.cc
@@ -586,41 +586,41 @@ TEST_F(ServiceWorkerContextTest, ProviderHostIterator) {
int provider_id = 1;
// Host1 (provider_id=1): process_id=1, origin1.
- ServiceWorkerProviderHost* host1(new ServiceWorkerProviderHost(
- kRenderProcessId1, MSG_ROUTING_NONE, provider_id++,
- SERVICE_WORKER_PROVIDER_FOR_WINDOW,
- ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
- context()->AsWeakPtr(), nullptr));
+ std::unique_ptr<ServiceWorkerProviderHost> host1 =
+ CreateProviderHostForWindow(kRenderProcessId1, provider_id++,
+ true /* is_parent_frame_secure */,
+ context()->AsWeakPtr());
host1->SetDocumentUrl(kOrigin1);
// Host2 (provider_id=2): process_id=2, origin2.
- ServiceWorkerProviderHost* host2(new ServiceWorkerProviderHost(
- kRenderProcessId2, MSG_ROUTING_NONE, provider_id++,
- SERVICE_WORKER_PROVIDER_FOR_WINDOW,
- ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
- context()->AsWeakPtr(), nullptr));
+ std::unique_ptr<ServiceWorkerProviderHost> host2 =
+ CreateProviderHostForWindow(kRenderProcessId2, provider_id++,
+ true /* is_parent_frame_secure */,
+ context()->AsWeakPtr());
host2->SetDocumentUrl(kOrigin2);
// Host3 (provider_id=3): process_id=2, origin1.
- ServiceWorkerProviderHost* host3(new ServiceWorkerProviderHost(
- kRenderProcessId2, MSG_ROUTING_NONE, provider_id++,
- SERVICE_WORKER_PROVIDER_FOR_WINDOW,
- ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
- context()->AsWeakPtr(), nullptr));
+ std::unique_ptr<ServiceWorkerProviderHost> host3 =
+ CreateProviderHostForWindow(kRenderProcessId2, provider_id++,
+ true /* is_parent_frame_secure */,
+ context()->AsWeakPtr());
host3->SetDocumentUrl(kOrigin1);
// Host4 (provider_id=4): process_id=2, origin2, for ServiceWorker.
- ServiceWorkerProviderHost* host4(new ServiceWorkerProviderHost(
- kRenderProcessId2, MSG_ROUTING_NONE, provider_id++,
- SERVICE_WORKER_PROVIDER_FOR_CONTROLLER,
- ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
- context()->AsWeakPtr(), nullptr));
+ std::unique_ptr<ServiceWorkerProviderHost> host4 =
+ CreateProviderHostForServiceWorkerContext(
+ kRenderProcessId2, provider_id++, true /* is_parent_frame_secure */,
+ context()->AsWeakPtr());
host4->SetDocumentUrl(kOrigin2);
- context()->AddProviderHost(base::WrapUnique(host1));
- context()->AddProviderHost(base::WrapUnique(host2));
- context()->AddProviderHost(base::WrapUnique(host3));
- context()->AddProviderHost(base::WrapUnique(host4));
+ ServiceWorkerProviderHost* host1_raw = host1.get();
+ ServiceWorkerProviderHost* host2_raw = host2.get();
+ ServiceWorkerProviderHost* host3_raw = host3.get();
+ ServiceWorkerProviderHost* host4_raw = host4.get();
+ context()->AddProviderHost(std::move(host1));
+ context()->AddProviderHost(std::move(host2));
+ context()->AddProviderHost(std::move(host3));
+ context()->AddProviderHost(std::move(host4));
// Iterate over all provider hosts.
std::set<ServiceWorkerProviderHost*> results;
@@ -629,10 +629,10 @@ TEST_F(ServiceWorkerContextTest, ProviderHostIterator) {
results.insert(it->GetProviderHost());
}
EXPECT_EQ(4u, results.size());
- EXPECT_TRUE(ContainsKey(results, host1));
- EXPECT_TRUE(ContainsKey(results, host2));
- EXPECT_TRUE(ContainsKey(results, host3));
- EXPECT_TRUE(ContainsKey(results, host4));
+ EXPECT_TRUE(ContainsKey(results, host1_raw));
+ EXPECT_TRUE(ContainsKey(results, host2_raw));
+ EXPECT_TRUE(ContainsKey(results, host3_raw));
+ EXPECT_TRUE(ContainsKey(results, host4_raw));
// Iterate over the client provider hosts that belong to kOrigin1.
results.clear();
@@ -641,8 +641,8 @@ TEST_F(ServiceWorkerContextTest, ProviderHostIterator) {
results.insert(it->GetProviderHost());
}
EXPECT_EQ(2u, results.size());
- EXPECT_TRUE(ContainsKey(results, host1));
- EXPECT_TRUE(ContainsKey(results, host3));
+ EXPECT_TRUE(ContainsKey(results, host1_raw));
+ EXPECT_TRUE(ContainsKey(results, host3_raw));
// Iterate over the provider hosts that belong to kOrigin2.
// (This should not include host4 as it's not for controllee.)
@@ -652,7 +652,7 @@ TEST_F(ServiceWorkerContextTest, ProviderHostIterator) {
results.insert(it->GetProviderHost());
}
EXPECT_EQ(1u, results.size());
- EXPECT_TRUE(ContainsKey(results, host2));
+ EXPECT_TRUE(ContainsKey(results, host2_raw));
context()->RemoveProviderHost(kRenderProcessId1, 1);
context()->RemoveProviderHost(kRenderProcessId2, 2);

Powered by Google App Engine
This is Rietveld 408576698