blob: 849769283ec9d522b2c486d2679a996dc32ba4fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2015 The Weave Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LIBWEAVE_SRC_BASE_API_HANDLER_H_
#define LIBWEAVE_SRC_BASE_API_HANDLER_H_
#include <memory>
#include <string>
#include <base/memory/weak_ptr.h>
namespace weave {
class Command;
class Device;
class DeviceRegistrationInfo;
struct Settings;
// Handles commands from 'base' package.
// Objects of the class subscribe for notification from CommandManager and
// execute incoming commands.
// Handled commands:
// base.updateDeviceInfo
// base.updateBaseConfiguration
class BaseApiHandler final {
public:
BaseApiHandler(DeviceRegistrationInfo* device_info, Device* device);
private:
void UpdateBaseConfiguration(const std::weak_ptr<Command>& command);
void UpdateDeviceInfo(const std::weak_ptr<Command>& command);
bool UpdateState(const std::string& anonymous_access_role,
bool discovery_enabled,
bool pairing_enabled);
void OnConfigChanged(const Settings& settings);
DeviceRegistrationInfo* device_info_;
Device* device_;
base::WeakPtrFactory<BaseApiHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BaseApiHandler);
};
} // namespace weave
#endif // LIBWEAVE_SRC_BASE_API_HANDLER_H_
|