blob: 6eebfca9498ea7fc7d9dddb4842e83b35a613399 [file] [log] [blame]
Vitaly Buka4615e0d2015-10-14 15:35:12 -07001// Copyright 2015 The Weave Authors. All rights reserved.
Vitaly Buka72410b22015-05-13 13:48:59 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Vitaly Buka912b6982015-07-06 11:13:03 -07005#ifndef LIBWEAVE_SRC_BASE_API_HANDLER_H_
6#define LIBWEAVE_SRC_BASE_API_HANDLER_H_
Vitaly Buka72410b22015-05-13 13:48:59 -07007
8#include <memory>
9#include <string>
10
11#include <base/memory/weak_ptr.h>
12
Vitaly Bukab6f015a2015-07-09 14:59:23 -070013namespace weave {
Vitaly Buka72410b22015-05-13 13:48:59 -070014
Vitaly Buka12affd82015-07-23 18:45:35 -070015class Command;
Vitaly Buka266e88b2015-10-06 11:33:00 -070016class Device;
Vitaly Buka72410b22015-05-13 13:48:59 -070017class DeviceRegistrationInfo;
Vitaly Buka4c808b22015-08-02 13:44:52 -070018struct Settings;
Vitaly Buka72410b22015-05-13 13:48:59 -070019
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 Buka2f7efdb2015-05-27 16:00:21 -070025// base.updateBaseConfiguration
Vitaly Buka72410b22015-05-13 13:48:59 -070026class BaseApiHandler final {
27 public:
Vitaly Buka266e88b2015-10-06 11:33:00 -070028 BaseApiHandler(DeviceRegistrationInfo* device_info, Device* device);
Vitaly Buka72410b22015-05-13 13:48:59 -070029
30 private:
Vitaly Bukac6029262015-10-07 09:29:13 -070031 void UpdateBaseConfiguration(const std::weak_ptr<Command>& command);
32 void UpdateDeviceInfo(const std::weak_ptr<Command>& command);
Vitaly Buka4c808b22015-08-02 13:44:52 -070033 void OnConfigChanged(const Settings& settings);
Vitaly Buka72410b22015-05-13 13:48:59 -070034
Vitaly Buka4c808b22015-08-02 13:44:52 -070035 DeviceRegistrationInfo* device_info_;
Vitaly Bukaf5336772016-01-19 16:43:56 -080036 Device* device_{nullptr};
Vitaly Buka72410b22015-05-13 13:48:59 -070037
38 base::WeakPtrFactory<BaseApiHandler> weak_ptr_factory_{this};
39 DISALLOW_COPY_AND_ASSIGN(BaseApiHandler);
40};
41
Vitaly Bukab6f015a2015-07-09 14:59:23 -070042} // namespace weave
Vitaly Buka72410b22015-05-13 13:48:59 -070043
Vitaly Buka912b6982015-07-06 11:13:03 -070044#endif // LIBWEAVE_SRC_BASE_API_HANDLER_H_