[email protected] | de0fdca2 | 2014-08-19 05:26:09 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [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 | |
[email protected] | de0fdca2 | 2014-08-19 05:26:09 | [diff] [blame] | 5 | #include "components/component_updater/component_updater_service.h" |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 6 | |
| 7 | #include <algorithm> |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 8 | #include <map> |
| 9 | #include <string> |
| 10 | #include <utility> |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
[email protected] | 44da56e | 2011-11-21 19:59:14 | [diff] [blame] | 13 | #include "base/bind.h" |
sorin | 395c2ac | 2014-09-16 21:31:07 | [diff] [blame] | 14 | #include "base/bind_helpers.h" |
[email protected] | 78efe2e9 | 2014-08-08 15:53:22 | [diff] [blame] | 15 | #include "base/callback.h" |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 16 | #include "base/compiler_specific.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 17 | #include "base/files/file_path.h" |
thestig | 819adcc8 | 2014-09-10 22:24:53 | [diff] [blame] | 18 | #include "base/files/file_util.h" |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 19 | #include "base/logging.h" |
sorin | 5cb1f549 | 2014-09-23 04:07:44 | [diff] [blame] | 20 | #include "base/macros.h" |
[email protected] | 7226b33c | 2011-08-18 08:44:22 | [diff] [blame] | 21 | #include "base/memory/scoped_ptr.h" |
[email protected] | f5d27e3 | 2014-01-31 06:48:53 | [diff] [blame] | 22 | #include "base/sequenced_task_runner.h" |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 23 | #include "base/single_thread_task_runner.h" |
| 24 | #include "base/thread_task_runner_handle.h" |
[email protected] | 8f5f2ea | 2013-10-31 09:39:10 | [diff] [blame] | 25 | #include "base/threading/sequenced_worker_pool.h" |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 26 | #include "base/threading/thread_checker.h" |
[email protected] | 41a17c5 | 2013-06-28 00:27:53 | [diff] [blame] | 27 | #include "base/timer/timer.h" |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 28 | #include "components/component_updater/component_updater_service_internal.h" |
| 29 | #include "components/component_updater/timer.h" |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 30 | #include "components/update_client/configurator.h" |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 31 | #include "components/update_client/crx_update_item.h" |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 32 | #include "components/update_client/update_client.h" |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 33 | #include "components/update_client/utils.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 34 | #include "url/gurl.h" |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 35 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 36 | using CrxInstaller = update_client::CrxInstaller; |
| 37 | using UpdateClient = update_client::UpdateClient; |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 38 | |
[email protected] | 055981f | 2014-01-17 20:22:32 | [diff] [blame] | 39 | namespace component_updater { |
[email protected] | 3a0092d | 2013-12-18 03:04:35 | [diff] [blame] | 40 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 41 | CrxUpdateService::CrxUpdateService( |
| 42 | const scoped_refptr<Configurator>& config, |
| 43 | const scoped_refptr<UpdateClient>& update_client) |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 44 | : config_(config), |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 45 | update_client_(update_client), |
| 46 | blocking_task_runner_(config->GetSequencedTaskRunner()) { |
| 47 | AddObserver(this); |
[email protected] | 1ea21ad | 2013-09-02 04:20:39 | [diff] [blame] | 48 | } |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 49 | |
| 50 | CrxUpdateService::~CrxUpdateService() { |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 51 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 52 | |
| 53 | for (const auto item : ready_callbacks_) { |
| 54 | item.second.Run(); |
| 55 | } |
| 56 | |
| 57 | RemoveObserver(this); |
| 58 | |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 59 | Stop(); |
[email protected] | 1ea21ad | 2013-09-02 04:20:39 | [diff] [blame] | 60 | } |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 61 | |
[email protected] | d3268fe | 2014-04-25 02:14:23 | [diff] [blame] | 62 | void CrxUpdateService::AddObserver(Observer* observer) { |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 63 | DCHECK(thread_checker_.CalledOnValidThread()); |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 64 | update_client_->AddObserver(observer); |
[email protected] | d3268fe | 2014-04-25 02:14:23 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | void CrxUpdateService::RemoveObserver(Observer* observer) { |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 68 | DCHECK(thread_checker_.CalledOnValidThread()); |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 69 | update_client_->RemoveObserver(observer); |
[email protected] | d3268fe | 2014-04-25 02:14:23 | [diff] [blame] | 70 | } |
| 71 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 72 | void CrxUpdateService::Start() { |
| 73 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 74 | VLOG(1) << "CrxUpdateService starting up. " |
| 75 | << "First update attempt will take place in " |
| 76 | << config_->InitialDelay() << " seconds. " |
| 77 | << "Next update attempt will take place in " |
| 78 | << config_->NextCheckDelay() << " seconds. "; |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 79 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 80 | timer_.Start( |
| 81 | base::TimeDelta::FromSeconds(config_->InitialDelay()), |
| 82 | base::TimeDelta::FromSeconds(config_->NextCheckDelay()), |
| 83 | base::Bind(base::IgnoreResult(&CrxUpdateService::CheckForUpdates), |
| 84 | base::Unretained(this))); |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 85 | } |
| 86 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 87 | // Stops the update loop. In flight operations will be completed. |
| 88 | void CrxUpdateService::Stop() { |
| 89 | DCHECK(thread_checker_.CalledOnValidThread()); |
[email protected] | fb53e65 | 2014-04-30 11:27:19 | [diff] [blame] | 90 | VLOG(1) << "CrxUpdateService stopping"; |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 91 | timer_.Stop(); |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | // Adds a component to be checked for upgrades. If the component exists it |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 95 | // it will be replaced. |
| 96 | bool CrxUpdateService::RegisterComponent(const CrxComponent& component) { |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 97 | DCHECK(thread_checker_.CalledOnValidThread()); |
[email protected] | d0c8b8b4 | 2014-05-06 05:11:45 | [diff] [blame] | 98 | if (component.pk_hash.empty() || !component.version.IsValid() || |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 99 | !component.installer) { |
| 100 | return false; |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 101 | } |
| 102 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 103 | // Update the registration data if the component has been registered before. |
| 104 | const std::string id(GetCrxComponentID(component)); |
| 105 | auto it = components_.find(id); |
| 106 | if (it != components_.end()) { |
| 107 | it->second = component; |
| 108 | return true; |
[email protected] | 10bc022 | 2014-06-11 13:44:38 | [diff] [blame] | 109 | } |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 110 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 111 | components_.insert(std::make_pair(id, component)); |
| 112 | components_order_.push_back(id); |
| 113 | |
| 114 | // Create an initial state for this component. The state is mutated in |
| 115 | // response to events from the UpdateClient instance. |
| 116 | CrxUpdateItem item; |
| 117 | item.id = id; |
| 118 | item.component = component; |
| 119 | const auto inserted = component_states_.insert(std::make_pair(id, item)); |
| 120 | DCHECK(inserted.second); |
| 121 | |
| 122 | // Start the timer if this is the first component registered. The first timer |
| 123 | // event occurs after an interval defined by the component update |
| 124 | // configurator. The subsequent timer events are repeated with a period |
| 125 | // defined by the same configurator. |
| 126 | if (components_.size() == 1) |
| 127 | Start(); |
| 128 | |
| 129 | return true; |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 130 | } |
| 131 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 132 | bool CrxUpdateService::UnregisterComponent(const std::string& id) { |
| 133 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 134 | auto it = components_.find(id); |
| 135 | if (it == components_.end()) |
| 136 | return false; |
bauerb | 1f6657e7 | 2015-02-09 00:00:27 | [diff] [blame] | 137 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 138 | DCHECK_EQ(id, it->first); |
bauerb | 1f6657e7 | 2015-02-09 00:00:27 | [diff] [blame] | 139 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 140 | // Delay the uninstall of the component if the component is being updated. |
| 141 | if (update_client_->IsUpdating(id)) { |
| 142 | components_pending_unregistration_.push_back(id); |
| 143 | return true; |
| 144 | } |
| 145 | |
| 146 | return DoUnregisterComponent(it->second); |
| 147 | } |
| 148 | |
| 149 | bool CrxUpdateService::DoUnregisterComponent(const CrxComponent& component) { |
| 150 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 151 | |
| 152 | const auto id = GetCrxComponentID(component); |
| 153 | DCHECK(ready_callbacks_.find(id) == ready_callbacks_.end()); |
| 154 | |
| 155 | const bool result = component.installer->Uninstall(); |
| 156 | |
| 157 | const auto pos = |
| 158 | std::find(components_order_.begin(), components_order_.end(), id); |
| 159 | if (pos != components_order_.end()) |
| 160 | components_order_.erase(pos); |
| 161 | |
| 162 | components_.erase(id); |
| 163 | component_states_.erase(id); |
| 164 | |
| 165 | return result; |
bauerb | 1f6657e7 | 2015-02-09 00:00:27 | [diff] [blame] | 166 | } |
| 167 | |
[email protected] | 68bf09e | 2014-06-03 00:10:56 | [diff] [blame] | 168 | std::vector<std::string> CrxUpdateService::GetComponentIDs() const { |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 169 | DCHECK(thread_checker_.CalledOnValidThread()); |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 170 | std::vector<std::string> ids; |
| 171 | for (const auto& it : components_) |
| 172 | ids.push_back(it.first); |
| 173 | return ids; |
[email protected] | 68bf09e | 2014-06-03 00:10:56 | [diff] [blame] | 174 | } |
| 175 | |
[email protected] | 78efe2e9 | 2014-08-08 15:53:22 | [diff] [blame] | 176 | OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() { |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 177 | DCHECK(thread_checker_.CalledOnValidThread()); |
[email protected] | 78efe2e9 | 2014-08-08 15:53:22 | [diff] [blame] | 178 | return *this; |
| 179 | } |
| 180 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 181 | const CrxComponent* CrxUpdateService::GetComponent( |
| 182 | const std::string& id) const { |
| 183 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 184 | const auto it(components_.find(id)); |
| 185 | return it != components_.end() ? &(it->second) : NULL; |
| 186 | } |
| 187 | |
| 188 | const CrxUpdateItem* CrxUpdateService::GetComponentState( |
| 189 | const std::string& id) const { |
| 190 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 191 | const auto it(component_states_.find(id)); |
| 192 | return it != component_states_.end() ? &it->second : NULL; |
| 193 | } |
| 194 | |
| 195 | void CrxUpdateService::MaybeThrottle(const std::string& id, |
[email protected] | 78efe2e9 | 2014-08-08 15:53:22 | [diff] [blame] | 196 | const base::Closure& callback) { |
| 197 | DCHECK(thread_checker_.CalledOnValidThread()); |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 198 | auto it = components_.find(id); |
| 199 | if (it != components_.end()) { |
| 200 | DCHECK_EQ(it->first, id); |
| 201 | if (OnDemandUpdateWithCooldown(id)) { |
| 202 | ready_callbacks_.insert(std::make_pair(id, callback)); |
| 203 | return; |
| 204 | } |
[email protected] | 78efe2e9 | 2014-08-08 15:53:22 | [diff] [blame] | 205 | } |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 206 | |
| 207 | callback.Run(); // Unblock the request if the request can't be throttled. |
| 208 | } |
| 209 | |
| 210 | bool CrxUpdateService::OnDemandUpdate(const std::string& id) { |
| 211 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 212 | |
| 213 | if (!GetComponent(id)) |
| 214 | return false; |
| 215 | |
| 216 | return OnDemandUpdateInternal(id); |
| 217 | } |
| 218 | |
| 219 | bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) { |
| 220 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 221 | |
| 222 | DCHECK(GetComponent(id)); |
| 223 | |
| 224 | // Check if the request is too soon. |
| 225 | const auto component_state(GetComponentState(id)); |
| 226 | if (component_state) { |
| 227 | base::TimeDelta delta = base::Time::Now() - component_state->last_check; |
| 228 | if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay())) |
| 229 | return false; |
| 230 | } |
| 231 | |
| 232 | return OnDemandUpdateInternal(id); |
| 233 | } |
| 234 | |
| 235 | bool CrxUpdateService::OnDemandUpdateInternal(const std::string& id) { |
| 236 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 237 | |
| 238 | update_client_->Install( |
| 239 | id, base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)), |
| 240 | base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this))); |
| 241 | |
| 242 | return true; |
| 243 | } |
| 244 | |
| 245 | bool CrxUpdateService::CheckForUpdates() { |
| 246 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 247 | std::vector<std::string> ids; |
| 248 | for (const auto id : components_order_) { |
| 249 | DCHECK(components_.find(id) != components_.end()); |
| 250 | ids.push_back(id); |
| 251 | } |
| 252 | |
| 253 | update_client_->Update( |
| 254 | ids, base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)), |
| 255 | base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this))); |
| 256 | |
| 257 | return true; |
[email protected] | 78efe2e9 | 2014-08-08 15:53:22 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | scoped_refptr<base::SequencedTaskRunner> |
| 261 | CrxUpdateService::GetSequencedTaskRunner() { |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 262 | DCHECK(thread_checker_.CalledOnValidThread()); |
bauerb | 1f6657e7 | 2015-02-09 00:00:27 | [diff] [blame] | 263 | return blocking_task_runner_; |
[email protected] | 78efe2e9 | 2014-08-08 15:53:22 | [diff] [blame] | 264 | } |
| 265 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 266 | bool CrxUpdateService::GetComponentDetails(const std::string& id, |
[email protected] | f392e37 | 2014-06-12 07:25:57 | [diff] [blame] | 267 | CrxUpdateItem* item) const { |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 268 | DCHECK(thread_checker_.CalledOnValidThread()); |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 269 | |
| 270 | // First, if this component is currently being updated, return its state from |
| 271 | // the update client. |
| 272 | if (update_client_->GetCrxUpdateState(id, item)) |
| 273 | return true; |
| 274 | |
| 275 | // Otherwise, return the last seen state of the component, if such a |
| 276 | // state exists. |
| 277 | const auto component_states_it = component_states_.find(id); |
| 278 | if (component_states_it != component_states_.end()) { |
| 279 | *item = component_states_it->second; |
| 280 | return true; |
| 281 | } |
| 282 | |
| 283 | return false; |
[email protected] | 2e919ddd | 2013-08-21 05:05:17 | [diff] [blame] | 284 | } |
| 285 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 286 | void CrxUpdateService::OnUpdate(const std::vector<std::string>& ids, |
| 287 | std::vector<CrxComponent>* components) { |
| 288 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 289 | DCHECK(components->empty()); |
| 290 | |
| 291 | for (const auto& id : ids) { |
| 292 | const auto registered_component(GetComponent(id)); |
| 293 | if (registered_component) { |
| 294 | components->push_back(*registered_component); |
| 295 | } |
| 296 | } |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 297 | } |
| 298 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 299 | void CrxUpdateService::OnUpdateComplete(int error) { |
| 300 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 301 | VLOG(1) << "Update completed with error " << error; |
| 302 | |
| 303 | for (const auto id : components_pending_unregistration_) { |
| 304 | if (!update_client_->IsUpdating(id)) { |
| 305 | const auto component = GetComponent(id); |
| 306 | if (component) |
| 307 | DoUnregisterComponent(*component); |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | void CrxUpdateService::OnEvent(Events event, const std::string& id) { |
[email protected] | ed6fb98 | 2014-07-23 16:56:52 | [diff] [blame] | 313 | DCHECK(thread_checker_.CalledOnValidThread()); |
[email protected] | 93e8e2c | 2014-01-04 12:29:23 | [diff] [blame] | 314 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 315 | // Unblock all throttles for the component. |
| 316 | if (event == Observer::Events::COMPONENT_UPDATED || |
| 317 | event == Observer::Events::COMPONENT_NOT_UPDATED) { |
| 318 | auto callbacks = ready_callbacks_.equal_range(id); |
| 319 | for (auto it = callbacks.first; it != callbacks.second; ++it) { |
| 320 | it->second.Run(); |
| 321 | } |
| 322 | ready_callbacks_.erase(id); |
| 323 | } |
| 324 | |
| 325 | CrxUpdateItem update_item; |
| 326 | if (!update_client_->GetCrxUpdateState(id, &update_item)) |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 327 | return; |
[email protected] | 93e8e2c | 2014-01-04 12:29:23 | [diff] [blame] | 328 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 329 | // Update the state of the item. |
| 330 | auto it = component_states_.find(id); |
| 331 | DCHECK(it != component_states_.end()); |
| 332 | it->second = update_item; |
bauerb | 1f6657e7 | 2015-02-09 00:00:27 | [diff] [blame] | 333 | |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 334 | // Update the component registration with the new version. |
| 335 | if (event == Observer::Events::COMPONENT_UPDATED) { |
| 336 | auto component(const_cast<CrxComponent*>(GetComponent(id))); |
| 337 | if (component) { |
| 338 | component->version = update_item.next_version; |
| 339 | component->fingerprint = update_item.next_fp; |
bauerb | 1f6657e7 | 2015-02-09 00:00:27 | [diff] [blame] | 340 | } |
| 341 | } |
[email protected] | 68bf09e | 2014-06-03 00:10:56 | [diff] [blame] | 342 | } |
| 343 | |
[email protected] | 00a77fa | 2013-11-02 04:18:46 | [diff] [blame] | 344 | /////////////////////////////////////////////////////////////////////////////// |
| 345 | |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 346 | // The component update factory. Using the component updater as a singleton |
| 347 | // is the job of the browser process. |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 348 | // TODO(sorin): consider making this a singleton. |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 349 | scoped_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( |
| 350 | const scoped_refptr<Configurator>& config) { |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 351 | DCHECK(config); |
sorin | 7c71762 | 2015-05-26 19:59:09 | [diff] [blame^] | 352 | auto update_client = update_client::UpdateClientFactory(config); |
| 353 | return scoped_ptr<ComponentUpdateService>( |
| 354 | new CrxUpdateService(config, update_client.Pass())); |
[email protected] | e8f96ff | 2011-08-03 05:07:33 | [diff] [blame] | 355 | } |
[email protected] | 2cddef4 | 2013-11-22 08:23:22 | [diff] [blame] | 356 | |
[email protected] | 055981f | 2014-01-17 20:22:32 | [diff] [blame] | 357 | } // namespace component_updater |