buffet: Use command schema to define "progress"
According to the GCD specification command progress is dictionary,
defined same way as parameters and results.
Mapping between "done" and "progress" dictionary is not obvious, so patch
removes updates of progress from CommandInstance::Done().
BUG=brillo:915
TEST=FEATURES=test emerge-gizmo buffet
Change-Id: If6f6d52dbc0595a8f1cf0cf949a741675c9e5f3c
Reviewed-on: https://chromium-review.googlesource.com/268352
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_instance.h b/buffet/commands/command_instance.h
index db9c519..f67b30b 100644
--- a/buffet/commands/command_instance.h
+++ b/buffet/commands/command_instance.h
@@ -81,13 +81,14 @@
// Sets the pointer to queue this command is part of.
void SetCommandQueue(CommandQueue* queue) { queue_ = queue; }
+ // Updates the command progress. The |progress| should match the schema.
+ // Returns false if |results| value is incorrect.
+ bool SetProgress(const native_types::Object& progress);
+
// Updates the command results. The |results| should match the schema.
// Returns false if |results| value is incorrect.
bool SetResults(const native_types::Object& results);
- // Updates the command execution progress. The |progress| must be between
- // 0 and 100. Returns false if |progress| value is incorrect.
- bool SetProgress(int progress);
// Aborts command execution.
void Abort();
// Cancels command execution.
@@ -96,12 +97,9 @@
void Done();
// Command state getters.
- int GetProgress() const { return progress_; }
+ const native_types::Object& GetProgress() const { return progress_; }
const std::string& GetStatus() const { return status_; }
- // Returns the "progress" portion of JSON command resource.
- std::unique_ptr<base::Value> GetProgressJson() const;
-
// Values for command execution status.
static const char kStatusQueued[];
static const char kStatusInProgress[];
@@ -131,12 +129,12 @@
const CommandDefinition* command_definition_;
// Command parameters and their values.
native_types::Object parameters_;
+ // Current command execution progress.
+ native_types::Object progress_;
// Command results.
native_types::Object results_;
// Current command status.
std::string status_ = kStatusQueued;
- // Current command execution progress.
- int progress_ = 0;
// Command proxies for the command.
std::vector<std::unique_ptr<CommandProxyInterface>> proxies_;
// Pointer to the command queue this command instance is added to.