Commit a5d0b997 authored by Sharon Yang's avatar Sharon Yang Committed by Commit Bot

[Fuchsia] Remove calls to ServiceDirectoryClient

Since base::ServiceDirectoryClient is being deprecated, remove the last
of the references to this class and replace with sys::ServiceDirectory.

Some references to the class are still in startup_context.h/cc because
there are external dependencies.

Testing: CQ.

Bug: 974072
Change-Id: I55f6166792c86459fac7ad46d5cf733060394af9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894154
Commit-Queue: Sharon Yang <yangsharon@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712302}
parent 8c0115c7
...@@ -34,8 +34,7 @@ void ServiceProviderImpl::AddBinding( ...@@ -34,8 +34,7 @@ void ServiceProviderImpl::AddBinding(
void ServiceProviderImpl::ConnectToService(std::string service_name, void ServiceProviderImpl::ConnectToService(std::string service_name,
zx::channel client_handle) { zx::channel client_handle) {
directory_.ConnectToServiceUnsafe(service_name.c_str(), directory_.Connect(service_name.c_str(), std::move(client_handle));
std::move(client_handle));
} }
void ServiceProviderImpl::SetOnLastClientDisconnectedClosure( void ServiceProviderImpl::SetOnLastClientDisconnectedClosure(
......
...@@ -9,12 +9,13 @@ ...@@ -9,12 +9,13 @@
#include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h>
#include <lib/fidl/cpp/binding_set.h> #include <lib/fidl/cpp/binding_set.h>
#include <lib/fidl/cpp/interface_handle.h> #include <lib/fidl/cpp/interface_handle.h>
#include <lib/sys/cpp/component_context.h>
#include <lib/zx/channel.h> #include <lib/zx/channel.h>
#include <string> #include <string>
#include "base/base_export.h" #include "base/base_export.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/fuchsia/service_directory_client.h" #include "base/fuchsia/default_context.h"
#include "base/macros.h" #include "base/macros.h"
namespace sys { namespace sys {
...@@ -56,7 +57,7 @@ class BASE_EXPORT ServiceProviderImpl : public ::fuchsia::sys::ServiceProvider { ...@@ -56,7 +57,7 @@ class BASE_EXPORT ServiceProviderImpl : public ::fuchsia::sys::ServiceProvider {
void OnBindingSetEmpty(); void OnBindingSetEmpty();
const ServiceDirectoryClient directory_; const sys::ServiceDirectory directory_;
fidl::BindingSet<::fuchsia::sys::ServiceProvider> bindings_; fidl::BindingSet<::fuchsia::sys::ServiceProvider> bindings_;
base::OnceClosure on_last_client_disconnected_; base::OnceClosure on_last_client_disconnected_;
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "fuchsia/base/agent_impl.h" #include "fuchsia/base/agent_impl.h"
#include <lib/sys/cpp/component_context.h>
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/fuchsia/testfidl/cpp/fidl.h" #include "base/fuchsia/testfidl/cpp/fidl.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -76,8 +78,8 @@ class AgentImplTest : public ::testing::Test { ...@@ -76,8 +78,8 @@ class AgentImplTest : public ::testing::Test {
fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_WRITABLE, fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_WRITABLE,
directory.NewRequest().TakeChannel()); directory.NewRequest().TakeChannel());
services_client_ = std::make_unique<base::fuchsia::ServiceDirectoryClient>( services_client_ =
std::move(directory)); std::make_unique<sys::ServiceDirectory>(std::move(directory));
} }
fuchsia::modular::AgentPtr CreateAgentAndConnect() { fuchsia::modular::AgentPtr CreateAgentAndConnect() {
...@@ -86,7 +88,7 @@ class AgentImplTest : public ::testing::Test { ...@@ -86,7 +88,7 @@ class AgentImplTest : public ::testing::Test {
&services_, base::BindRepeating(&AgentImplTest::OnComponentConnect, &services_, base::BindRepeating(&AgentImplTest::OnComponentConnect,
base::Unretained(this))); base::Unretained(this)));
fuchsia::modular::AgentPtr agent; fuchsia::modular::AgentPtr agent;
services_client_->ConnectToService(agent.NewRequest()); services_client_->Connect(agent.NewRequest());
return agent; return agent;
} }
...@@ -116,7 +118,7 @@ class AgentImplTest : public ::testing::Test { ...@@ -116,7 +118,7 @@ class AgentImplTest : public ::testing::Test {
base::test::SingleThreadTaskEnvironment task_environment_{ base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::IO}; base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
sys::OutgoingDirectory services_; sys::OutgoingDirectory services_;
std::unique_ptr<base::fuchsia::ServiceDirectoryClient> services_client_; std::unique_ptr<sys::ServiceDirectory> services_client_;
std::unique_ptr<AgentImpl> agent_impl_; std::unique_ptr<AgentImpl> agent_impl_;
...@@ -148,7 +150,7 @@ TEST_F(AgentImplTest, PublishAndUnpublish) { ...@@ -148,7 +150,7 @@ TEST_F(AgentImplTest, PublishAndUnpublish) {
// Verify that the Agent service is no longer available. // Verify that the Agent service is no longer available.
cr_fuchsia::ResultReceiver<zx_status_t> client_disconnect_status2; cr_fuchsia::ResultReceiver<zx_status_t> client_disconnect_status2;
services_client_->ConnectToService(agent.NewRequest()); services_client_->Connect(agent.NewRequest());
agent.set_error_handler(cr_fuchsia::CallbackToFitFunction( agent.set_error_handler(cr_fuchsia::CallbackToFitFunction(
client_disconnect_status2.GetReceiveCallback())); client_disconnect_status2.GetReceiveCallback()));
......
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
namespace cr_fuchsia { namespace cr_fuchsia {
AgentManager::AgentManager( AgentManager::AgentManager(const sys::ServiceDirectory* incoming)
const base::fuchsia::ServiceDirectoryClient* incoming)
: component_context_( : component_context_(
incoming->ConnectToService<fuchsia::modular::ComponentContext>()) {} incoming->Connect<fuchsia::modular::ComponentContext>()) {}
AgentManager::~AgentManager() = default; AgentManager::~AgentManager() = default;
......
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
#include <fuchsia/modular/cpp/fidl.h> #include <fuchsia/modular/cpp/fidl.h>
#include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h>
#include <lib/sys/cpp/component_context.h>
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/fuchsia/service_directory_client.h" #include "base/fuchsia/default_context.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
namespace cr_fuchsia { namespace cr_fuchsia {
// Connects to the ComponentContext service from the supplied // Connects to the ComponentContext service from the supplied ServiceDirectory,
// ServiceDirectoryClient, and uses it to connect-to and manage one or more // and uses it to connect-to and manage one or more Agents used by the caller.
// Agents used by the caller.
class BASE_EXPORT AgentManager { class BASE_EXPORT AgentManager {
public: public:
explicit AgentManager(const base::fuchsia::ServiceDirectoryClient* incoming); explicit AgentManager(const sys::ServiceDirectory* incoming);
~AgentManager(); ~AgentManager();
// Connects to |agent| so satisfying the specified |request|. // Connects to |agent| so satisfying the specified |request|.
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/fuchsia/default_context.h" #include "base/fuchsia/default_context.h"
#include "base/fuchsia/file_utils.h" #include "base/fuchsia/file_utils.h"
#include "base/fuchsia/service_directory_client.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "fuchsia/base/fit_adapter.h" #include "fuchsia/base/fit_adapter.h"
...@@ -53,9 +52,9 @@ class WebEngineDebugIntegrationTest : public testing::Test { ...@@ -53,9 +52,9 @@ class WebEngineDebugIntegrationTest : public testing::Test {
// There should only be one instance of WebEngine in the realm. // There should only be one instance of WebEngine in the realm.
ASSERT_TRUE(file_enum.Next().empty()); ASSERT_TRUE(file_enum.Next().empty());
debug_dir_ = std::make_unique<base::fuchsia::ServiceDirectoryClient>( debug_dir_ = std::make_unique<sys::ServiceDirectory>(
base::fuchsia::OpenDirectory(chromium_path.Append("out/debug"))); base::fuchsia::OpenDirectory(chromium_path.Append("out/debug")));
debug_ = debug_dir_->ConnectToServiceSync<fuchsia::web::Debug>(); debug_dir_->Connect(debug_.NewRequest());
// Attach the DevToolsListener. EnableDevTools has an acknowledgement // Attach the DevToolsListener. EnableDevTools has an acknowledgement
// callback so the listener will have been added after this call returns. // callback so the listener will have been added after this call returns.
...@@ -101,7 +100,7 @@ class WebEngineDebugIntegrationTest : public testing::Test { ...@@ -101,7 +100,7 @@ class WebEngineDebugIntegrationTest : public testing::Test {
TestDebugListener dev_tools_listener_; TestDebugListener dev_tools_listener_;
fidl::Binding<fuchsia::web::DevToolsListener> dev_tools_listener_binding_; fidl::Binding<fuchsia::web::DevToolsListener> dev_tools_listener_binding_;
std::unique_ptr<base::fuchsia::ServiceDirectoryClient> debug_dir_; std::unique_ptr<sys::ServiceDirectory> debug_dir_;
fuchsia::web::ContextProviderPtr web_context_provider_; fuchsia::web::ContextProviderPtr web_context_provider_;
fuchsia::web::DebugSyncPtr debug_; fuchsia::web::DebugSyncPtr debug_;
...@@ -197,7 +196,7 @@ TEST_F(WebEngineDebugIntegrationTest, MultipleDebugClients) { ...@@ -197,7 +196,7 @@ TEST_F(WebEngineDebugIntegrationTest, MultipleDebugClients) {
// Connect a second Debug interface. // Connect a second Debug interface.
fuchsia::web::DebugSyncPtr debug2; fuchsia::web::DebugSyncPtr debug2;
debug2 = debug_dir_->ConnectToServiceSync<fuchsia::web::Debug>(); debug_dir_->Connect(debug2.NewRequest());
TestDebugListener dev_tools_listener2; TestDebugListener dev_tools_listener2;
fidl::Binding<fuchsia::web::DevToolsListener> dev_tools_listener_binding2( fidl::Binding<fuchsia::web::DevToolsListener> dev_tools_listener_binding2(
&dev_tools_listener2); &dev_tools_listener2);
......
...@@ -161,6 +161,7 @@ test("cast_runner_integration_tests") { ...@@ -161,6 +161,7 @@ test("cast_runner_integration_tests") {
"//net:test_support", "//net:test_support",
"//testing/gtest", "//testing/gtest",
"//third_party/fuchsia-sdk/sdk:modular", "//third_party/fuchsia-sdk/sdk:modular",
"//third_party/fuchsia-sdk/sdk:sys_cpp",
] ]
package_deps = [ [ package_deps = [ [
"//fuchsia/engine:web_engine", "//fuchsia/engine:web_engine",
......
...@@ -101,7 +101,7 @@ void CastRunner::StartComponent( ...@@ -101,7 +101,7 @@ void CastRunner::StartComponent(
pending_component->startup_context = pending_component->startup_context =
std::make_unique<base::fuchsia::StartupContext>(std::move(startup_info)); std::make_unique<base::fuchsia::StartupContext>(std::move(startup_info));
pending_component->agent_manager = std::make_unique<cr_fuchsia::AgentManager>( pending_component->agent_manager = std::make_unique<cr_fuchsia::AgentManager>(
pending_component->startup_context->incoming_services()); pending_component->startup_context->component_context()->svc().get());
pending_component->controller_request = std::move(controller_request); pending_component->controller_request = std::move(controller_request);
// Get binding details from the Agent. // Get binding details from the Agent.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <fuchsia/modular/cpp/fidl.h> #include <fuchsia/modular/cpp/fidl.h>
#include <lib/fdio/directory.h> #include <lib/fdio/directory.h>
#include <lib/fidl/cpp/binding.h> #include <lib/fidl/cpp/binding.h>
#include <lib/sys/cpp/component_context.h>
#include <lib/zx/channel.h> #include <lib/zx/channel.h>
#include "base/base_paths_fuchsia.h" #include "base/base_paths_fuchsia.h"
...@@ -235,8 +236,7 @@ class CastRunnerIntegrationTest : public testing::Test { ...@@ -235,8 +236,7 @@ class CastRunnerIntegrationTest : public testing::Test {
ZX_OK); ZX_OK);
component_services_client_ = component_services_client_ =
std::make_unique<base::fuchsia::ServiceDirectoryClient>( std::make_unique<sys::ServiceDirectory>(std::move(svc_directory));
std::move(svc_directory));
// Place the ServiceDirectory in the |flat_namespace|. // Place the ServiceDirectory in the |flat_namespace|.
startup_info.flat_namespace.paths.emplace_back( startup_info.flat_namespace.paths.emplace_back(
...@@ -288,8 +288,7 @@ class CastRunnerIntegrationTest : public testing::Test { ...@@ -288,8 +288,7 @@ class CastRunnerIntegrationTest : public testing::Test {
// Incoming service directory, ComponentContext and per-component state. // Incoming service directory, ComponentContext and per-component state.
sys::OutgoingDirectory component_services_; sys::OutgoingDirectory component_services_;
std::unique_ptr<cr_fuchsia::FakeComponentContext> component_context_; std::unique_ptr<cr_fuchsia::FakeComponentContext> component_context_;
std::unique_ptr<base::fuchsia::ServiceDirectoryClient> std::unique_ptr<sys::ServiceDirectory> component_services_client_;
component_services_client_;
FakeComponentState* component_state_ = nullptr; FakeComponentState* component_state_ = nullptr;
// ServiceDirectory into which the CastRunner will publish itself. // ServiceDirectory into which the CastRunner will publish itself.
...@@ -507,7 +506,7 @@ TEST_F(CastRunnerIntegrationTest, Lifecycle) { ...@@ -507,7 +506,7 @@ TEST_F(CastRunnerIntegrationTest, Lifecycle) {
StartCastComponent(base::StringPrintf("cast:%s", kCastChannelAppId)); StartCastComponent(base::StringPrintf("cast:%s", kCastChannelAppId));
fuchsia::modular::LifecyclePtr lifecycle; fuchsia::modular::LifecyclePtr lifecycle;
component_services_client_->ConnectToService(lifecycle.NewRequest()); component_services_client_->Connect(lifecycle.NewRequest());
lifecycle->Terminate(); lifecycle->Terminate();
base::RunLoop run_loop; base::RunLoop run_loop;
......
...@@ -95,12 +95,6 @@ class WebComponent : public fuchsia::sys::ComponentController, ...@@ -95,12 +95,6 @@ class WebComponent : public fuchsia::sys::ComponentController,
// If running as a Mod then these are used to e.g. RemoveSelfFromStory(). // If running as a Mod then these are used to e.g. RemoveSelfFromStory().
fuchsia::modular::ModuleContextPtr module_context_; fuchsia::modular::ModuleContextPtr module_context_;
// Incoming services provided at component creation.
std::unique_ptr<base::fuchsia::ServiceDirectoryClient> additional_services_;
// The names of services provided at component creation.
std::vector<std::string> additional_service_names_;
// Objects used for binding and exporting the ViewProvider service. // Objects used for binding and exporting the ViewProvider service.
std::unique_ptr< std::unique_ptr<
base::fuchsia::ScopedServiceBinding<fuchsia::ui::app::ViewProvider>> base::fuchsia::ScopedServiceBinding<fuchsia::ui::app::ViewProvider>>
......
...@@ -133,10 +133,8 @@ TEST_F(WebRunnerSmokeTest, LifecycleTerminate) { ...@@ -133,10 +133,8 @@ TEST_F(WebRunnerSmokeTest, LifecycleTerminate) {
fuchsia::sys::ComponentControllerPtr controller; fuchsia::sys::ComponentControllerPtr controller;
launcher->CreateComponent(std::move(launch_info), controller.NewRequest()); launcher->CreateComponent(std::move(launch_info), controller.NewRequest());
base::fuchsia::ServiceDirectoryClient component_services( sys::ServiceDirectory component_services(std::move(directory));
std::move(directory)); auto lifecycle = component_services.Connect<fuchsia::modular::Lifecycle>();
auto lifecycle =
component_services.ConnectToService<fuchsia::modular::Lifecycle>();
ASSERT_TRUE(lifecycle); ASSERT_TRUE(lifecycle);
// Terminate() the component, and expect that |controller| disconnects us. // Terminate() the component, and expect that |controller| disconnects us.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment