blob: b275b7e45dce3fba56dda05cb19c2ea68d07590c [file] [log] [blame]
Ken Turneredb93932018-02-14 05:27:31 +11001// Copyright 2018 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef ML_DAEMON_H_
6#define ML_DAEMON_H_
7
Andrew Moylanef116f92018-04-11 15:12:38 +10008#include <brillo/daemons/dbus_daemon.h>
Ken Turneredb93932018-02-14 05:27:31 +11009#include <dbus/exported_object.h>
10
11namespace dbus {
12class MethodCall;
13} // namespace dbus
14
15namespace ml {
16
Andrew Moylanef116f92018-04-11 15:12:38 +100017class Daemon : public brillo::DBusDaemon {
Ken Turneredb93932018-02-14 05:27:31 +110018 public:
19 Daemon();
20 ~Daemon() override;
21
22 protected:
23 int OnInit() override;
24
25 private:
26 // This function initializes the D-Bus service. The primary function of the
27 // D-Bus interface is to receive a FD from the Chrome process so that we can
28 // bootstrap a Mojo IPC channel. Since we should expect requests for client
29 // registration to occur as soon as the D-Bus channel is up, this
30 // initialization should be the last thing that happens in Daemon::OnInit().
31 void InitDBus();
32
Andrew Moylanef116f92018-04-11 15:12:38 +100033 // Handles org.chromium.BootstrapMojoConnection D-Bus method calls.
Ken Turneredb93932018-02-14 05:27:31 +110034 void BootstrapMojoConnection(
35 dbus::MethodCall* method_call,
36 dbus::ExportedObject::ResponseSender response_sender);
37
Andrew Moylanef116f92018-04-11 15:12:38 +100038 // Must be last class member.
39 base::WeakPtrFactory<Daemon> weak_ptr_factory_;
Ken Turneredb93932018-02-14 05:27:31 +110040};
41
42} // namespace ml
43
44#endif // ML_DAEMON_H_