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

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

Issue 2766263009: Convert content ConnectionFilter to OnBindInterface (Closed)
Patch Set: . Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_test_helper.h" 5 #include "content/browser/service_worker/embedded_worker_test_helper.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient:: 108 void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::
109 AddMessageToConsole(blink::WebConsoleMessage::Level level, 109 AddMessageToConsole(blink::WebConsoleMessage::Level level,
110 const std::string& message) { 110 const std::string& message) {
111 // TODO(shimazu): Pass these arguments to the test helper when a test is 111 // TODO(shimazu): Pass these arguments to the test helper when a test is
112 // necessary to check them individually. 112 // necessary to check them individually.
113 } 113 }
114 114
115 // static 115 // static
116 void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::Bind( 116 void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::Bind(
117 const base::WeakPtr<EmbeddedWorkerTestHelper>& helper, 117 const base::WeakPtr<EmbeddedWorkerTestHelper>& helper,
118 mojom::EmbeddedWorkerInstanceClientRequest request) { 118 mojo::ScopedMessagePipeHandle request_handle) {
119 mojom::EmbeddedWorkerInstanceClientRequest request =
120 mojo::MakeRequest<mojom::EmbeddedWorkerInstanceClient>(
121 std::move(request_handle));
119 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>* clients = 122 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>* clients =
120 helper->mock_instance_clients(); 123 helper->mock_instance_clients();
121 size_t next_client_index = helper->mock_instance_clients_next_index_; 124 size_t next_client_index = helper->mock_instance_clients_next_index_;
122 125
123 ASSERT_GE(clients->size(), next_client_index); 126 ASSERT_GE(clients->size(), next_client_index);
124 if (clients->size() == next_client_index) { 127 if (clients->size() == next_client_index) {
125 clients->push_back( 128 clients->push_back(
126 base::MakeUnique<MockEmbeddedWorkerInstanceClient>(helper)); 129 base::MakeUnique<MockEmbeddedWorkerInstanceClient>(helper));
127 } 130 }
128 131
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 wrapper_->process_manager()->SetNewProcessIdForTest(new_render_process_id()); 286 wrapper_->process_manager()->SetNewProcessIdForTest(new_render_process_id());
284 287
285 scoped_refptr<ServiceWorkerDispatcherHost> dispatcher_host( 288 scoped_refptr<ServiceWorkerDispatcherHost> dispatcher_host(
286 new MockServiceWorkerDispatcherHost( 289 new MockServiceWorkerDispatcherHost(
287 mock_render_process_id_, browser_context_->GetResourceContext(), 290 mock_render_process_id_, browser_context_->GetResourceContext(),
288 this)); 291 this));
289 wrapper_->context()->AddDispatcherHost(mock_render_process_id_, 292 wrapper_->context()->AddDispatcherHost(mock_render_process_id_,
290 dispatcher_host.get()); 293 dispatcher_host.get());
291 dispatcher_hosts_[mock_render_process_id_] = std::move(dispatcher_host); 294 dispatcher_hosts_[mock_render_process_id_] = std::move(dispatcher_host);
292 295
293 // Setup process level interface registry. 296 render_process_host_->OverrideBinderForTesting(
294 render_process_interface_registry_ = 297 mojom::EmbeddedWorkerInstanceClient::Name_,
295 CreateInterfaceRegistry(render_process_host_.get()); 298 base::Bind(&MockEmbeddedWorkerInstanceClient::Bind, AsWeakPtr()));
296 new_render_process_interface_registry_ = 299 new_render_process_host_->OverrideBinderForTesting(
297 CreateInterfaceRegistry(new_render_process_host_.get()); 300 mojom::EmbeddedWorkerInstanceClient::Name_,
301 base::Bind(&MockEmbeddedWorkerInstanceClient::Bind, AsWeakPtr()));
298 } 302 }
299 303
300 EmbeddedWorkerTestHelper::~EmbeddedWorkerTestHelper() { 304 EmbeddedWorkerTestHelper::~EmbeddedWorkerTestHelper() {
301 if (wrapper_.get()) 305 if (wrapper_.get())
302 wrapper_->Shutdown(); 306 wrapper_->Shutdown();
303 } 307 }
304 308
305 void EmbeddedWorkerTestHelper::SimulateAddProcessToPattern(const GURL& pattern, 309 void EmbeddedWorkerTestHelper::SimulateAddProcessToPattern(const GURL& pattern,
306 int process_id) { 310 int process_id) {
307 if (!context()->GetDispatcherHost(process_id)) { 311 if (!context()->GetDispatcherHost(process_id)) {
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 FROM_HERE, 758 FROM_HERE,
755 base::Bind(&EmbeddedWorkerTestHelper::OnPaymentRequestEvent, AsWeakPtr(), 759 base::Bind(&EmbeddedWorkerTestHelper::OnPaymentRequestEvent, AsWeakPtr(),
756 base::Passed(std::move(app_request)), callback)); 760 base::Passed(std::move(app_request)), callback));
757 } 761 }
758 762
759 EmbeddedWorkerRegistry* EmbeddedWorkerTestHelper::registry() { 763 EmbeddedWorkerRegistry* EmbeddedWorkerTestHelper::registry() {
760 DCHECK(context()); 764 DCHECK(context());
761 return context()->embedded_worker_registry(); 765 return context()->embedded_worker_registry();
762 } 766 }
763 767
764 std::unique_ptr<service_manager::InterfaceRegistry>
765 EmbeddedWorkerTestHelper::CreateInterfaceRegistry(MockRenderProcessHost* rph) {
766 auto registry =
767 base::MakeUnique<service_manager::InterfaceRegistry>(std::string());
768 registry->AddInterface(
769 base::Bind(&MockEmbeddedWorkerInstanceClient::Bind, AsWeakPtr()));
770
771 service_manager::mojom::InterfaceProviderPtr interfaces;
772 registry->Bind(mojo::MakeRequest(&interfaces), service_manager::Identity(),
773 service_manager::InterfaceProviderSpec(),
774 service_manager::Identity(),
775 service_manager::InterfaceProviderSpec());
776
777 std::unique_ptr<service_manager::InterfaceProvider> remote_interfaces(
778 new service_manager::InterfaceProvider);
779 remote_interfaces->Bind(std::move(interfaces));
780 rph->SetRemoteInterfaces(std::move(remote_interfaces));
781 return registry;
782 }
783
784 } // namespace content 768 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/embedded_worker_test_helper.h ('k') | content/browser/utility_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698