Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/component_updater/cros_component_installer.h" | 5 #include "chrome/browser/component_updater/cros_component_installer.h" |
| 6 #include "base/task_scheduler/post_task.h" | 6 #include "base/task_scheduler/post_task.h" |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/component_updater/component_installer_errors.h" | 8 #include "chrome/browser/component_updater/component_installer_errors.h" |
| 9 #include "components/component_updater/component_updater_paths.h" | 9 #include "components/component_updater/component_updater_paths.h" |
| 10 #include "components/crx_file/id_util.h" | 10 #include "components/crx_file/id_util.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 attrs["_env_version"] = env_version; | 121 attrs["_env_version"] = env_version; |
| 122 return attrs; | 122 return attrs; |
| 123 } | 123 } |
| 124 | 124 |
| 125 std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const { | 125 std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const { |
| 126 std::vector<std::string> mime_types; | 126 std::vector<std::string> mime_types; |
| 127 return mime_types; | 127 return mime_types; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void CrOSComponent::RegisterCrOSComponentInternal( | 130 void CrOSComponent::RegisterCrOSComponentInternal( |
| 131 const std::string& name, | |
| 131 ComponentUpdateService* cus, | 132 ComponentUpdateService* cus, |
| 132 const ComponentConfig& config, | 133 const ComponentConfig& config, |
| 133 const base::Closure& installcallback) { | 134 const base::Closure& installcallback) { |
| 134 std::unique_ptr<ComponentInstallerTraits> traits( | 135 std::unique_ptr<ComponentInstallerTraits> traits( |
| 135 new CrOSComponentInstallerTraits(config)); | 136 new CrOSComponentInstallerTraits(config)); |
| 136 // |cus| will take ownership of |installer| during | 137 // |cus| will take ownership of |installer| during |
|
sky
2017/05/23 23:20:30
Update comment?
Also, I'm rather confused about t
xiaochu
2017/05/23 23:40:52
Done.
| |
| 137 // installer->Register(cus). | 138 // installer->Register(cus). |
| 138 DefaultComponentInstaller* installer = | 139 scoped_refptr<DefaultComponentInstaller> installer = |
| 139 new DefaultComponentInstaller(std::move(traits)); | 140 g_browser_process->platform_part()->GetCrosComponentInstaller( |
| 141 name, std::move(traits)); | |
| 140 installer->Register(cus, installcallback); | 142 installer->Register(cus, installcallback); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void CrOSComponent::InstallChromeOSComponent( | 145 void CrOSComponent::InstallChromeOSComponent( |
| 144 ComponentUpdateService* cus, | 146 ComponentUpdateService* cus, |
| 145 const std::string& id, | 147 const std::string& id, |
| 146 const update_client::Callback& install_callback) { | 148 const update_client::Callback& install_callback) { |
| 147 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback); | 149 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback); |
| 148 } | 150 } |
| 149 | 151 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 167 DVLOG(1) << "[RegisterCrOSComponents] component " << name | 169 DVLOG(1) << "[RegisterCrOSComponents] component " << name |
| 168 << " is not in configuration."; | 170 << " is not in configuration."; |
| 169 base::PostTask( | 171 base::PostTask( |
| 170 FROM_HERE, | 172 FROM_HERE, |
| 171 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); | 173 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); |
| 172 return false; | 174 return false; |
| 173 } | 175 } |
| 174 ComponentConfig config(it->first, it->second.find("env_version")->second, | 176 ComponentConfig config(it->first, it->second.find("env_version")->second, |
| 175 it->second.find("sha2hashstr")->second); | 177 it->second.find("sha2hashstr")->second); |
| 176 RegisterCrOSComponentInternal( | 178 RegisterCrOSComponentInternal( |
| 177 cus, config, | 179 name, cus, config, |
| 178 base::Bind(InstallChromeOSComponent, cus, | 180 base::Bind(InstallChromeOSComponent, cus, |
| 179 crx_file::id_util::GenerateIdFromHex( | 181 crx_file::id_util::GenerateIdFromHex( |
| 180 it->second.find("sha2hashstr")->second) | 182 it->second.find("sha2hashstr")->second) |
| 181 .substr(0, 32), | 183 .substr(0, 32), |
| 182 install_callback)); | 184 install_callback)); |
| 183 return true; | 185 return true; |
| 184 } | 186 } |
| 185 | 187 |
| 186 void MountResult(const base::Callback<void(const std::string&)>& mount_callback, | 188 void MountResult(const base::Callback<void(const std::string&)>& mount_callback, |
| 187 chromeos::DBusMethodCallStatus call_status, | 189 chromeos::DBusMethodCallStatus call_status, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 206 chromeos::DBusThreadManager::Get()->GetImageLoaderClient(); | 208 chromeos::DBusThreadManager::Get()->GetImageLoaderClient(); |
| 207 if (loader) { | 209 if (loader) { |
| 208 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback)); | 210 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback)); |
| 209 } else { | 211 } else { |
| 210 DVLOG(1) << "Failed to get ImageLoaderClient object."; | 212 DVLOG(1) << "Failed to get ImageLoaderClient object."; |
| 211 } | 213 } |
| 212 } | 214 } |
| 213 #endif // defined(OS_CHROMEOS | 215 #endif // defined(OS_CHROMEOS |
| 214 | 216 |
| 215 } // namespace component_updater | 217 } // namespace component_updater |
| OLD | NEW |