blob: 8743bcf8aeaa661b117ddab31651d3f986339103 [file] [log] [blame]
Vitaly Bukae74fe3c2015-05-13 13:48:59 -07001// 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
13namespace buffet {
14
15class CommandInstance;
16class CommandManager;
17class 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
24class 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_