Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: chrome/browser/component_updater/cros_component_installer.cc

Issue 2898063002: Hold cros_component_installers in browser_process. (Closed)
Patch Set: update commit message Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
137 // installer->Register(cus). 138 // installer->Register(cus).
138 DefaultComponentInstaller* installer = 139 DefaultComponentInstaller* installer =
139 new DefaultComponentInstaller(std::move(traits)); 140 g_browser_process->cros_component_installer(name, std::move(traits));
140 installer->Register(cus, installcallback); 141 installer->Register(cus, installcallback);
141 } 142 }
142 143
143 void CrOSComponent::InstallChromeOSComponent( 144 void CrOSComponent::InstallChromeOSComponent(
144 ComponentUpdateService* cus, 145 ComponentUpdateService* cus,
145 const std::string& id, 146 const std::string& id,
146 const update_client::Callback& install_callback) { 147 const update_client::Callback& install_callback) {
147 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback); 148 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback);
148 } 149 }
149 150
(...skipping 17 matching lines...) Expand all
167 DVLOG(1) << "[RegisterCrOSComponents] component " << name 168 DVLOG(1) << "[RegisterCrOSComponents] component " << name
168 << " is not in configuration."; 169 << " is not in configuration.";
169 base::PostTask( 170 base::PostTask(
170 FROM_HERE, 171 FROM_HERE,
171 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); 172 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT));
172 return false; 173 return false;
173 } 174 }
174 ComponentConfig config(it->first, it->second.find("env_version")->second, 175 ComponentConfig config(it->first, it->second.find("env_version")->second,
175 it->second.find("sha2hashstr")->second); 176 it->second.find("sha2hashstr")->second);
176 RegisterCrOSComponentInternal( 177 RegisterCrOSComponentInternal(
177 cus, config, 178 name, cus, config,
178 base::Bind(InstallChromeOSComponent, cus, 179 base::Bind(InstallChromeOSComponent, cus,
179 crx_file::id_util::GenerateIdFromHex( 180 crx_file::id_util::GenerateIdFromHex(
180 it->second.find("sha2hashstr")->second) 181 it->second.find("sha2hashstr")->second)
181 .substr(0, 32), 182 .substr(0, 32),
182 install_callback)); 183 install_callback));
183 return true; 184 return true;
184 } 185 }
185 186
186 void MountResult(const base::Callback<void(const std::string&)>& mount_callback, 187 void MountResult(const base::Callback<void(const std::string&)>& mount_callback,
187 chromeos::DBusMethodCallStatus call_status, 188 chromeos::DBusMethodCallStatus call_status,
(...skipping 18 matching lines...) Expand all
206 chromeos::DBusThreadManager::Get()->GetImageLoaderClient(); 207 chromeos::DBusThreadManager::Get()->GetImageLoaderClient();
207 if (loader) { 208 if (loader) {
208 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback)); 209 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback));
209 } else { 210 } else {
210 DVLOG(1) << "Failed to get ImageLoaderClient object."; 211 DVLOG(1) << "Failed to get ImageLoaderClient object.";
211 } 212 }
212 } 213 }
213 #endif // defined(OS_CHROMEOS 214 #endif // defined(OS_CHROMEOS
214 215
215 } // namespace component_updater 216 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698