blob: b1304c5d35653cafc3ef5a5ec984a58220b0ce6b [file] [log] [blame]
[email protected]de0fdca22014-08-19 05:26:091// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]e8f96ff2011-08-03 05:07:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]de0fdca22014-08-19 05:26:095#include "components/component_updater/component_updater_service.h"
[email protected]e8f96ff2011-08-03 05:07:336
7#include <algorithm>
sorin7c717622015-05-26 19:59:098#include <map>
9#include <string>
10#include <utility>
[email protected]e8f96ff2011-08-03 05:07:3311#include <vector>
12
[email protected]44da56e2011-11-21 19:59:1413#include "base/bind.h"
sorin395c2ac2014-09-16 21:31:0714#include "base/bind_helpers.h"
[email protected]78efe2e92014-08-08 15:53:2215#include "base/callback.h"
[email protected]57999812013-02-24 05:40:5216#include "base/files/file_path.h"
thestig819adcc82014-09-10 22:24:5317#include "base/files/file_util.h"
[email protected]e8f96ff2011-08-03 05:07:3318#include "base/logging.h"
sorin5cb1f5492014-09-23 04:07:4419#include "base/macros.h"
sorin85953dc2016-03-10 00:32:4820#include "base/metrics/histogram_macros.h"
waffles77255cc2016-08-02 17:25:1221#include "base/strings/utf_string_conversions.h"
[email protected]ed6fb982014-07-23 16:56:5222#include "base/threading/thread_checker.h"
gab7966d312016-05-11 20:35:0123#include "base/threading/thread_task_runner_handle.h"
sorin85953dc2016-03-10 00:32:4824#include "base/time/time.h"
[email protected]41a17c52013-06-28 00:27:5325#include "base/timer/timer.h"
sorin7c717622015-05-26 19:59:0926#include "components/component_updater/component_updater_service_internal.h"
27#include "components/component_updater/timer.h"
sorin52ac0882015-01-24 01:15:0028#include "components/update_client/configurator.h"
sorin52ac0882015-01-24 01:15:0029#include "components/update_client/crx_update_item.h"
sorin52ac0882015-01-24 01:15:0030#include "components/update_client/update_client.h"
sorin7b8650522016-11-02 18:23:4131#include "components/update_client/update_client_errors.h"
sorin52ac0882015-01-24 01:15:0032#include "components/update_client/utils.h"
[email protected]761fa4702013-07-02 15:25:1533#include "url/gurl.h"
[email protected]e8f96ff2011-08-03 05:07:3334
sorin7c717622015-05-26 19:59:0935using CrxInstaller = update_client::CrxInstaller;
36using UpdateClient = update_client::UpdateClient;
sorin52ac0882015-01-24 01:15:0037
sorin85953dc2016-03-10 00:32:4838namespace {
39
40enum UpdateType {
41 UPDATE_TYPE_MANUAL = 0,
42 UPDATE_TYPE_AUTOMATIC,
43 UPDATE_TYPE_COUNT,
44};
45
46} // namespace
47
[email protected]055981f2014-01-17 20:22:3248namespace component_updater {
[email protected]3a0092d2013-12-18 03:04:3549
Joshua Pawlicki0499ac82017-08-17 18:29:0750ComponentInfo::ComponentInfo(const std::string& id,
51 const std::string& fingerprint,
52 const base::string16& name,
wafflese7759f72016-10-10 23:41:2553 const base::Version& version)
Joshua Pawlicki0499ac82017-08-17 18:29:0754 : id(id), fingerprint(fingerprint), name(name), version(version) {}
55ComponentInfo::ComponentInfo(const ComponentInfo& other) = default;
56ComponentInfo::ComponentInfo(ComponentInfo&& other) = default;
waffles77255cc2016-08-02 17:25:1257ComponentInfo::~ComponentInfo() {}
58
sorin7c717622015-05-26 19:59:0959CrxUpdateService::CrxUpdateService(
60 const scoped_refptr<Configurator>& config,
61 const scoped_refptr<UpdateClient>& update_client)
Sorin Jianuebd652462017-07-23 02:00:5862 : config_(config), update_client_(update_client) {
sorin7c717622015-05-26 19:59:0963 AddObserver(this);
[email protected]1ea21ad2013-09-02 04:20:3964}
[email protected]e8f96ff2011-08-03 05:07:3365
66CrxUpdateService::~CrxUpdateService() {
sorin7c717622015-05-26 19:59:0967 DCHECK(thread_checker_.CalledOnValidThread());
68
Sorin Jianua8ef73d2017-11-02 16:55:1769 for (auto& item : ready_callbacks_) {
70 std::move(item.second).Run();
sorin7c717622015-05-26 19:59:0971 }
72
73 RemoveObserver(this);
74
[email protected]e8f96ff2011-08-03 05:07:3375 Stop();
[email protected]1ea21ad2013-09-02 04:20:3976}
[email protected]e8f96ff2011-08-03 05:07:3377
[email protected]d3268fe2014-04-25 02:14:2378void CrxUpdateService::AddObserver(Observer* observer) {
[email protected]ed6fb982014-07-23 16:56:5279 DCHECK(thread_checker_.CalledOnValidThread());
sorin7c717622015-05-26 19:59:0980 update_client_->AddObserver(observer);
[email protected]d3268fe2014-04-25 02:14:2381}
82
83void CrxUpdateService::RemoveObserver(Observer* observer) {
[email protected]ed6fb982014-07-23 16:56:5284 DCHECK(thread_checker_.CalledOnValidThread());
sorin7c717622015-05-26 19:59:0985 update_client_->RemoveObserver(observer);
[email protected]d3268fe2014-04-25 02:14:2386}
87
sorin7c717622015-05-26 19:59:0988void CrxUpdateService::Start() {
89 DCHECK(thread_checker_.CalledOnValidThread());
90 VLOG(1) << "CrxUpdateService starting up. "
91 << "First update attempt will take place in "
92 << config_->InitialDelay() << " seconds. "
93 << "Next update attempt will take place in "
94 << config_->NextCheckDelay() << " seconds. ";
[email protected]e8f96ff2011-08-03 05:07:3395
sorin7c717622015-05-26 19:59:0996 timer_.Start(
97 base::TimeDelta::FromSeconds(config_->InitialDelay()),
98 base::TimeDelta::FromSeconds(config_->NextCheckDelay()),
99 base::Bind(base::IgnoreResult(&CrxUpdateService::CheckForUpdates),
100 base::Unretained(this)));
[email protected]e8f96ff2011-08-03 05:07:33101}
102
sorin7c717622015-05-26 19:59:09103// Stops the update loop. In flight operations will be completed.
104void CrxUpdateService::Stop() {
105 DCHECK(thread_checker_.CalledOnValidThread());
[email protected]fb53e652014-04-30 11:27:19106 VLOG(1) << "CrxUpdateService stopping";
[email protected]e8f96ff2011-08-03 05:07:33107 timer_.Stop();
sorinecaad3e2015-11-13 19:15:52108 update_client_->Stop();
[email protected]e8f96ff2011-08-03 05:07:33109}
110
111// Adds a component to be checked for upgrades. If the component exists it
sorin7c717622015-05-26 19:59:09112// it will be replaced.
113bool CrxUpdateService::RegisterComponent(const CrxComponent& component) {
[email protected]ed6fb982014-07-23 16:56:52114 DCHECK(thread_checker_.CalledOnValidThread());
[email protected]d0c8b8b42014-05-06 05:11:45115 if (component.pk_hash.empty() || !component.version.IsValid() ||
sorin7c717622015-05-26 19:59:09116 !component.installer) {
117 return false;
[email protected]e8f96ff2011-08-03 05:07:33118 }
119
sorin7c717622015-05-26 19:59:09120 // Update the registration data if the component has been registered before.
121 const std::string id(GetCrxComponentID(component));
122 auto it = components_.find(id);
123 if (it != components_.end()) {
124 it->second = component;
125 return true;
[email protected]10bc0222014-06-11 13:44:38126 }
[email protected]e8f96ff2011-08-03 05:07:33127
sorin7c717622015-05-26 19:59:09128 components_.insert(std::make_pair(id, component));
129 components_order_.push_back(id);
waffles77255cc2016-08-02 17:25:12130 for (const auto& mime_type : component.handled_mime_types)
131 component_ids_by_mime_type_[mime_type] = id;
sorin7c717622015-05-26 19:59:09132
133 // Create an initial state for this component. The state is mutated in
134 // response to events from the UpdateClient instance.
135 CrxUpdateItem item;
136 item.id = id;
137 item.component = component;
138 const auto inserted = component_states_.insert(std::make_pair(id, item));
139 DCHECK(inserted.second);
140
141 // Start the timer if this is the first component registered. The first timer
142 // event occurs after an interval defined by the component update
143 // configurator. The subsequent timer events are repeated with a period
144 // defined by the same configurator.
145 if (components_.size() == 1)
146 Start();
147
148 return true;
[email protected]e8f96ff2011-08-03 05:07:33149}
150
sorin7c717622015-05-26 19:59:09151bool CrxUpdateService::UnregisterComponent(const std::string& id) {
152 DCHECK(thread_checker_.CalledOnValidThread());
153 auto it = components_.find(id);
154 if (it == components_.end())
155 return false;
bauerb1f6657e72015-02-09 00:00:27156
sorin7c717622015-05-26 19:59:09157 DCHECK_EQ(id, it->first);
bauerb1f6657e72015-02-09 00:00:27158
sorin7c717622015-05-26 19:59:09159 // Delay the uninstall of the component if the component is being updated.
160 if (update_client_->IsUpdating(id)) {
161 components_pending_unregistration_.push_back(id);
162 return true;
163 }
164
165 return DoUnregisterComponent(it->second);
166}
167
168bool CrxUpdateService::DoUnregisterComponent(const CrxComponent& component) {
169 DCHECK(thread_checker_.CalledOnValidThread());
170
171 const auto id = GetCrxComponentID(component);
172 DCHECK(ready_callbacks_.find(id) == ready_callbacks_.end());
173
174 const bool result = component.installer->Uninstall();
175
176 const auto pos =
177 std::find(components_order_.begin(), components_order_.end(), id);
178 if (pos != components_order_.end())
179 components_order_.erase(pos);
180
181 components_.erase(id);
182 component_states_.erase(id);
183
184 return result;
bauerb1f6657e72015-02-09 00:00:27185}
186
[email protected]68bf09e2014-06-03 00:10:56187std::vector<std::string> CrxUpdateService::GetComponentIDs() const {
[email protected]ed6fb982014-07-23 16:56:52188 DCHECK(thread_checker_.CalledOnValidThread());
sorin7c717622015-05-26 19:59:09189 std::vector<std::string> ids;
190 for (const auto& it : components_)
191 ids.push_back(it.first);
192 return ids;
[email protected]68bf09e2014-06-03 00:10:56193}
194
waffles77255cc2016-08-02 17:25:12195std::unique_ptr<ComponentInfo> CrxUpdateService::GetComponentForMimeType(
196 const std::string& mime_type) const {
197 DCHECK(thread_checker_.CalledOnValidThread());
198 const auto it = component_ids_by_mime_type_.find(mime_type);
199 if (it == component_ids_by_mime_type_.end())
200 return nullptr;
vmpstr6d9996c82017-02-23 00:43:25201 auto* const component = GetComponent(it->second);
waffles77255cc2016-08-02 17:25:12202 if (!component)
203 return nullptr;
Gyuyoung Kim6afb5082018-01-19 13:35:57204 return std::make_unique<ComponentInfo>(
Joshua Pawlicki0499ac82017-08-17 18:29:07205 GetCrxComponentID(*component), component->fingerprint,
206 base::UTF8ToUTF16(component->name), component->version);
207}
208
209std::vector<ComponentInfo> CrxUpdateService::GetComponents() const {
210 DCHECK(thread_checker_.CalledOnValidThread());
211 std::vector<ComponentInfo> result;
212 for (const auto& it : components_) {
213 result.push_back(ComponentInfo(it.first, it.second.fingerprint,
214 base::UTF8ToUTF16(it.second.name),
215 it.second.version));
216 }
217 return result;
waffles77255cc2016-08-02 17:25:12218}
219
[email protected]78efe2e92014-08-08 15:53:22220OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() {
sorin7c717622015-05-26 19:59:09221 DCHECK(thread_checker_.CalledOnValidThread());
[email protected]78efe2e92014-08-08 15:53:22222 return *this;
223}
224
sorin7c717622015-05-26 19:59:09225const CrxComponent* CrxUpdateService::GetComponent(
226 const std::string& id) const {
227 DCHECK(thread_checker_.CalledOnValidThread());
228 const auto it(components_.find(id));
Ivan Kotenkov75b1c3a2017-10-24 14:47:24229 return it != components_.end() ? &(it->second) : nullptr;
sorin7c717622015-05-26 19:59:09230}
231
232const CrxUpdateItem* CrxUpdateService::GetComponentState(
233 const std::string& id) const {
234 DCHECK(thread_checker_.CalledOnValidThread());
235 const auto it(component_states_.find(id));
Ivan Kotenkov75b1c3a2017-10-24 14:47:24236 return it != component_states_.end() ? &it->second : nullptr;
sorin7c717622015-05-26 19:59:09237}
238
239void CrxUpdateService::MaybeThrottle(const std::string& id,
Sorin Jianua8ef73d2017-11-02 16:55:17240 base::OnceClosure callback) {
[email protected]78efe2e92014-08-08 15:53:22241 DCHECK(thread_checker_.CalledOnValidThread());
Sorin Jianua8ef73d2017-11-02 16:55:17242 const auto it = components_.find(id);
sorin7c717622015-05-26 19:59:09243 if (it != components_.end()) {
244 DCHECK_EQ(it->first, id);
245 if (OnDemandUpdateWithCooldown(id)) {
Sorin Jianua8ef73d2017-11-02 16:55:17246 ready_callbacks_.insert(std::make_pair(id, std::move(callback)));
sorin7c717622015-05-26 19:59:09247 return;
248 }
[email protected]78efe2e92014-08-08 15:53:22249 }
sorin7c717622015-05-26 19:59:09250
Sorin Jianua8ef73d2017-11-02 16:55:17251 // Unblock the request if the request can't be throttled.
252 std::move(callback).Run();
sorin7c717622015-05-26 19:59:09253}
254
sorin4c520182016-08-19 17:27:44255void CrxUpdateService::OnDemandUpdate(const std::string& id,
Vladislav Kuzkokov12eca792017-10-20 12:45:38256 Callback callback) {
sorin7c717622015-05-26 19:59:09257 DCHECK(thread_checker_.CalledOnValidThread());
258
sorin4c520182016-08-19 17:27:44259 if (!GetComponent(id)) {
drbasic6d4d9ce2017-02-22 10:33:59260 if (!callback.is_null()) {
261 base::ThreadTaskRunnerHandle::Get()->PostTask(
Vladislav Kuzkokov12eca792017-10-20 12:45:38262 FROM_HERE, base::BindOnce(std::move(callback),
263 update_client::Error::INVALID_ARGUMENT));
drbasic6d4d9ce2017-02-22 10:33:59264 }
sorin4c520182016-08-19 17:27:44265 return;
266 }
sorin7c717622015-05-26 19:59:09267
Vladislav Kuzkokov12eca792017-10-20 12:45:38268 OnDemandUpdateInternal(id, std::move(callback));
sorin7c717622015-05-26 19:59:09269}
270
271bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) {
272 DCHECK(thread_checker_.CalledOnValidThread());
273
274 DCHECK(GetComponent(id));
275
276 // Check if the request is too soon.
vmpstr2de366b2016-07-20 21:35:48277 const auto* component_state(GetComponentState(id));
Ivan Afanasyevec822ac2017-09-05 14:10:06278 if (component_state && !component_state->last_check.is_null()) {
sorin1827db12016-09-15 20:43:31279 base::TimeDelta delta =
280 base::TimeTicks::Now() - component_state->last_check;
sorin7c717622015-05-26 19:59:09281 if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay()))
282 return false;
283 }
284
sorin842703b2016-11-02 23:59:23285 OnDemandUpdateInternal(id, Callback());
sorin4c520182016-08-19 17:27:44286 return true;
sorin7c717622015-05-26 19:59:09287}
288
sorin4c520182016-08-19 17:27:44289void CrxUpdateService::OnDemandUpdateInternal(const std::string& id,
Vladislav Kuzkokov12eca792017-10-20 12:45:38290 Callback callback) {
sorin7c717622015-05-26 19:59:09291 DCHECK(thread_checker_.CalledOnValidThread());
292
sorin85953dc2016-03-10 00:32:48293 UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_MANUAL,
294 UPDATE_TYPE_COUNT);
sorin7c717622015-05-26 19:59:09295 update_client_->Install(
Sorin Jianua8ef73d2017-11-02 16:55:17296 id, base::BindOnce(&CrxUpdateService::OnUpdate, base::Unretained(this)),
Vladislav Kuzkokov12eca792017-10-20 12:45:38297 base::BindOnce(&CrxUpdateService::OnUpdateComplete,
298 base::Unretained(this), std::move(callback),
299 base::TimeTicks::Now()));
sorin7c717622015-05-26 19:59:09300}
301
302bool CrxUpdateService::CheckForUpdates() {
303 DCHECK(thread_checker_.CalledOnValidThread());
sorin85953dc2016-03-10 00:32:48304
305 UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_AUTOMATIC,
306 UPDATE_TYPE_COUNT);
307
sorinfccbf2d2016-04-04 20:34:34308 std::vector<std::string> secure_ids; // Requires HTTPS for update checks.
309 std::vector<std::string> unsecure_ids; // Can fallback to HTTP.
sorin7c717622015-05-26 19:59:09310 for (const auto id : components_order_) {
311 DCHECK(components_.find(id) != components_.end());
sorinfccbf2d2016-04-04 20:34:34312
vmpstr2de366b2016-07-20 21:35:48313 auto* component(GetComponent(id));
sorinfccbf2d2016-04-04 20:34:34314 if (!component || component->requires_network_encryption)
315 secure_ids.push_back(id);
316 else
317 unsecure_ids.push_back(id);
sorin7c717622015-05-26 19:59:09318 }
319
sorinfccbf2d2016-04-04 20:34:34320 if (!unsecure_ids.empty()) {
321 update_client_->Update(
322 unsecure_ids,
Sorin Jianua8ef73d2017-11-02 16:55:17323 base::BindOnce(&CrxUpdateService::OnUpdate, base::Unretained(this)),
Vladislav Kuzkokov12eca792017-10-20 12:45:38324 base::BindOnce(&CrxUpdateService::OnUpdateComplete,
325 base::Unretained(this), Callback(),
326 base::TimeTicks::Now()));
sorinfccbf2d2016-04-04 20:34:34327 }
328
329 if (!secure_ids.empty()) {
330 update_client_->Update(
331 secure_ids,
Sorin Jianua8ef73d2017-11-02 16:55:17332 base::BindOnce(&CrxUpdateService::OnUpdate, base::Unretained(this)),
Vladislav Kuzkokov12eca792017-10-20 12:45:38333 base::BindOnce(&CrxUpdateService::OnUpdateComplete,
334 base::Unretained(this), Callback(),
335 base::TimeTicks::Now()));
sorinfccbf2d2016-04-04 20:34:34336 }
sorin7c717622015-05-26 19:59:09337
338 return true;
[email protected]78efe2e92014-08-08 15:53:22339}
340
sorin7c717622015-05-26 19:59:09341bool CrxUpdateService::GetComponentDetails(const std::string& id,
[email protected]f392e372014-06-12 07:25:57342 CrxUpdateItem* item) const {
[email protected]ed6fb982014-07-23 16:56:52343 DCHECK(thread_checker_.CalledOnValidThread());
sorin7c717622015-05-26 19:59:09344
345 // First, if this component is currently being updated, return its state from
346 // the update client.
347 if (update_client_->GetCrxUpdateState(id, item))
348 return true;
349
350 // Otherwise, return the last seen state of the component, if such a
351 // state exists.
352 const auto component_states_it = component_states_.find(id);
353 if (component_states_it != component_states_.end()) {
354 *item = component_states_it->second;
355 return true;
356 }
357
358 return false;
[email protected]2e919ddd2013-08-21 05:05:17359}
360
sorin7c717622015-05-26 19:59:09361void CrxUpdateService::OnUpdate(const std::vector<std::string>& ids,
362 std::vector<CrxComponent>* components) {
363 DCHECK(thread_checker_.CalledOnValidThread());
364 DCHECK(components->empty());
365
366 for (const auto& id : ids) {
sorineae115a2016-08-26 02:27:20367 const update_client::CrxComponent* registered_component(GetComponent(id));
sorin97bd0292016-11-14 19:46:53368 if (registered_component)
sorin7c717622015-05-26 19:59:09369 components->push_back(*registered_component);
sorin7c717622015-05-26 19:59:09370 }
[email protected]ed6fb982014-07-23 16:56:52371}
372
sorin842703b2016-11-02 23:59:23373void CrxUpdateService::OnUpdateComplete(Callback callback,
sorin4c520182016-08-19 17:27:44374 const base::TimeTicks& start_time,
sorin7b8650522016-11-02 18:23:41375 update_client::Error error) {
sorin7c717622015-05-26 19:59:09376 DCHECK(thread_checker_.CalledOnValidThread());
sorin7b8650522016-11-02 18:23:41377 VLOG(1) << "Update completed with error " << static_cast<int>(error);
sorin7c717622015-05-26 19:59:09378
sorin7b8650522016-11-02 18:23:41379 UMA_HISTOGRAM_BOOLEAN("ComponentUpdater.UpdateCompleteResult",
380 error != update_client::Error::NONE);
sorin85953dc2016-03-10 00:32:48381 UMA_HISTOGRAM_LONG_TIMES_100("ComponentUpdater.UpdateCompleteTime",
382 base::TimeTicks::Now() - start_time);
383
sorin7c717622015-05-26 19:59:09384 for (const auto id : components_pending_unregistration_) {
385 if (!update_client_->IsUpdating(id)) {
vmpstr2de366b2016-07-20 21:35:48386 const auto* component = GetComponent(id);
sorin7c717622015-05-26 19:59:09387 if (component)
388 DoUnregisterComponent(*component);
389 }
390 }
sorin4c520182016-08-19 17:27:44391
392 if (!callback.is_null()) {
Sorin Jianuebd652462017-07-23 02:00:58393 base::ThreadTaskRunnerHandle::Get()->PostTask(
Vladislav Kuzkokov12eca792017-10-20 12:45:38394 FROM_HERE, base::BindOnce(std::move(callback), error));
sorin4c520182016-08-19 17:27:44395 }
sorin7c717622015-05-26 19:59:09396}
397
398void CrxUpdateService::OnEvent(Events event, const std::string& id) {
[email protected]ed6fb982014-07-23 16:56:52399 DCHECK(thread_checker_.CalledOnValidThread());
[email protected]93e8e2c2014-01-04 12:29:23400
sorin7c717622015-05-26 19:59:09401 // Unblock all throttles for the component.
402 if (event == Observer::Events::COMPONENT_UPDATED ||
Sorin Jianucbb10e12018-01-23 18:01:44403 event == Observer::Events::COMPONENT_NOT_UPDATED ||
404 event == Observer::Events::COMPONENT_UPDATE_ERROR) {
sorin7c717622015-05-26 19:59:09405 auto callbacks = ready_callbacks_.equal_range(id);
406 for (auto it = callbacks.first; it != callbacks.second; ++it) {
Sorin Jianua8ef73d2017-11-02 16:55:17407 std::move(it->second).Run();
sorin7c717622015-05-26 19:59:09408 }
409 ready_callbacks_.erase(id);
410 }
411
412 CrxUpdateItem update_item;
413 if (!update_client_->GetCrxUpdateState(id, &update_item))
[email protected]e8f96ff2011-08-03 05:07:33414 return;
[email protected]93e8e2c2014-01-04 12:29:23415
sorin7c717622015-05-26 19:59:09416 // Update the state of the item.
417 auto it = component_states_.find(id);
418 DCHECK(it != component_states_.end());
419 it->second = update_item;
bauerb1f6657e72015-02-09 00:00:27420
sorin7c717622015-05-26 19:59:09421 // Update the component registration with the new version.
422 if (event == Observer::Events::COMPONENT_UPDATED) {
vmpstr2de366b2016-07-20 21:35:48423 auto* component(const_cast<CrxComponent*>(GetComponent(id)));
sorin7c717622015-05-26 19:59:09424 if (component) {
425 component->version = update_item.next_version;
426 component->fingerprint = update_item.next_fp;
bauerb1f6657e72015-02-09 00:00:27427 }
428 }
[email protected]68bf09e2014-06-03 00:10:56429}
430
[email protected]00a77fa2013-11-02 04:18:46431///////////////////////////////////////////////////////////////////////////////
432
[email protected]e8f96ff2011-08-03 05:07:33433// The component update factory. Using the component updater as a singleton
434// is the job of the browser process.
sorin7c717622015-05-26 19:59:09435// TODO(sorin): consider making this a singleton.
dchenga0ee5fb82016-04-26 02:46:55436std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory(
sorin9797aba2015-04-17 17:15:03437 const scoped_refptr<Configurator>& config) {
[email protected]e8f96ff2011-08-03 05:07:33438 DCHECK(config);
sorin7c717622015-05-26 19:59:09439 auto update_client = update_client::UpdateClientFactory(config);
Gyuyoung Kim6afb5082018-01-19 13:35:57440 return std::make_unique<CrxUpdateService>(config, std::move(update_client));
[email protected]e8f96ff2011-08-03 05:07:33441}
[email protected]2cddef42013-11-22 08:23:22442
[email protected]055981f2014-01-17 20:22:32443} // namespace component_updater