Ken Turner | edb9393 | 2018-02-14 05:27:31 +1100 | [diff] [blame] | 1 | // 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 Moylan | ef116f9 | 2018-04-11 15:12:38 +1000 | [diff] [blame^] | 8 | #include <brillo/daemons/dbus_daemon.h> |
Ken Turner | edb9393 | 2018-02-14 05:27:31 +1100 | [diff] [blame] | 9 | #include <dbus/exported_object.h> |
| 10 | |
| 11 | namespace dbus { |
| 12 | class MethodCall; |
| 13 | } // namespace dbus |
| 14 | |
| 15 | namespace ml { |
| 16 | |
Andrew Moylan | ef116f9 | 2018-04-11 15:12:38 +1000 | [diff] [blame^] | 17 | class Daemon : public brillo::DBusDaemon { |
Ken Turner | edb9393 | 2018-02-14 05:27:31 +1100 | [diff] [blame] | 18 | 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 Moylan | ef116f9 | 2018-04-11 15:12:38 +1000 | [diff] [blame^] | 33 | // Handles org.chromium.BootstrapMojoConnection D-Bus method calls. |
Ken Turner | edb9393 | 2018-02-14 05:27:31 +1100 | [diff] [blame] | 34 | void BootstrapMojoConnection( |
| 35 | dbus::MethodCall* method_call, |
| 36 | dbus::ExportedObject::ResponseSender response_sender); |
| 37 | |
Andrew Moylan | ef116f9 | 2018-04-11 15:12:38 +1000 | [diff] [blame^] | 38 | // Must be last class member. |
| 39 | base::WeakPtrFactory<Daemon> weak_ptr_factory_; |
Ken Turner | edb9393 | 2018-02-14 05:27:31 +1100 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | } // namespace ml |
| 43 | |
| 44 | #endif // ML_DAEMON_H_ |