Commit abd73350 authored by xiaochu's avatar xiaochu Committed by Commit bot

component_updater: add '_env_version' attribute for cros_component_installer

Add _env_version attribute for each cros component update check.
Remove dir field in configuration and use name to be dir name.

BUG=chromium:690521
TEST=Run on a chromebook to download escpr successfully.

Review-Url: https://codereview.chromium.org/2882133003
Cr-Commit-Position: refs/heads/master@{#472294}
parent c9b7a5a0
...@@ -51,14 +51,14 @@ void ImageLoaderRegistration(const std::string& version, ...@@ -51,14 +51,14 @@ void ImageLoaderRegistration(const std::string& version,
} }
ComponentConfig::ComponentConfig(const std::string& name, ComponentConfig::ComponentConfig(const std::string& name,
const std::string& dir, const std::string& env_version,
const std::string& sha2hashstr) const std::string& sha2hashstr)
: name(name), dir(dir), sha2hashstr(sha2hashstr) {} : name(name), env_version(env_version), sha2hashstr(sha2hashstr) {}
ComponentConfig::~ComponentConfig() {} ComponentConfig::~ComponentConfig() {}
CrOSComponentInstallerTraits::CrOSComponentInstallerTraits( CrOSComponentInstallerTraits::CrOSComponentInstallerTraits(
const ComponentConfig& config) const ComponentConfig& config)
: dir_name(config.dir), name(config.name) { : name(config.name), env_version(config.env_version) {
if (config.sha2hashstr.length() != 64) if (config.sha2hashstr.length() != 64)
return; return;
auto strstream = config.sha2hashstr; auto strstream = config.sha2hashstr;
...@@ -104,7 +104,7 @@ bool CrOSComponentInstallerTraits::VerifyInstallation( ...@@ -104,7 +104,7 @@ bool CrOSComponentInstallerTraits::VerifyInstallation(
} }
base::FilePath CrOSComponentInstallerTraits::GetRelativeInstallDir() const { base::FilePath CrOSComponentInstallerTraits::GetRelativeInstallDir() const {
return base::FilePath(dir_name); return base::FilePath(name);
} }
void CrOSComponentInstallerTraits::GetHash(std::vector<uint8_t>* hash) const { void CrOSComponentInstallerTraits::GetHash(std::vector<uint8_t>* hash) const {
...@@ -117,7 +117,9 @@ std::string CrOSComponentInstallerTraits::GetName() const { ...@@ -117,7 +117,9 @@ std::string CrOSComponentInstallerTraits::GetName() const {
update_client::InstallerAttributes update_client::InstallerAttributes
CrOSComponentInstallerTraits::GetInstallerAttributes() const { CrOSComponentInstallerTraits::GetInstallerAttributes() const {
return update_client::InstallerAttributes(); update_client::InstallerAttributes attrs;
attrs["_env_version"] = env_version;
return attrs;
} }
std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const { std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const {
...@@ -150,8 +152,8 @@ bool CrOSComponent::InstallCrOSComponent( ...@@ -150,8 +152,8 @@ bool CrOSComponent::InstallCrOSComponent(
const update_client::Callback& install_callback) { const update_client::Callback& install_callback) {
auto* const cus = g_browser_process->component_updater(); auto* const cus = g_browser_process->component_updater();
const ConfigMap components = { const ConfigMap components = {
{"escpr", {"epson-inkjet-printer-escpr",
{{"dir", "epson-inkjet-printer-escpr"}, {{"env_version", "0.0"},
{"sha2hashstr", {"sha2hashstr",
"1913a5e0a6cad30b6f03e176177e0d7ed62c5d6700a9c66da556d7c3f5d6a47e"}}}}; "1913a5e0a6cad30b6f03e176177e0d7ed62c5d6700a9c66da556d7c3f5d6a47e"}}}};
if (name.empty()) { if (name.empty()) {
...@@ -169,7 +171,7 @@ bool CrOSComponent::InstallCrOSComponent( ...@@ -169,7 +171,7 @@ bool CrOSComponent::InstallCrOSComponent(
base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT));
return false; return false;
} }
ComponentConfig config(it->first, it->second.find("dir")->second, ComponentConfig config(it->first, it->second.find("env_version")->second,
it->second.find("sha2hashstr")->second); it->second.find("sha2hashstr")->second);
RegisterCrOSComponentInternal( RegisterCrOSComponentInternal(
cus, config, cus, config,
......
...@@ -18,10 +18,10 @@ namespace component_updater { ...@@ -18,10 +18,10 @@ namespace component_updater {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
struct ComponentConfig { struct ComponentConfig {
std::string name; std::string name;
std::string dir; std::string env_version;
std::string sha2hashstr; std::string sha2hashstr;
ComponentConfig(const std::string& name, ComponentConfig(const std::string& name,
const std::string& dir, const std::string& env_version,
const std::string& sha2hashstr); const std::string& sha2hashstr);
~ComponentConfig(); ~ComponentConfig();
}; };
...@@ -50,8 +50,8 @@ class CrOSComponentInstallerTraits : public ComponentInstallerTraits { ...@@ -50,8 +50,8 @@ class CrOSComponentInstallerTraits : public ComponentInstallerTraits {
std::string GetName() const override; std::string GetName() const override;
update_client::InstallerAttributes GetInstallerAttributes() const override; update_client::InstallerAttributes GetInstallerAttributes() const override;
std::vector<std::string> GetMimeTypes() const override; std::vector<std::string> GetMimeTypes() const override;
std::string dir_name;
std::string name; std::string name;
std::string env_version;
uint8_t kSha2Hash_[crypto::kSHA256Length] = {}; uint8_t kSha2Hash_[crypto::kSHA256Length] = {};
DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTraits); DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTraits);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment