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

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

Issue 2313653002: ServiceWorker: Exchange InterfaceProviders when starting worker thread (Closed)
Patch Set: Indent Created 4 years, 3 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/embedded_worker_instance.h" 5 #include "content/browser/service_worker/embedded_worker_instance.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 helper_->SimulateAddProcessToPattern(pattern, 195 helper_->SimulateAddProcessToPattern(pattern,
196 helper_->mock_render_process_id()); 196 helper_->mock_render_process_id());
197 197
198 // Check if StartWorker/StopWorker will be called via mojo IPC. 198 // Check if StartWorker/StopWorker will be called via mojo IPC.
199 helper_->PrepareMockInstanceClients(1); 199 helper_->PrepareMockInstanceClients(1);
200 ASSERT_EQ(mock_instance_clients()->size(), 1UL); 200 ASSERT_EQ(mock_instance_clients()->size(), 1UL);
201 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient* instance_client = 201 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient* instance_client =
202 mock_instance_clients()->at(0).get(); 202 mock_instance_clients()->at(0).get();
203 EXPECT_CALL( 203 EXPECT_CALL(
204 *instance_client, 204 *instance_client,
205 MockStartWorker(AllOf( 205 MockStartWorker(
206 Pointee( 206 AllOf(Pointee(Field(
207 Field(&EmbeddedWorkerStartWorkerParams::service_worker_version_id, 207 &EmbeddedWorkerStartWorkerParams::service_worker_version_id,
208 Eq(service_worker_version_id))), 208 Eq(service_worker_version_id))),
209 Pointee(Field(&EmbeddedWorkerStartWorkerParams::scope, Eq(pattern))), 209 Pointee(Field(&EmbeddedWorkerStartWorkerParams::scope,
210 Pointee( 210 Eq(pattern))),
211 Field(&EmbeddedWorkerStartWorkerParams::script_url, Eq(url)))))) 211 Pointee(Field(&EmbeddedWorkerStartWorkerParams::script_url,
212 Eq(url)))),
213 _))
212 .Times(1); 214 .Times(1);
213 EXPECT_CALL(*instance_client, MockStopWorker(_)).Times(1); 215 EXPECT_CALL(*instance_client, MockStopWorker(_)).Times(1);
214 216
215 // Start should succeed. 217 // Start should succeed.
216 ServiceWorkerStatusCode status; 218 ServiceWorkerStatusCode status;
217 base::RunLoop run_loop; 219 base::RunLoop run_loop;
218 std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params = 220 std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params =
219 CreateStartParams(service_worker_version_id, pattern, url); 221 CreateStartParams(service_worker_version_id, pattern, url);
220 worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, 222 worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status,
221 run_loop.QuitClosure())); 223 run_loop.QuitClosure()));
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 674
673 const int64_t version_id = 55L; 675 const int64_t version_id = 55L;
674 const GURL pattern("http://example.com/"); 676 const GURL pattern("http://example.com/");
675 const GURL url("http://example.com/worker.js"); 677 const GURL url("http://example.com/worker.js");
676 678
677 // Let StartWorker fail; binding is discarded in the middle of IPC 679 // Let StartWorker fail; binding is discarded in the middle of IPC
678 helper_->PrepareMockInstanceClients(1); 680 helper_->PrepareMockInstanceClients(1);
679 ASSERT_EQ(mock_instance_clients()->size(), 1UL); 681 ASSERT_EQ(mock_instance_clients()->size(), 1UL);
680 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient* instance_client = 682 EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient* instance_client =
681 mock_instance_clients()->at(0).get(); 683 mock_instance_clients()->at(0).get();
682 EXPECT_CALL(*instance_client, MockStartWorker(_)) 684 EXPECT_CALL(*instance_client, MockStartWorker(_, _))
683 .WillOnce(WithoutArgs( 685 .WillOnce(WithoutArgs(
684 Invoke([this]() { helper_->mock_instance_clients()->clear(); }))); 686 Invoke([this]() { helper_->mock_instance_clients()->clear(); })));
685 687
686 std::unique_ptr<EmbeddedWorkerInstance> worker = 688 std::unique_ptr<EmbeddedWorkerInstance> worker =
687 embedded_worker_registry()->CreateWorker(); 689 embedded_worker_registry()->CreateWorker();
688 helper_->SimulateAddProcessToPattern(pattern, 690 helper_->SimulateAddProcessToPattern(pattern,
689 helper_->mock_render_process_id()); 691 helper_->mock_render_process_id());
690 worker->AddListener(this); 692 worker->AddListener(this);
691 693
692 // Attempt to start the worker. 694 // Attempt to start the worker.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 732
731 // Worker should handle the failure of binding as detach. 733 // Worker should handle the failure of binding as detach.
732 ASSERT_EQ(3u, events_.size()); 734 ASSERT_EQ(3u, events_.size());
733 EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type); 735 EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type);
734 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); 736 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type);
735 EXPECT_EQ(DETACHED, events_[2].type); 737 EXPECT_EQ(DETACHED, events_[2].type);
736 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); 738 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status);
737 } 739 }
738 740
739 } // namespace content 741 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698