Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 1 | // Copyright 2014 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 BUFFET_MANAGER_H_ |
| 6 | #define BUFFET_MANAGER_H_ |
| 7 | |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 8 | #include <map> |
Alex Vakulenko | 3379706 | 2014-05-12 15:55:25 -0700 | [diff] [blame] | 9 | #include <memory> |
| 10 | #include <string> |
| 11 | |
Alex Vakulenko | 132617a | 2014-09-04 08:59:43 -0700 | [diff] [blame] | 12 | #include <base/macros.h> |
Christopher Wiley | adb901d | 2014-05-07 09:58:45 -0700 | [diff] [blame] | 13 | #include <base/memory/weak_ptr.h> |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 14 | #include <base/values.h> |
Alex Vakulenko | 07216fe | 2014-09-19 15:31:09 -0700 | [diff] [blame] | 15 | #include <chromeos/dbus/data_serialization.h> |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 16 | #include <chromeos/dbus/dbus_object.h> |
Alex Vakulenko | a8b95bc | 2014-08-27 11:00:57 -0700 | [diff] [blame] | 17 | #include <chromeos/dbus/exported_property_set.h> |
| 18 | #include <chromeos/errors/error.h> |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 19 | |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 20 | #include "buffet/device_registration_info.h" |
Christopher Wiley | aa3f29c | 2014-03-27 14:51:26 -0700 | [diff] [blame] | 21 | |
Christopher Wiley | b5dd5ea | 2014-08-11 10:51:20 -0700 | [diff] [blame] | 22 | namespace chromeos { |
Christopher Wiley | adb901d | 2014-05-07 09:58:45 -0700 | [diff] [blame] | 23 | namespace dbus_utils { |
| 24 | class ExportedObjectManager; |
| 25 | } // namespace dbus_utils |
Christopher Wiley | b5dd5ea | 2014-08-11 10:51:20 -0700 | [diff] [blame] | 26 | } // namespace chromeos |
| 27 | |
| 28 | namespace buffet { |
| 29 | |
| 30 | class CommandManager; |
Alex Vakulenko | 07216fe | 2014-09-19 15:31:09 -0700 | [diff] [blame] | 31 | class StateManager; |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 32 | |
| 33 | // The Manager is responsible for global state of Buffet. It exposes |
| 34 | // interfaces which affect the entire device such as device registration and |
| 35 | // device state. |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 36 | class Manager final { |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 37 | public: |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 38 | explicit Manager( |
| 39 | const base::WeakPtr<chromeos::dbus_utils::ExportedObjectManager>& |
| 40 | object_manager); |
Alex Vakulenko | be9c383 | 2014-08-24 15:05:06 -0700 | [diff] [blame] | 41 | void RegisterAsync( |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 42 | const chromeos::dbus_utils::AsyncEventSequencer::CompletionAction& cb); |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 43 | |
| 44 | private: |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 45 | // DBus methods: |
Anton Muhin | 86d67fe | 2014-10-01 18:06:54 +0400 | [diff] [blame^] | 46 | // Handles calls to org.chromium.Buffet.Manager.StartDevice(). |
| 47 | void HandleStartDevice(chromeos::ErrorPtr* error); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 48 | // Handles calls to org.chromium.Buffet.Manager.CheckDeviceRegistered(). |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 49 | std::string HandleCheckDeviceRegistered(chromeos::ErrorPtr* error); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 50 | // Handles calls to org.chromium.Buffet.Manager.GetDeviceInfo(). |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 51 | std::string HandleGetDeviceInfo(chromeos::ErrorPtr* error); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 52 | // Handles calls to org.chromium.Buffet.Manager.StartRegisterDevice(). |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 53 | std::string HandleStartRegisterDevice(chromeos::ErrorPtr* error, |
| 54 | const std::map<std::string, |
Alex Vakulenko | a904434 | 2014-08-23 19:31:27 -0700 | [diff] [blame] | 55 | std::string>& params); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 56 | // Handles calls to org.chromium.Buffet.Manager.FinishRegisterDevice(). |
Anton Muhin | 532ff7e | 2014-09-29 23:21:21 +0400 | [diff] [blame] | 57 | std::string HandleFinishRegisterDevice(chromeos::ErrorPtr* error); |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 58 | // Handles calls to org.chromium.Buffet.Manager.UpdateState(). |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 59 | void HandleUpdateState(chromeos::ErrorPtr* error, |
Alex Vakulenko | 576c979 | 2014-09-22 16:49:45 -0700 | [diff] [blame] | 60 | const chromeos::VariantDictionary& property_set); |
Alex Vakulenko | 665c885 | 2014-09-11 16:57:24 -0700 | [diff] [blame] | 61 | // Handles calls to org.chromium.Buffet.Manager.AddCommand(). |
| 62 | void HandleAddCommand(chromeos::ErrorPtr* error, |
| 63 | const std::string& json_command); |
Christopher Wiley | b76eb29 | 2014-05-05 16:09:16 -0700 | [diff] [blame] | 64 | // Handles calls to org.chromium.Buffet.Manager.Test() |
Alex Vakulenko | 7a1dc0b | 2014-08-15 11:45:46 -0700 | [diff] [blame] | 65 | std::string HandleTestMethod(chromeos::ErrorPtr* error, |
| 66 | const std::string& message); |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 67 | |
Alex Vakulenko | f2784de | 2014-08-15 11:49:35 -0700 | [diff] [blame] | 68 | chromeos::dbus_utils::DBusObject dbus_object_; |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 69 | |
Alex Vakulenko | c2bc9a4 | 2014-07-23 10:57:58 -0700 | [diff] [blame] | 70 | std::shared_ptr<CommandManager> command_manager_; |
Alex Vakulenko | 07216fe | 2014-09-19 15:31:09 -0700 | [diff] [blame] | 71 | std::shared_ptr<StateManager> state_manager_; |
Alex Vakulenko | 1f30a62 | 2014-07-23 11:13:15 -0700 | [diff] [blame] | 72 | std::unique_ptr<DeviceRegistrationInfo> device_info_; |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 73 | |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 74 | DISALLOW_COPY_AND_ASSIGN(Manager); |
| 75 | }; |
| 76 | |
| 77 | } // namespace buffet |
| 78 | |
| 79 | #endif // BUFFET_MANAGER_H_ |