Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__ |
| 7 | |
| 8 | #include <string> |
Chris Masone | 790e62e | 2010-08-12 10:41:18 -0700 | [diff] [blame] | 9 | #include "base/logging.h" |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 10 | |
| 11 | // InstallPlan is a simple struct that contains relevant info for many |
| 12 | // parts of the update system about the install that should happen. |
| 13 | |
| 14 | namespace chromeos_update_engine { |
| 15 | |
| 16 | struct InstallPlan { |
| 17 | InstallPlan(bool is_full, |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame^] | 18 | bool is_resume, |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 19 | const std::string& url, |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 20 | uint64_t size, |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 21 | const std::string& hash, |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 22 | const std::string& install_path, |
| 23 | const std::string& kernel_install_path) |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 24 | : is_full_update(is_full), |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame^] | 25 | is_resume(is_resume), |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 26 | download_url(url), |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 27 | size(size), |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 28 | download_hash(hash), |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 29 | install_path(install_path), |
| 30 | kernel_install_path(kernel_install_path) {} |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame^] | 31 | InstallPlan() : is_full_update(false), is_resume(false), size(0) {} |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 32 | |
| 33 | bool is_full_update; |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame^] | 34 | bool is_resume; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 35 | std::string download_url; // url to download from |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 36 | uint64_t size; // size of the download url's data |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 37 | std::string download_hash; // hash of the data at the url |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 38 | std::string install_path; // path to install device |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 39 | std::string kernel_install_path; // path to kernel install device |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 40 | |
| 41 | bool operator==(const InstallPlan& that) const { |
| 42 | return (is_full_update == that.is_full_update) && |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame^] | 43 | (is_resume == that.is_resume) && |
| 44 | (download_url == that.download_url) && |
| 45 | (size == that.size) && |
| 46 | (download_hash == that.download_hash) && |
| 47 | (install_path == that.install_path) && |
| 48 | (kernel_install_path == that.kernel_install_path); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 49 | } |
| 50 | bool operator!=(const InstallPlan& that) const { |
| 51 | return !((*this) == that); |
| 52 | } |
| 53 | void Dump() const { |
| 54 | LOG(INFO) << "InstallPlan: " |
| 55 | << (is_full_update ? "full_update" : "delta_update") |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame^] | 56 | << (is_resume ? ", resume" : ", new_update") |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 57 | << ", url: " << download_url |
| 58 | << ", size: " << size |
| 59 | << ", hash: " << download_hash |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 60 | << ", install_path: " << install_path |
| 61 | << ", kernel_install_path: " << kernel_install_path; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 62 | } |
| 63 | }; |
| 64 | |
| 65 | } // namespace chromeos_update_engine |
| 66 | |
| 67 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__ |