| 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 638b46b1789ee1bbcbd7ee12f5770a5fecef090a..10e4b83b5a6969ae73abeceaf4eb840f02ec3a78 100644
|
| --- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
|
| +++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
|
| @@ -156,16 +156,16 @@ class ServiceWorkerDispatcherHostTest : public testing::Test {
|
| void SendSetHostedVersionId(int provider_id,
|
| int64_t version_id,
|
| int embedded_worker_id) {
|
| - dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_SetVersionId(
|
| - provider_id, version_id, embedded_worker_id));
|
| + dispatcher_host_->OnSetHostedVersionId(provider_id, version_id,
|
| + embedded_worker_id);
|
| }
|
|
|
| void SendProviderCreated(ServiceWorkerProviderType type,
|
| const GURL& pattern) {
|
| const int64_t kProviderId = 99;
|
| - dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
|
| - kProviderId, MSG_ROUTING_NONE, type,
|
| - true /* is_parent_frame_secure */));
|
| + ServiceWorkerProviderHostInfo info(kProviderId, MSG_ROUTING_NONE, type,
|
| + true);
|
| + dispatcher_host_->OnProviderCreated(std::move(info));
|
| helper_->SimulateAddProcessToPattern(pattern,
|
| helper_->mock_render_process_id());
|
| provider_host_ = context()->GetProviderHost(
|
| @@ -246,12 +246,15 @@ class ServiceWorkerDispatcherHostTest : public testing::Test {
|
| sender_provider_host, callback);
|
| }
|
|
|
| - ServiceWorkerProviderHost* CreateServiceWorkerProviderHost(int provider_id) {
|
| - return new ServiceWorkerProviderHost(
|
| - helper_->mock_render_process_id(), kRenderFrameId, provider_id,
|
| - SERVICE_WORKER_PROVIDER_FOR_WINDOW,
|
| - ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
|
| - context()->AsWeakPtr(), dispatcher_host_.get());
|
| + std::unique_ptr<ServiceWorkerProviderHost> CreateServiceWorkerProviderHost(
|
| + int provider_id) {
|
| + std::unique_ptr<ServiceWorkerProviderHost> host =
|
| + ServiceWorkerProviderHost::CreateForTesting(
|
| + helper_->mock_render_process_id(), provider_id,
|
| + SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(),
|
| + kRenderFrameId, dispatcher_host_.get());
|
| + host->set_parent_frame_secure(true);
|
| + return host;
|
| }
|
|
|
| TestBrowserThreadBundle browser_thread_bundle_;
|
| @@ -510,34 +513,32 @@ TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) {
|
| const int kProviderId = 1001;
|
| int process_id = helper_->mock_render_process_id();
|
|
|
| - dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
|
| + dispatcher_host_->OnProviderCreated(ServiceWorkerProviderHostInfo(
|
| kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
|
| true /* is_parent_frame_secure */));
|
| EXPECT_TRUE(context()->GetProviderHost(process_id, kProviderId));
|
|
|
| // Two with the same ID should be seen as a bad message.
|
| - dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
|
| + dispatcher_host_->OnProviderCreated(ServiceWorkerProviderHostInfo(
|
| kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
|
| true /* is_parent_frame_secure */));
|
| EXPECT_EQ(1, dispatcher_host_->bad_messages_received_count_);
|
|
|
| - dispatcher_host_->OnMessageReceived(
|
| - ServiceWorkerHostMsg_ProviderDestroyed(kProviderId));
|
| + dispatcher_host_->OnProviderDestroyed(kProviderId);
|
| EXPECT_FALSE(context()->GetProviderHost(process_id, kProviderId));
|
|
|
| // Destroying an ID that does not exist warrants a bad message.
|
| - dispatcher_host_->OnMessageReceived(
|
| - ServiceWorkerHostMsg_ProviderDestroyed(kProviderId));
|
| + dispatcher_host_->OnProviderDestroyed(kProviderId);
|
| EXPECT_EQ(2, dispatcher_host_->bad_messages_received_count_);
|
|
|
| // Deletion of the dispatcher_host should cause providers for that
|
| // process to get deleted as well.
|
| - dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
|
| + dispatcher_host_->OnProviderCreated(ServiceWorkerProviderHostInfo(
|
| kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
|
| true /* is_parent_frame_secure */));
|
| EXPECT_TRUE(context()->GetProviderHost(process_id, kProviderId));
|
| EXPECT_TRUE(dispatcher_host_->HasOneRef());
|
| - dispatcher_host_ = NULL;
|
| + dispatcher_host_ = nullptr;
|
| EXPECT_FALSE(context()->GetProviderHost(process_id, kProviderId));
|
| }
|
|
|
| @@ -669,7 +670,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, CleanupOnRendererCrash) {
|
| // 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
|
| // complain.
|
| - new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated(
|
| + new_dispatcher_host->OnProviderCreated(ServiceWorkerProviderHostInfo(
|
| provider_id, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW,
|
| true /* is_parent_frame_secure */));
|
| EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_);
|
|
|