Commit ee1b3a33 authored by Wez's avatar Wez Committed by Commit Bot

[fuchsia] Remove base::fuchsia::ServiceDirectory.

base::fuchsia::ServiceDirectory has been replaced with the Fuchsia
sys::OutgoingDirectory, so remove the old #includes.

Also add some missing //base/bind.h #includes, revealed by this change.

Bug: 974072
Change-Id: I757e9980b563dcf991f2c83e67ad33cc3294b906
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066974
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749799}
parent f1fd3d24
...@@ -1569,8 +1569,6 @@ jumbo_component("base") { ...@@ -1569,8 +1569,6 @@ jumbo_component("base") {
"fuchsia/intl_profile_watcher.h", "fuchsia/intl_profile_watcher.h",
"fuchsia/scoped_service_binding.cc", "fuchsia/scoped_service_binding.cc",
"fuchsia/scoped_service_binding.h", "fuchsia/scoped_service_binding.h",
"fuchsia/service_directory.cc",
"fuchsia/service_directory.h",
"fuchsia/service_provider_impl.cc", "fuchsia/service_provider_impl.cc",
"fuchsia/service_provider_impl.h", "fuchsia/service_provider_impl.h",
"fuchsia/startup_context.cc", "fuchsia/startup_context.cc",
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include <lib/fidl/cpp/binding.h> #include <lib/fidl/cpp/binding.h>
#include <lib/fidl/cpp/binding_set.h> #include <lib/fidl/cpp/binding_set.h>
#include <lib/zx/channel.h>
#include "base/base_export.h" #include "base/base_export.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/fuchsia/service_directory.h"
namespace sys { namespace sys {
class OutgoingDirectory; class OutgoingDirectory;
...@@ -67,11 +67,6 @@ class ScopedServiceBinding : public internal::ScopedServiceBindingBase { ...@@ -67,11 +67,6 @@ class ScopedServiceBinding : public internal::ScopedServiceBindingBase {
fit::bind_member(this, &ScopedServiceBinding::BindClient)); fit::bind_member(this, &ScopedServiceBinding::BindClient));
} }
// TODO(crbug.com/974072): Remove this constructor once all code has been
// migrated from base::fuchsia::ServiceDirectory to sys::OutgoingDirectory.
ScopedServiceBinding(ServiceDirectory* service_directory, Interface* impl)
: ScopedServiceBinding(service_directory->outgoing_directory(), impl) {}
~ScopedServiceBinding() { UnregisterService(Interface::Name_); } ~ScopedServiceBinding() { UnregisterService(Interface::Name_); }
void SetOnLastClientCallback(base::OnceClosure on_last_client_callback) { void SetOnLastClientCallback(base::OnceClosure on_last_client_callback) {
...@@ -122,14 +117,6 @@ class ScopedSingleClientServiceBinding ...@@ -122,14 +117,6 @@ class ScopedSingleClientServiceBinding
fit::bind_member(this, &ScopedSingleClientServiceBinding::BindClient)); fit::bind_member(this, &ScopedSingleClientServiceBinding::BindClient));
} }
// TODO(crbug.com/974072): Remove this constructor once all code has been
// migrated from base::fuchsia::ServiceDirectory to sys::OutgoingDirectory.
ScopedSingleClientServiceBinding(ServiceDirectory* service_directory,
Interface* impl)
: ScopedSingleClientServiceBinding(
service_directory->outgoing_directory(),
impl) {}
~ScopedSingleClientServiceBinding() { UnregisterService(Interface::Name_); } ~ScopedSingleClientServiceBinding() { UnregisterService(Interface::Name_); }
typename Interface::EventSender_& events() { return binding_.events(); } typename Interface::EventSender_& events() { return binding_.events(); }
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/fuchsia/service_directory.h"
#include <lib/sys/cpp/component_context.h>
#include <lib/sys/cpp/outgoing_directory.h>
#include "base/fuchsia/default_context.h"
#include "base/fuchsia/fuchsia_logging.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop_current.h"
#include "base/no_destructor.h"
namespace base {
namespace fuchsia {
namespace {
std::unique_ptr<ServiceDirectory> CreateDefaultServiceDirectory() {
sys::OutgoingDirectory* outgoing =
ComponentContextForCurrentProcess()->outgoing().get();
outgoing->ServeFromStartupInfo();
return std::make_unique<ServiceDirectory>(outgoing);
}
} // namespace
ServiceDirectory::ServiceDirectory(
fidl::InterfaceRequest<::fuchsia::io::Directory> request) {
Initialize(std::move(request));
}
ServiceDirectory::ServiceDirectory(sys::OutgoingDirectory* directory)
: directory_(directory) {}
ServiceDirectory::ServiceDirectory() = default;
ServiceDirectory::~ServiceDirectory() = default;
// static
ServiceDirectory* ServiceDirectory::GetDefault() {
static NoDestructor<std::unique_ptr<ServiceDirectory>> directory(
CreateDefaultServiceDirectory());
return directory.get()->get();
}
void ServiceDirectory::Initialize(
fidl::InterfaceRequest<::fuchsia::io::Directory> request) {
DCHECK(!owned_directory_);
owned_directory_ = std::make_unique<sys::OutgoingDirectory>();
directory_ = owned_directory_.get();
directory_->GetOrCreateDirectory("svc")->Serve(
::fuchsia::io::OPEN_RIGHT_READABLE | ::fuchsia::io::OPEN_RIGHT_WRITABLE,
request.TakeChannel());
}
} // namespace fuchsia
} // namespace base
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_FUCHSIA_SERVICE_DIRECTORY_H_
#define BASE_FUCHSIA_SERVICE_DIRECTORY_H_
#include <fuchsia/io/cpp/fidl.h>
#include <lib/fidl/cpp/interface_handle.h>
#include <lib/zx/channel.h>
#include <string>
#include <utility>
#include "base/base_export.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/strings/string_piece.h"
namespace sys {
class OutgoingDirectory;
} // namespace sys
namespace base {
namespace fuchsia {
// Directory of FIDL services published for other processes to consume. Services
// published in this directory can be discovered from other processes by name.
// Normally this class should be used by creating a ScopedServiceBinding
// instance. This ensures that the service is unregistered when the
// implementation is destroyed. GetDefault() should be used to get the default
// ServiceDirectory for the current process. The default instance exports
// services via a channel supplied at process creation time.
// Debug services are published to a "debug" sub-directory only accessible by
// other services via the Hub.
//
// TODO(crbug.com/974072): Currently this class is just a wrapper around
// sys::OutgoingDirectory. Migrate all code to use sys::OutgoingDirectory and
// remove this class.
class BASE_EXPORT ServiceDirectory {
public:
// Responds to service requests over the supplied |request| channel.
explicit ServiceDirectory(
fidl::InterfaceRequest<::fuchsia::io::Directory> request);
// Wraps a sys::OutgoingDirectory. The |directory| must outlive
// the ServiceDirectory object.
explicit ServiceDirectory(sys::OutgoingDirectory* directory);
// Creates an uninitialized ServiceDirectory instance. Initialize must be
// called on the instance before any services can be registered. Unless you
// need separate construction & initialization for a ServiceDirectory member,
// use the all-in-one constructor above.
ServiceDirectory();
~ServiceDirectory();
// Returns default ServiceDirectory instance for the current process. It
// publishes services to the directory provided by the process creator.
static ServiceDirectory* GetDefault();
// Configures an uninitialized ServiceDirectory instance to service the
// supplied |directory_request| channel.
void Initialize(fidl::InterfaceRequest<::fuchsia::io::Directory> request);
sys::OutgoingDirectory* outgoing_directory() { return directory_; }
private:
std::unique_ptr<sys::OutgoingDirectory> owned_directory_;
sys::OutgoingDirectory* directory_;
DISALLOW_COPY_AND_ASSIGN(ServiceDirectory);
};
} // namespace fuchsia
} // namespace base
#endif // BASE_FUCHSIA_SERVICE_DIRECTORY_H_
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/fuchsia/default_context.h" #include "base/fuchsia/default_context.h"
#include "base/fuchsia/scoped_service_binding.h" #include "base/fuchsia/scoped_service_binding.h"
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "base/fuchsia/default_job.h" #include "base/fuchsia/default_job.h"
#include "base/fuchsia/file_utils.h" #include "base/fuchsia/file_utils.h"
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/fuchsia/service_directory.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/multiprocess_test.h" #include "base/test/multiprocess_test.h"
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <utility> #include <utility>
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/bind.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/message_loop/message_loop_current.h" #include "base/message_loop/message_loop_current.h"
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "base/fuchsia/service_directory.h"
#include "base/fuchsia/startup_context.h" #include "base/fuchsia/startup_context.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/message_loop/message_pump_for_io.h" #include "base/message_loop/message_pump_for_io.h"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/fuchsia/file_utils.h" #include "base/fuchsia/file_utils.h"
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h" #include "base/logging.h"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <lib/sys/cpp/component_context.h> #include <lib/sys/cpp/component_context.h>
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/fuchsia/default_context.h" #include "base/fuchsia/default_context.h"
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h" #include "base/logging.h"
......
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