blob: 0efdc08b33769194336748afc2be2327fbdc6a53 [file] [log] [blame]
Peter Qiua522e002015-10-13 13:21:58 -07001//
2// Copyright (C) 2015 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
Peter Qiu58083962015-11-05 14:29:50 -080017#ifndef APMANAGER_DBUS_DBUS_CONTROL_H_
18#define APMANAGER_DBUS_DBUS_CONTROL_H_
Peter Qiua522e002015-10-13 13:21:58 -070019
20#include <base/macros.h>
Peter Qiu0d70fa72015-11-12 10:31:40 -080021#include <brillo/dbus/exported_object_manager.h>
Peter Qiua522e002015-10-13 13:21:58 -070022#include <dbus/bus.h>
23
24#include "apmanager/control_interface.h"
Peter Qiu0d70fa72015-11-12 10:31:40 -080025#include "apmanager/manager.h"
Peter Qiua522e002015-10-13 13:21:58 -070026
27namespace apmanager {
28
29// D-Bus control interface for IPC through D-Bus.
30class DBusControl : public ControlInterface {
31 public:
Peter Qiu0d70fa72015-11-12 10:31:40 -080032 DBusControl();
Peter Qiua522e002015-10-13 13:21:58 -070033 ~DBusControl() override;
34
35 // Inheritted from ControlInterface.
Peter Qiu0d70fa72015-11-12 10:31:40 -080036 void Init() override;
37 void Shutdown() override;
Peter Qiua522e002015-10-13 13:21:58 -070038 std::unique_ptr<FirewallProxyInterface> CreateFirewallProxy(
39 const base::Closure& service_appeared_callback,
40 const base::Closure& service_vanished_callback) override;
41 std::unique_ptr<ShillProxyInterface> CreateShillProxy(
42 const base::Closure& service_appeared_callback,
43 const base::Closure& service_vanished_callback) override;
44
45 private:
Peter Qiu0d70fa72015-11-12 10:31:40 -080046 // Invoked when D-Bus objects for both ObjectManager and Manager
47 // are registered to the bus.
48 void OnObjectRegistrationCompleted(bool registration_success);
49
Peter Qiua522e002015-10-13 13:21:58 -070050 // NOTE: No dedicated bus is needed for the proxies, since the proxies
51 // being created here doesn't listen for any broadcast signals.
52 // Use a dedicated bus for the proxies if this condition is not true
53 // anymore.
54 scoped_refptr<dbus::Bus> bus_;
Peter Qiu0d70fa72015-11-12 10:31:40 -080055 std::unique_ptr<brillo::dbus_utils::ExportedObjectManager> object_manager_;
56 std::unique_ptr<Manager> manager_;
57
Peter Qiua522e002015-10-13 13:21:58 -070058 DISALLOW_COPY_AND_ASSIGN(DBusControl);
59};
60
61} // namespace apmanager
62
Peter Qiu58083962015-11-05 14:29:50 -080063#endif // APMANAGER_DBUS_DBUS_CONTROL_H_