PM: Add an update engine provider.

The UpdaterProvider exports variables for querying the status of an
update process and related settings. Includes a concrete implementation
(RealUpdaterProvider), which currently links directly with update engine
code and pulls information through the SystemState object.  Also
included is a fake implementation (FakeUpdaterProvider) for testing
purposes.

BUG=chromium:346914
TEST=Unit tests.

Change-Id: I6ed5b40f21e43537e78aebf4217d811e149f745b
Reviewed-on: https://chromium-review.googlesource.com/192232
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/policy_manager/real_updater_provider.h b/policy_manager/real_updater_provider.h
new file mode 100644
index 0000000..1b24e16
--- /dev/null
+++ b/policy_manager/real_updater_provider.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2014 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_UPDATER_PROVIDER_H_
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_UPDATER_PROVIDER_H_
+
+#include "update_engine/policy_manager/updater_provider.h"
+
+#include "update_engine/system_state.h"
+
+namespace chromeos_policy_manager {
+
+// A concrete UpdaterProvider implementation using local (in-process) bindings.
+class RealUpdaterProvider : public UpdaterProvider {
+ public:
+  // We assume that any other object handle we get from the system state is
+  // "volatile", and so must be re-acquired whenever access is needed; this
+  // guarantees that parts of the system state can be mocked out at any time
+  // during testing. We further assume that, by the time Init() is called, the
+  // system state object is fully populated and usable.
+  explicit RealUpdaterProvider(
+      chromeos_update_engine::SystemState* system_state);
+
+  virtual Variable<base::Time>* var_last_checked_time() override {
+    return var_last_checked_time_.get();
+  }
+
+  virtual Variable<base::Time>* var_update_completed_time() override {
+    return var_update_completed_time_.get();
+  }
+
+  virtual Variable<double>* var_progress() override {
+    return var_progress_.get();
+  }
+
+  virtual Variable<Stage>* var_stage() override {
+    return var_stage_.get();
+  }
+
+  virtual Variable<std::string>* var_new_version() override {
+    return var_new_version_.get();
+  }
+
+  virtual Variable<size_t>* var_payload_size() override {
+    return var_payload_size_.get();
+  }
+
+  virtual Variable<std::string>* var_curr_channel() override {
+    return var_curr_channel_.get();
+  }
+
+  virtual Variable<std::string>* var_new_channel() override {
+    return var_new_channel_.get();
+  }
+
+  virtual Variable<bool>* var_p2p_enabled() override {
+    return var_p2p_enabled_.get();
+  }
+
+  virtual Variable<bool>* var_cellular_enabled() override {
+    return var_cellular_enabled_.get();
+  }
+
+ protected:
+  virtual bool DoInit() { return true; }
+
+ private:
+  // A pointer to the update engine's system state aggregator.
+  chromeos_update_engine::SystemState* system_state_;
+
+  // Pointers to all variable implementations.
+  scoped_ptr<Variable<base::Time>> var_last_checked_time_;
+  scoped_ptr<Variable<base::Time>> var_update_completed_time_;
+  scoped_ptr<Variable<double>> var_progress_;
+  scoped_ptr<Variable<Stage>> var_stage_;
+  scoped_ptr<Variable<std::string>> var_new_version_;
+  scoped_ptr<Variable<size_t>> var_payload_size_;
+  scoped_ptr<Variable<std::string>> var_curr_channel_;
+  scoped_ptr<Variable<std::string>> var_new_channel_;
+  scoped_ptr<Variable<bool>> var_p2p_enabled_;
+  scoped_ptr<Variable<bool>> var_cellular_enabled_;
+
+  DISALLOW_COPY_AND_ASSIGN(RealUpdaterProvider);
+};
+
+}  // namespace chromeos_policy_manager
+
+#endif  // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_UPDATER_PROVIDER_H_