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

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

Issue 2039743003: Introduce ServiceWorker.ActivatedWorkerPreparationForMainFrame.Time UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move GetWorkerPreparationSuffix Created 4 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 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/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 bool called = false; 625 bool called = false;
626 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT; 626 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT;
627 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, 627 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
628 base::Bind(&SaveStatusCallback, &called, &status)); 628 base::Bind(&SaveStatusCallback, &called, &status));
629 base::RunLoop().RunUntilIdle(); 629 base::RunLoop().RunUntilIdle();
630 630
631 EXPECT_TRUE(called); 631 EXPECT_TRUE(called);
632 EXPECT_EQ(SERVICE_WORKER_OK, status); 632 EXPECT_EQ(SERVICE_WORKER_OK, status);
633 633
634 EXPECT_TRUE(context()->GetProviderHost(process_id, provider_id)); 634 EXPECT_TRUE(context()->GetProviderHost(process_id, provider_id));
635 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status()); 635 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::RUNNING,
636 version_->running_status());
636 637
637 // Simulate the render process crashing. 638 // Simulate the render process crashing.
638 dispatcher_host_->OnFilterRemoved(); 639 dispatcher_host_->OnFilterRemoved();
639 640
640 // The dispatcher host should clean up the state from the process. 641 // The dispatcher host should clean up the state from the process.
641 EXPECT_FALSE(context()->GetProviderHost(process_id, provider_id)); 642 EXPECT_FALSE(context()->GetProviderHost(process_id, provider_id));
642 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 643 EXPECT_EQ(ServiceWorkerVersion::RunningStatus::STOPPED,
644 version_->running_status());
643 645
644 // We should be able to hook up a new dispatcher host although the old object 646 // We should be able to hook up a new dispatcher host although the old object
645 // is not yet destroyed. This is what the browser does when reusing a crashed 647 // is not yet destroyed. This is what the browser does when reusing a crashed
646 // render process. 648 // render process.
647 scoped_refptr<TestingServiceWorkerDispatcherHost> new_dispatcher_host( 649 scoped_refptr<TestingServiceWorkerDispatcherHost> new_dispatcher_host(
648 new TestingServiceWorkerDispatcherHost( 650 new TestingServiceWorkerDispatcherHost(
649 process_id, context_wrapper(), &resource_context_, helper_.get())); 651 process_id, context_wrapper(), &resource_context_, helper_.get()));
650 652
651 // To show the new dispatcher can operate, simulate provider creation. Since 653 // To show the new dispatcher can operate, simulate provider creation. Since
652 // the old dispatcher cleaned up the old provider host, the new one won't 654 // the old dispatcher cleaned up the old provider host, the new one won't
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 provider_host_->process_id()); 758 provider_host_->process_id());
757 // SendSetHostedVersionId should reject because the provider host process id 759 // SendSetHostedVersionId should reject because the provider host process id
758 // is different. 760 // is different.
759 SendSetHostedVersionId(kProviderId, version_->version_id()); 761 SendSetHostedVersionId(kProviderId, version_->version_id());
760 base::RunLoop().RunUntilIdle(); 762 base::RunLoop().RunUntilIdle();
761 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( 763 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching(
762 ServiceWorkerMsg_AssociateRegistration::ID)); 764 ServiceWorkerMsg_AssociateRegistration::ID));
763 } 765 }
764 766
765 } // namespace content 767 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698