Vitaly Buka | e74fe3c | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 1 | // Copyright 2015 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_BASE_API_HANDLER_H_ |
| 6 | #define BUFFET_BASE_API_HANDLER_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | |
| 11 | #include <base/memory/weak_ptr.h> |
| 12 | |
| 13 | namespace buffet { |
| 14 | |
| 15 | class CommandInstance; |
| 16 | class CommandManager; |
| 17 | class DeviceRegistrationInfo; |
| 18 | |
| 19 | // Handles commands from 'base' package. |
| 20 | // Objects of the class subscribe for notification from CommandManager and |
| 21 | // execute incoming commands. |
| 22 | // Handled commands: |
| 23 | // base.updateDeviceInfo |
| 24 | class BaseApiHandler final { |
| 25 | public: |
| 26 | BaseApiHandler(const base::WeakPtr<DeviceRegistrationInfo>& device_info, |
| 27 | const std::shared_ptr<CommandManager>& command_manager); |
| 28 | |
| 29 | private: |
| 30 | void OnCommandAdded(CommandInstance* command); |
| 31 | void UpdateDeviceInfo(CommandInstance* command); |
| 32 | |
| 33 | base::WeakPtr<DeviceRegistrationInfo> device_info_; |
| 34 | |
| 35 | base::WeakPtrFactory<BaseApiHandler> weak_ptr_factory_{this}; |
| 36 | DISALLOW_COPY_AND_ASSIGN(BaseApiHandler); |
| 37 | }; |
| 38 | |
| 39 | } // namespace buffet |
| 40 | |
| 41 | #endif // BUFFET_BASE_API_HANDLER_H_ |