blob: 563aa35f474d2cefc4441fe517c1b45570a74fc3 [file] [log] [blame]
// Copyright 2019 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 <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/threading/sequence_bound.h"
#include "services/service_manager/public/cpp/manifest.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_binding.h"
#include "services/service_manager/public/mojom/service.mojom.h"
namespace base {
class SequencedTaskRunner;
class Thread;
} // namespace base
namespace chromecast {
namespace external_mojo {
class ExternalMojoBroker;
// A Mojo service (intended to run within cast_shell or some other Chromium
// ServiceManager environment) that allows Mojo services built into external
// processes to interoperate with the Mojo services within cast_shell.
class BrokerService : public ::service_manager::Service {
static constexpr char const* kServiceName = "external_mojo_broker";
// Adds a manifest for an external Mojo service (ie, one that is running in
// a non-Chromium process). A manifest is only needed for external services
// that bind to Mojo services within cast_shell, or for external services that
// are bound to (used) by internal Mojo services. All external manifests must
// be added before GetExternalMojoBrokerManifest() is called (otherwise they
// will not be included in the broker manifest, and so the relevant
// permissions will not be set correctly).
static void AddExternalServiceManifest(service_manager::Manifest manifest);
// Returns the manifest for this service.
static const service_manager::Manifest& GetManifest();
explicit BrokerService(service_manager::mojom::ServiceRequest request);
~BrokerService() override;
service_manager::ServiceBinding service_binding_;
std::unique_ptr<base::Thread> io_thread_;
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
base::SequenceBound<ExternalMojoBroker> broker_;
} // namespace external_mojo
} // namespace chromecast