blob: 8aa27ba1d0d48af98881f98015a683a48f8bb45f [file] [log] [blame]
Anton Muhin59755522014-11-05 21:30:12 +04001// Copyright 2014 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#include "buffet/commands/cloud_command_proxy.h"
6
7#include "buffet/commands/command_instance.h"
8#include "buffet/commands/prop_constraints.h"
9#include "buffet/commands/prop_types.h"
10#include "buffet/device_registration_info.h"
11
12namespace buffet {
13
14CloudCommandProxy::CloudCommandProxy(
15 CommandInstance* command_instance,
16 DeviceRegistrationInfo* device_registration_info)
17 : command_instance_(command_instance),
18 device_registration_info_(device_registration_info) {
19}
20
Anton Muhincfde8692014-11-25 03:36:59 +040021void CloudCommandProxy::OnResultsChanged(const native_types::Object& results) {
22 base::DictionaryValue patch;
23 patch.Set("results", TypedValueToJson(results, nullptr).get());
24 device_registration_info_->UpdateCommand(command_instance_->GetID(), patch);
25}
26
Anton Muhin59755522014-11-05 21:30:12 +040027void CloudCommandProxy::OnStatusChanged(const std::string& status) {
28 base::DictionaryValue patch;
29 // TODO(antonm): Change status to state.
30 patch.SetString("state", status);
31 device_registration_info_->UpdateCommand(command_instance_->GetID(), patch);
32}
33
34void CloudCommandProxy::OnProgressChanged(int progress) {
35 base::DictionaryValue patch;
36 patch.SetInteger("progress", progress);
37 // TODO(antonm): Consider batching progress change updates.
38 device_registration_info_->UpdateCommand(command_instance_->GetID(), patch);
39}
40
41} // namespace buffet