update_engine: support downloading DLC

DLC (Downloadable Content) is a new concept that best can be described
as pieces of programs that are considered extensions of the rootfs. Each
DLC resides in the stateful partition and there are two slots for each
DLC (A and B, same as root and kernel partitions.) Each slot is treated
much like the root and kernel partitions themselves. This patch adds
initial support for installing and updating one or multiple DLCs. Each
DLC has a unique APP ID which is constructed such as
${PLATFORM_APPID}_${DLC_ID} where:

PLATFORM_APPID: Is the APP ID currently used for system updates (release
or canary)
DLC_ID: Is a unique ID given to a DLC for its lifetime.

The combination of these two unique IDs will generate a unique APP ID
that can be used for fetching update payloads for DLCs for each board.

Update engine traditionally is used for updating a system to a newer one
using the A/B slots. However, with DLCs residing in the stateful
partition, there is a chance that the stateful partition gets wiped or a
new DLC is required to be installed in the current slot. To solve this
problem, there is a new "Install" operation that allows downloading an
update payload for the current slot with the same version as we are now.
This CL adds AttemptInstall Dbus signal to be used for attempting an DLC
install operation. Furthermore, two new flags are added to the
update_engine_client utility:
--dlc_ids: A colon separated list of DLC IDs.
--install: Requests an install operation rather than an update.

BUG=chromium:879313
TEST=unittest, manual test
CQ-DEPEND=1266235

Change-Id: Ia9c9b702dc9d1bd47fbb10b30969baa0322993f6
Reviewed-on: https://chromium-review.googlesource.com/1195593
Commit-Ready: Xiaochu Liu <xiaochu@chromium.org>
Tested-by: Xiaochu Liu <xiaochu@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Xiaochu Liu <xiaochu@chromium.org>
diff --git a/update_attempter.h b/update_attempter.h
index 8fcaba5..ebbd5ec 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -71,7 +71,8 @@
   void Init();
 
   // Initiates scheduling of update checks.
-  virtual void ScheduleUpdates();
+  // Returns true if update check is scheduled.
+  virtual bool ScheduleUpdates();
 
   // Checks for update and, if a newer version is available, attempts to update
   // the system. Non-empty |in_app_version| or |in_update_url| prevents
@@ -147,6 +148,10 @@
                               const std::string& omaha_url,
                               UpdateAttemptFlags flags);
 
+  // This is the version of CheckForUpdate called by AttemptInstall API.
+  virtual bool CheckForInstall(const std::vector<std::string>& dlc_ids,
+                               const std::string& omaha_url);
+
   // This is the internal entry point for going through a rollback. This will
   // attempt to run the postinstall on the non-active partition and set it as
   // the partition to boot from. If |powerwash| is True, perform a powerwash
@@ -518,6 +523,12 @@
   std::string forced_app_version_;
   std::string forced_omaha_url_;
 
+  // A list of DLC IDs.
+  std::vector<std::string> dlc_ids_;
+  // Whether the operation is install (write to the current slot not the
+  // inactive slot).
+  bool is_install_;
+
   // If this is not TimeDelta(), then that means staging is turned on.
   base::TimeDelta staging_wait_time_;
   chromeos_update_manager::StagingSchedule staging_schedule_;