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

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

Issue 2933793002: ServiceWorker: keep dispatcher hosts for unittests in the test helper (Closed)
Patch Set: RegisterMockDispatcherHost -> RegisterDispatcherHost Created 3 years, 6 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_dispatcher_host_unittest.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
index 5ccbba1dbfdfa197377b9be827e94e93b7d88600..e2debc26b2ec9973ca0b7dc5c83d157bcc7c40c4 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -99,16 +99,12 @@ static const int kRenderFrameId = 1;
class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost {
public:
- TestingServiceWorkerDispatcherHost(
- int process_id,
- ServiceWorkerContextWrapper* context_wrapper,
- ResourceContext* resource_context,
- EmbeddedWorkerTestHelper* helper)
+ TestingServiceWorkerDispatcherHost(int process_id,
+ ResourceContext* resource_context,
+ EmbeddedWorkerTestHelper* helper)
: ServiceWorkerDispatcherHost(process_id, resource_context),
bad_messages_received_count_(0),
- helper_(helper) {
- Init(context_wrapper);
- }
+ helper_(helper) {}
bool Send(IPC::Message* message) override { return helper_->Send(message); }
@@ -166,9 +162,10 @@ class ServiceWorkerDispatcherHostTest : public testing::Test {
helper_.reset(helper.release());
// Replace the default dispatcher host.
int process_id = helper_->mock_render_process_id();
- context()->RemoveDispatcherHost(process_id);
dispatcher_host_ = new TestingServiceWorkerDispatcherHost(
- process_id, context_wrapper(), &resource_context_, helper_.get());
+ process_id, &resource_context_, helper_.get());
+ helper_->RegisterDispatcherHost(process_id, nullptr);
+ dispatcher_host_->Init(context_wrapper());
}
void SetUpRegistration(const GURL& scope, const GURL& script_url) {
@@ -743,8 +740,9 @@ TEST_F(ServiceWorkerDispatcherHostTest, CleanupOnRendererCrash) {
// is not yet destroyed. This is what the browser does when reusing a crashed
// render process.
scoped_refptr<TestingServiceWorkerDispatcherHost> new_dispatcher_host(
- new TestingServiceWorkerDispatcherHost(
- process_id, context_wrapper(), &resource_context_, helper_.get()));
+ new TestingServiceWorkerDispatcherHost(process_id, &resource_context_,
+ helper_.get()));
+ new_dispatcher_host->Init(context_wrapper());
// To show the new dispatcher can operate, simulate provider creation. Since
// the old dispatcher cleaned up the old provider host, the new one won't

Powered by Google App Engine
This is Rietveld 408576698