| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/update_client/update_engine.h" | 5 #include "components/update_client/update_engine.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 UpdateEngine::UpdateEngine( | 51 UpdateEngine::UpdateEngine( |
| 52 const scoped_refptr<Configurator>& config, | 52 const scoped_refptr<Configurator>& config, |
| 53 UpdateChecker::Factory update_checker_factory, | 53 UpdateChecker::Factory update_checker_factory, |
| 54 CrxDownloader::Factory crx_downloader_factory, | 54 CrxDownloader::Factory crx_downloader_factory, |
| 55 PingManager* ping_manager, | 55 PingManager* ping_manager, |
| 56 const NotifyObserversCallback& notify_observers_callback) | 56 const NotifyObserversCallback& notify_observers_callback) |
| 57 : config_(config), | 57 : config_(config), |
| 58 update_checker_factory_(update_checker_factory), | 58 update_checker_factory_(update_checker_factory), |
| 59 crx_downloader_factory_(crx_downloader_factory), | 59 crx_downloader_factory_(crx_downloader_factory), |
| 60 ping_manager_(ping_manager), | 60 ping_manager_(ping_manager), |
| 61 metadata_(new PersistedData(config->GetPrefService())), | |
| 62 notify_observers_callback_(notify_observers_callback) {} | 61 notify_observers_callback_(notify_observers_callback) {} |
| 63 | 62 |
| 64 UpdateEngine::~UpdateEngine() { | 63 UpdateEngine::~UpdateEngine() { |
| 65 DCHECK(thread_checker_.CalledOnValidThread()); | 64 DCHECK(thread_checker_.CalledOnValidThread()); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void UpdateEngine::Update( | 67 void UpdateEngine::Update( |
| 69 bool is_foreground, | 68 bool is_foreground, |
| 70 const std::vector<std::string>& ids, | 69 const std::vector<std::string>& ids, |
| 71 const UpdateClient::CrxDataCallback& crx_data_callback, | 70 const UpdateClient::CrxDataCallback& crx_data_callback, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 FROM_HERE, | 144 FROM_HERE, |
| 146 base::Bind(&UpdateEngine::DoUpdateCheck, base::Unretained(this), it)); | 145 base::Bind(&UpdateEngine::DoUpdateCheck, base::Unretained(this), it)); |
| 147 } | 146 } |
| 148 | 147 |
| 149 void UpdateEngine::DoUpdateCheck(const UpdateContextIterator& it) { | 148 void UpdateEngine::DoUpdateCheck(const UpdateContextIterator& it) { |
| 150 DCHECK(thread_checker_.CalledOnValidThread()); | 149 DCHECK(thread_checker_.CalledOnValidThread()); |
| 151 | 150 |
| 152 auto& update_context = *it; | 151 auto& update_context = *it; |
| 153 DCHECK(update_context); | 152 DCHECK(update_context); |
| 154 | 153 |
| 155 update_context->update_checker = | 154 update_context->update_checker = update_checker_factory_(config_); |
| 156 update_checker_factory_(config_, metadata_.get()); | |
| 157 | 155 |
| 158 update_context->update_checker->CheckForUpdates( | 156 update_context->update_checker->CheckForUpdates( |
| 159 update_context->ids, update_context->components, | 157 update_context->ids, update_context->components, |
| 160 config_->ExtraRequestParams(), update_context->enabled_component_updates, | 158 config_->ExtraRequestParams(), update_context->enabled_component_updates, |
| 161 base::Bind(&UpdateEngine::UpdateCheckDone, base::Unretained(this), it)); | 159 base::Bind(&UpdateEngine::UpdateCheckDone, base::Unretained(this), it)); |
| 162 } | 160 } |
| 163 | 161 |
| 164 void UpdateEngine::UpdateCheckDone(const UpdateContextIterator& it, | 162 void UpdateEngine::UpdateCheckDone(const UpdateContextIterator& it, |
| 165 int error, | 163 int error, |
| 166 int retry_after_sec) { | 164 int retry_after_sec) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 component->Uninstall(version, reason); | 359 component->Uninstall(version, reason); |
| 362 | 360 |
| 363 update_context->component_queue.push(id); | 361 update_context->component_queue.push(id); |
| 364 | 362 |
| 365 base::ThreadTaskRunnerHandle::Get()->PostTask( | 363 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 366 FROM_HERE, | 364 FROM_HERE, |
| 367 base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it)); | 365 base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it)); |
| 368 } | 366 } |
| 369 | 367 |
| 370 } // namespace update_client | 368 } // namespace update_client |
| OLD | NEW |