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

Side by Side Diff: content/browser/service_worker/service_worker_handle_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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <tuple> 5 #include <tuple>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/service_worker/embedded_worker_registry.h" 10 #include "content/browser/service_worker/embedded_worker_registry.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 }; 69 };
70 70
71 class ServiceWorkerHandleTest : public testing::Test { 71 class ServiceWorkerHandleTest : public testing::Test {
72 public: 72 public:
73 ServiceWorkerHandleTest() 73 ServiceWorkerHandleTest()
74 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} 74 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {}
75 75
76 void SetUp() override { 76 void SetUp() override {
77 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath())); 77 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath()));
78 78
79 helper_->context()->RemoveDispatcherHost(helper_->mock_render_process_id());
79 dispatcher_host_ = new TestingServiceWorkerDispatcherHost( 80 dispatcher_host_ = new TestingServiceWorkerDispatcherHost(
80 helper_->mock_render_process_id(), helper_->context_wrapper(), 81 helper_->mock_render_process_id(), helper_->context_wrapper(),
81 &resource_context_, helper_.get()); 82 &resource_context_, helper_.get());
82 83
83 const GURL pattern("http://www.example.com/"); 84 const GURL pattern("http://www.example.com/");
84 registration_ = new ServiceWorkerRegistration( 85 registration_ = new ServiceWorkerRegistration(
85 pattern, 86 pattern,
86 1L, 87 1L,
87 helper_->context()->AsWeakPtr()); 88 helper_->context()->AsWeakPtr());
88 version_ = new ServiceWorkerVersion( 89 version_ = new ServiceWorkerVersion(
(...skipping 14 matching lines...) Expand all
103 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); 104 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing));
104 base::RunLoop().RunUntilIdle(); 105 base::RunLoop().RunUntilIdle();
105 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 106 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
106 helper_->context()->storage()->StoreRegistration( 107 helper_->context()->storage()->StoreRegistration(
107 registration_.get(), 108 registration_.get(),
108 version_.get(), 109 version_.get(),
109 CreateReceiverOnCurrentThread(&status)); 110 CreateReceiverOnCurrentThread(&status));
110 base::RunLoop().RunUntilIdle(); 111 base::RunLoop().RunUntilIdle();
111 ASSERT_EQ(SERVICE_WORKER_OK, status); 112 ASSERT_EQ(SERVICE_WORKER_OK, status);
112 113
113 provider_host_.reset(new ServiceWorkerProviderHost( 114 provider_host_ = CreateProviderHostWithDispatcherHost(
114 helper_->mock_render_process_id(), kRenderFrameId, 1, 115 helper_->mock_render_process_id(), 1 /* provider_id */,
115 SERVICE_WORKER_PROVIDER_FOR_WINDOW, 116 helper_->context()->AsWeakPtr(), kRenderFrameId,
116 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, 117 dispatcher_host_.get());
117 helper_->context()->AsWeakPtr(), dispatcher_host_.get()));
118
119 helper_->SimulateAddProcessToPattern(pattern, 118 helper_->SimulateAddProcessToPattern(pattern,
120 helper_->mock_render_process_id()); 119 helper_->mock_render_process_id());
121 } 120 }
122 121
123 void TearDown() override { 122 void TearDown() override {
124 dispatcher_host_ = NULL; 123 dispatcher_host_ = NULL;
125 registration_ = NULL; 124 registration_ = NULL;
126 version_ = NULL; 125 version_ = NULL;
127 provider_host_.reset(); 126 provider_host_.reset();
128 helper_.reset(); 127 helper_.reset();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // StartWorker shouldn't be recorded here. 163 // StartWorker shouldn't be recorded here.
165 ASSERT_EQ(1UL, ipc_sink()->message_count()); 164 ASSERT_EQ(1UL, ipc_sink()->message_count());
166 message = ipc_sink()->GetMessageAt(0); 165 message = ipc_sink()->GetMessageAt(0);
167 166
168 // StateChanged (state == Installed). 167 // StateChanged (state == Installed).
169 VerifyStateChangedMessage(handle->handle_id(), 168 VerifyStateChangedMessage(handle->handle_id(),
170 blink::WebServiceWorkerStateInstalled, message); 169 blink::WebServiceWorkerStateInstalled, message);
171 } 170 }
172 171
173 } // namespace content 172 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698