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

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: 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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "content/browser/browser_thread_impl.h" 15 #include "content/browser/browser_thread_impl.h"
16 #include "content/browser/message_port_service.h" 16 #include "content/browser/message_port_service.h"
17 #include "content/browser/service_worker/embedded_worker_instance.h" 17 #include "content/browser/service_worker/embedded_worker_instance.h"
18 #include "content/browser/service_worker/embedded_worker_registry.h" 18 #include "content/browser/service_worker/embedded_worker_registry.h"
19 #include "content/browser/service_worker/embedded_worker_status.h"
19 #include "content/browser/service_worker/embedded_worker_test_helper.h" 20 #include "content/browser/service_worker/embedded_worker_test_helper.h"
20 #include "content/browser/service_worker/service_worker_context_core.h" 21 #include "content/browser/service_worker/service_worker_context_core.h"
21 #include "content/browser/service_worker/service_worker_context_wrapper.h" 22 #include "content/browser/service_worker/service_worker_context_wrapper.h"
22 #include "content/browser/service_worker/service_worker_handle.h" 23 #include "content/browser/service_worker/service_worker_handle.h"
23 #include "content/common/service_worker/embedded_worker_messages.h" 24 #include "content/common/service_worker/embedded_worker_messages.h"
24 #include "content/common/service_worker/service_worker_messages.h" 25 #include "content/common/service_worker/service_worker_messages.h"
25 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
26 #include "content/public/test/mock_resource_context.h" 27 #include "content/public/test/mock_resource_context.h"
27 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
28 #include "content/test/test_content_browser_client.h" 29 #include "content/test/test_content_browser_client.h"
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 bool called = false; 626 bool called = false;
626 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT; 627 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT;
627 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, 628 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN,
628 base::Bind(&SaveStatusCallback, &called, &status)); 629 base::Bind(&SaveStatusCallback, &called, &status));
629 base::RunLoop().RunUntilIdle(); 630 base::RunLoop().RunUntilIdle();
630 631
631 EXPECT_TRUE(called); 632 EXPECT_TRUE(called);
632 EXPECT_EQ(SERVICE_WORKER_OK, status); 633 EXPECT_EQ(SERVICE_WORKER_OK, status);
633 634
634 EXPECT_TRUE(context()->GetProviderHost(process_id, provider_id)); 635 EXPECT_TRUE(context()->GetProviderHost(process_id, provider_id));
635 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status()); 636 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, 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(EmbeddedWorkerStatus::STOPPED, version_->running_status());
643 644
644 // We should be able to hook up a new dispatcher host although the old object 645 // 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 646 // is not yet destroyed. This is what the browser does when reusing a crashed
646 // render process. 647 // render process.
647 scoped_refptr<TestingServiceWorkerDispatcherHost> new_dispatcher_host( 648 scoped_refptr<TestingServiceWorkerDispatcherHost> new_dispatcher_host(
648 new TestingServiceWorkerDispatcherHost( 649 new TestingServiceWorkerDispatcherHost(
649 process_id, context_wrapper(), &resource_context_, helper_.get())); 650 process_id, context_wrapper(), &resource_context_, helper_.get()));
650 651
651 // To show the new dispatcher can operate, simulate provider creation. Since 652 // 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 653 // 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()); 757 provider_host_->process_id());
757 // SendSetHostedVersionId should reject because the provider host process id 758 // SendSetHostedVersionId should reject because the provider host process id
758 // is different. 759 // is different.
759 SendSetHostedVersionId(kProviderId, version_->version_id()); 760 SendSetHostedVersionId(kProviderId, version_->version_id());
760 base::RunLoop().RunUntilIdle(); 761 base::RunLoop().RunUntilIdle();
761 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( 762 EXPECT_FALSE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching(
762 ServiceWorkerMsg_AssociateRegistration::ID)); 763 ServiceWorkerMsg_AssociateRegistration::ID));
763 } 764 }
764 765
765 } // namespace content 766 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698