Vitaly Buka | 4615e0d | 2015-10-14 15:35:12 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Weave Authors. All rights reserved. |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Vitaly Buka | 912b698 | 2015-07-06 11:13:03 -0700 | [diff] [blame] | 5 | #ifndef LIBWEAVE_SRC_BASE_API_HANDLER_H_ |
| 6 | #define LIBWEAVE_SRC_BASE_API_HANDLER_H_ |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | |
| 11 | #include <base/memory/weak_ptr.h> |
| 12 | |
Vitaly Buka | b6f015a | 2015-07-09 14:59:23 -0700 | [diff] [blame] | 13 | namespace weave { |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 14 | |
Vitaly Buka | 12affd8 | 2015-07-23 18:45:35 -0700 | [diff] [blame] | 15 | class Command; |
Vitaly Buka | 266e88b | 2015-10-06 11:33:00 -0700 | [diff] [blame] | 16 | class Device; |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 17 | class DeviceRegistrationInfo; |
Vitaly Buka | 4c808b2 | 2015-08-02 13:44:52 -0700 | [diff] [blame] | 18 | struct Settings; |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 19 | |
| 20 | // Handles commands from 'base' package. |
| 21 | // Objects of the class subscribe for notification from CommandManager and |
| 22 | // execute incoming commands. |
| 23 | // Handled commands: |
| 24 | // base.updateDeviceInfo |
Vitaly Buka | 2f7efdb | 2015-05-27 16:00:21 -0700 | [diff] [blame] | 25 | // base.updateBaseConfiguration |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 26 | class BaseApiHandler final { |
| 27 | public: |
Vitaly Buka | 266e88b | 2015-10-06 11:33:00 -0700 | [diff] [blame] | 28 | BaseApiHandler(DeviceRegistrationInfo* device_info, Device* device); |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 29 | |
| 30 | private: |
Vitaly Buka | c602926 | 2015-10-07 09:29:13 -0700 | [diff] [blame] | 31 | void UpdateBaseConfiguration(const std::weak_ptr<Command>& command); |
| 32 | void UpdateDeviceInfo(const std::weak_ptr<Command>& command); |
Vitaly Buka | 4c808b2 | 2015-08-02 13:44:52 -0700 | [diff] [blame] | 33 | void OnConfigChanged(const Settings& settings); |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 34 | |
Vitaly Buka | 4c808b2 | 2015-08-02 13:44:52 -0700 | [diff] [blame] | 35 | DeviceRegistrationInfo* device_info_; |
Vitaly Buka | f533677 | 2016-01-19 16:43:56 -0800 | [diff] [blame] | 36 | Device* device_{nullptr}; |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 37 | |
| 38 | base::WeakPtrFactory<BaseApiHandler> weak_ptr_factory_{this}; |
| 39 | DISALLOW_COPY_AND_ASSIGN(BaseApiHandler); |
| 40 | }; |
| 41 | |
Vitaly Buka | b6f015a | 2015-07-09 14:59:23 -0700 | [diff] [blame] | 42 | } // namespace weave |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 43 | |
Vitaly Buka | 912b698 | 2015-07-06 11:13:03 -0700 | [diff] [blame] | 44 | #endif // LIBWEAVE_SRC_BASE_API_HANDLER_H_ |