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

Unified Diff: content/browser/service_worker/embedded_worker_test_helper.cc

Issue 2606593002: [ServiceWorker] Associate interfaces.
Patch Set: Fix unit tests Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/embedded_worker_test_helper.cc
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc
index 004f9e418e7c1b9b6c78736cb7685b3a2b6467c1..690a569c011824a9402d9d8cb9c078afb5474fe0 100644
--- a/content/browser/service_worker/embedded_worker_test_helper.cc
+++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -26,9 +26,11 @@
#include "content/common/service_worker/service_worker_messages.h"
#include "content/common/service_worker/service_worker_utils.h"
#include "content/public/common/push_event_payload.h"
+#include "content/public/test/fake_associated_interface_provider_impl.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_associated_binding.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "services/service_manager/public/cpp/interface_registry.h"
@@ -66,9 +68,11 @@ class EmbeddedWorkerTestHelper::MockEmbeddedWorkerSetup
: helper_(helper) {}
static void Create(const base::WeakPtr<EmbeddedWorkerTestHelper>& helper,
- mojom::EmbeddedWorkerSetupRequest request) {
- mojo::MakeStrongBinding(base::MakeUnique<MockEmbeddedWorkerSetup>(helper),
- std::move(request));
+ mojo::ScopedInterfaceEndpointHandle handle) {
+ mojo::MakeStrongAssociatedBinding(
+ base::MakeUnique<MockEmbeddedWorkerSetup>(helper),
+ mojo::MakeAssociatedRequest<mojom::EmbeddedWorkerSetup>(
+ std::move(handle)));
}
void AttachServiceWorkerEventDispatcher(
@@ -133,7 +137,7 @@ void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StopWorker(
// static
void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::Bind(
const base::WeakPtr<EmbeddedWorkerTestHelper>& helper,
- mojom::EmbeddedWorkerInstanceClientRequest request) {
+ mojo::ScopedInterfaceEndpointHandle handle) {
std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>* clients =
helper->mock_instance_clients();
size_t next_client_index = helper->mock_instance_clients_next_index_;
@@ -148,7 +152,9 @@ void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::Bind(
clients->at(next_client_index);
helper->mock_instance_clients_next_index_ = next_client_index + 1;
if (client)
- client->binding_.Bind(std::move(request));
+ client->binding_.Bind(
+ mojo::MakeAssociatedRequest<mojom::EmbeddedWorkerInstanceClient>(
+ std::move(handle)));
}
class EmbeddedWorkerTestHelper::MockServiceWorkerEventDispatcher
@@ -228,11 +234,9 @@ EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
registry()->AddChildProcessSender(mock_render_process_id_, this,
NewMessagePortMessageFilter());
- // Setup process level interface registry.
- render_process_interface_registry_ =
- CreateInterfaceRegistry(render_process_host_.get());
- new_render_process_interface_registry_ =
- CreateInterfaceRegistry(new_render_process_host_.get());
+ // Override process level remote associated interfaces.
+ OverrideRemoteAssociatedInterfaces(render_process_host_.get());
+ OverrideRemoteAssociatedInterfaces(new_render_process_host_.get());
}
EmbeddedWorkerTestHelper::~EmbeddedWorkerTestHelper() {
@@ -569,26 +573,17 @@ EmbeddedWorkerTestHelper::NewMessagePortMessageFilter() {
return filter.get();
}
-std::unique_ptr<service_manager::InterfaceRegistry>
-EmbeddedWorkerTestHelper::CreateInterfaceRegistry(MockRenderProcessHost* rph) {
- auto registry =
- base::MakeUnique<service_manager::InterfaceRegistry>(std::string());
- registry->AddInterface(
- base::Bind(&MockEmbeddedWorkerSetup::Create, AsWeakPtr()));
- registry->AddInterface(
- base::Bind(&MockEmbeddedWorkerInstanceClient::Bind, AsWeakPtr()));
+void EmbeddedWorkerTestHelper::OverrideRemoteAssociatedInterfaces(
+ MockRenderProcessHost* rph) {
+ AssociatedInterfaceProvider* provider =
+ rph->GetAssociatedInterfaceProviderForTesting();
- service_manager::mojom::InterfaceProviderPtr interfaces;
- registry->Bind(mojo::MakeRequest(&interfaces), service_manager::Identity(),
- service_manager::InterfaceProviderSpec(),
- service_manager::Identity(),
- service_manager::InterfaceProviderSpec());
-
- std::unique_ptr<service_manager::InterfaceProvider> remote_interfaces(
- new service_manager::InterfaceProvider);
- remote_interfaces->Bind(std::move(interfaces));
- rph->SetRemoteInterfaces(std::move(remote_interfaces));
- return registry;
+ provider->OverrideBinderForTesting(
+ mojom::EmbeddedWorkerInstanceClient::Name_,
+ base::Bind(&MockEmbeddedWorkerInstanceClient::Bind, AsWeakPtr()));
+ provider->OverrideBinderForTesting(
+ mojom::EmbeddedWorkerSetup::Name_,
+ base::Bind(&MockEmbeddedWorkerSetup::Create, AsWeakPtr()));
}
} // namespace content
« no previous file with comments | « content/browser/service_worker/embedded_worker_test_helper.h ('k') | content/public/browser/render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698