blob: 56c8d993657dd9b2e3e02dcd56ce9308a7517151 [file] [log] [blame]
// Copyright 2018 The Chromium OS 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 SHILL_DBUS_DBUS_CONTROL_H_
#define SHILL_DBUS_DBUS_CONTROL_H_
#include <memory>
#include <string>
#include <brillo/dbus/exported_object_manager.h>
#include "shill/control_interface.h"
namespace shill {
class EventDispatcher;
class Manager;
class DBusControl : public ControlInterface {
public:
explicit DBusControl(EventDispatcher* dispatcher);
~DBusControl() override;
void RegisterManagerObject(
Manager* manager,
const base::Closure& registration_done_callback) override;
std::unique_ptr<DeviceAdaptorInterface> CreateDeviceAdaptor(
Device* device) override;
std::unique_ptr<IPConfigAdaptorInterface> CreateIPConfigAdaptor(
IPConfig* ipconfig) override;
std::unique_ptr<ManagerAdaptorInterface> CreateManagerAdaptor(
Manager* manager) override;
std::unique_ptr<ProfileAdaptorInterface> CreateProfileAdaptor(
Profile* profile) override;
std::unique_ptr<RpcTaskAdaptorInterface> CreateRpcTaskAdaptor(
RpcTask* task) override;
std::unique_ptr<ServiceAdaptorInterface> CreateServiceAdaptor(
Service* service) override;
#ifndef DISABLE_VPN
std::unique_ptr<ThirdPartyVpnAdaptorInterface> CreateThirdPartyVpnAdaptor(
ThirdPartyVpnDriver* driver) override;
#endif
const RpcIdentifier& NullRpcIdentifier() override;
// The caller retains ownership of 'delegate'. It must not be deleted before
// the proxy.
std::unique_ptr<PowerManagerProxyInterface> CreatePowerManagerProxy(
PowerManagerProxyDelegate* delegate,
const base::Closure& service_appeared_callback,
const base::Closure& service_vanished_callback) override;
#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X)
std::unique_ptr<SupplicantProcessProxyInterface> CreateSupplicantProcessProxy(
const base::Closure& service_appeared_callback,
const base::Closure& service_vanished_callback) override;
std::unique_ptr<SupplicantInterfaceProxyInterface>
CreateSupplicantInterfaceProxy(SupplicantEventDelegateInterface* delegate,
const RpcIdentifier& object_path) override;
std::unique_ptr<SupplicantNetworkProxyInterface> CreateSupplicantNetworkProxy(
const RpcIdentifier& object_path) override;
#endif // DISABLE_WIFI || DISABLE_WIRED_8021X
#if !defined(DISABLE_WIFI)
// See comment in supplicant_bss_proxy.h, about bare pointer.
std::unique_ptr<SupplicantBSSProxyInterface> CreateSupplicantBSSProxy(
WiFiEndpoint* wifi_endpoint, const RpcIdentifier& object_path) override;
#endif // DISABLE_WIFI
std::unique_ptr<UpstartProxyInterface> CreateUpstartProxy() override;
std::unique_ptr<DHCPCDListenerInterface> CreateDHCPCDListener(
DHCPProvider* provider) override;
std::unique_ptr<DHCPProxyInterface> CreateDHCPProxy(
const std::string& service) override;
#if !defined(DISABLE_CELLULAR)
std::unique_ptr<DBusPropertiesProxy> CreateDBusPropertiesProxy(
const RpcIdentifier& path, const std::string& service) override;
std::unique_ptr<DBusObjectManagerProxyInterface> CreateDBusObjectManagerProxy(
const RpcIdentifier& path,
const std::string& service,
const base::Closure& service_appeared_callback,
const base::Closure& service_vanished_callback) override;
// Proxies for ModemManager1 interfaces
std::unique_ptr<mm1::Mm1ProxyInterface> CreateMM1Proxy(
const std::string& service) override;
std::unique_ptr<mm1::ModemLocationProxyInterface> CreateMM1ModemLocationProxy(
const RpcIdentifier& path, const std::string& service) override;
std::unique_ptr<mm1::ModemModem3gppProxyInterface>
CreateMM1ModemModem3gppProxy(const RpcIdentifier& path,
const std::string& service) override;
std::unique_ptr<mm1::ModemModemCdmaProxyInterface>
CreateMM1ModemModemCdmaProxy(const RpcIdentifier& path,
const std::string& service) override;
std::unique_ptr<mm1::ModemProxyInterface> CreateMM1ModemProxy(
const RpcIdentifier& path, const std::string& service) override;
std::unique_ptr<mm1::ModemSignalProxyInterface> CreateMM1ModemSignalProxy(
const RpcIdentifier& path, const std::string& service) override;
std::unique_ptr<mm1::ModemSimpleProxyInterface> CreateMM1ModemSimpleProxy(
const RpcIdentifier& path, const std::string& service) override;
std::unique_ptr<mm1::SimProxyInterface> CreateMM1SimProxy(
const RpcIdentifier& path, const std::string& service) override;
#endif // DISABLE_CELLULAR
private:
void OnDBusServiceRegistered(
const base::Callback<void(bool)>& completion_action, bool success);
void TakeServiceOwnership(bool success);
static const char kNullPath[];
// Use separate bus connection for adaptors and proxies. This allows the
// proxy to receive all broadcast signal messages that it is interested in.
// Refer to crbug.com/446837 for more info.
scoped_refptr<dbus::Bus> adaptor_bus_;
scoped_refptr<dbus::Bus> proxy_bus_;
EventDispatcher* dispatcher_;
RpcIdentifier null_identifier_;
base::Closure registration_done_callback_;
};
} // namespace shill
#endif // SHILL_DBUS_DBUS_CONTROL_H_