sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "components/update_client/component.h" |
| 6 | |
| 7 | #include <algorithm> |
| 8 | #include <utility> |
| 9 | |
| 10 | #include "base/bind.h" |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 11 | #include "base/files/file_util.h" |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 12 | #include "base/files/scoped_temp_dir.h" |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 13 | #include "base/location.h" |
| 14 | #include "base/logging.h" |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 15 | #include "base/single_thread_task_runner.h" |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 16 | #include "base/strings/string_number_conversions.h" |
Gabriel Charette | 44db142 | 2018-08-06 11:19:33 | [diff] [blame] | 17 | #include "base/task/post_task.h" |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 18 | #include "base/threading/thread_task_runner_handle.h" |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 19 | #include "base/values.h" |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 20 | #include "components/update_client/action_runner.h" |
sorin | cca1c12 | 2017-05-11 17:43:22 | [diff] [blame] | 21 | #include "components/update_client/component_unpacker.h" |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 22 | #include "components/update_client/configurator.h" |
Sorin Jianu | 75e6bf2 | 2019-02-12 16:07:12 | [diff] [blame] | 23 | #include "components/update_client/network.h" |
Joshua Pawlicki | d5409e1 | 2019-04-06 00:23:11 | [diff] [blame] | 24 | #include "components/update_client/patcher.h" |
Sorin Jianu | b925867 | 2020-02-19 16:52:17 | [diff] [blame] | 25 | #include "components/update_client/persisted_data.h" |
Sorin Jianu | 55587d3 | 2018-11-14 21:43:27 | [diff] [blame] | 26 | #include "components/update_client/protocol_definition.h" |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 27 | #include "components/update_client/protocol_serializer.h" |
Sorin Jianu | ebd65246 | 2017-07-23 02:00:58 | [diff] [blame] | 28 | #include "components/update_client/task_traits.h" |
Joshua Pawlicki | d5409e1 | 2019-04-06 00:23:11 | [diff] [blame] | 29 | #include "components/update_client/unzipper.h" |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 30 | #include "components/update_client/update_client.h" |
| 31 | #include "components/update_client/update_client_errors.h" |
| 32 | #include "components/update_client/update_engine.h" |
| 33 | #include "components/update_client/utils.h" |
| 34 | |
| 35 | // The state machine representing how a CRX component changes during an update. |
| 36 | // |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 37 | // +------------------------- kNew |
| 38 | // | | |
| 39 | // | V |
| 40 | // | kChecking |
| 41 | // | | |
| 42 | // V error V no no |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 43 | // kUpdateError <------------- [update?] -> [action?] -> kUpToDate kUpdated |
| 44 | // ^ | | ^ ^ |
| 45 | // | yes | | yes | | |
| 46 | // | V | | | |
| 47 | // | kCanUpdate +--------> kRun | |
| 48 | // | | | |
| 49 | // | no V | |
| 50 | // | +-<- [differential update?] | |
| 51 | // | | | | |
| 52 | // | | yes | | |
| 53 | // | | error V | |
| 54 | // | +-<----- kDownloadingDiff kRun---->-+ |
| 55 | // | | | ^ | |
| 56 | // | | | yes | | |
| 57 | // | | error V | | |
| 58 | // | +-<----- kUpdatingDiff ---------> [action?] ->-+ |
| 59 | // | | ^ no |
| 60 | // | error V | |
| 61 | // +-<-------- kDownloading | |
| 62 | // | | | |
| 63 | // | | | |
| 64 | // | error V | |
| 65 | // +-<-------- kUpdating --------------------------------+ |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 66 | |
| 67 | namespace update_client { |
| 68 | |
| 69 | namespace { |
| 70 | |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 71 | using InstallOnBlockingTaskRunnerCompleteCallback = base::OnceCallback< |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 72 | void(ErrorCategory error_category, int error_code, int extra_code1)>; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 73 | |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 74 | void InstallComplete( |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 75 | scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 76 | InstallOnBlockingTaskRunnerCompleteCallback callback, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 77 | const base::FilePath& unpack_path, |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 78 | const CrxInstaller::Result& result) { |
Sami Kyostila | 14ca764 | 2019-08-01 17:52:25 | [diff] [blame] | 79 | base::PostTask( |
| 80 | FROM_HERE, |
| 81 | {base::ThreadPool(), base::TaskPriority::BEST_EFFORT, base::MayBlock()}, |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 82 | base::BindOnce( |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 83 | [](scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 84 | InstallOnBlockingTaskRunnerCompleteCallback callback, |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 85 | const base::FilePath& unpack_path, |
| 86 | const CrxInstaller::Result& result) { |
Lei Zhang | 091d423 | 2019-10-15 21:12:51 | [diff] [blame] | 87 | base::DeleteFileRecursively(unpack_path); |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 88 | const ErrorCategory error_category = |
Sorin Jianu | afcb70dd | 2018-05-16 20:14:15 | [diff] [blame] | 89 | result.error ? ErrorCategory::kInstall : ErrorCategory::kNone; |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 90 | main_task_runner->PostTask( |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 91 | FROM_HERE, base::BindOnce(std::move(callback), error_category, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 92 | static_cast<int>(result.error), |
| 93 | result.extended_error)); |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 94 | }, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 95 | main_task_runner, std::move(callback), unpack_path, result)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | void InstallOnBlockingTaskRunner( |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 99 | scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 100 | const base::FilePath& unpack_path, |
Minh X. Nguyen | aafd763 | 2017-10-19 21:12:35 | [diff] [blame] | 101 | const std::string& public_key, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 102 | const std::string& fingerprint, |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 103 | std::unique_ptr<CrxInstaller::InstallParams> install_params, |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 104 | scoped_refptr<CrxInstaller> installer, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 105 | InstallOnBlockingTaskRunnerCompleteCallback callback) { |
Sorin Jianu | 23f70f75 | 2017-05-30 16:21:58 | [diff] [blame] | 106 | DCHECK(base::DirectoryExists(unpack_path)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 107 | |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 108 | // Acquire the ownership of the |unpack_path|. |
| 109 | base::ScopedTempDir unpack_path_owner; |
| 110 | ignore_result(unpack_path_owner.Set(unpack_path)); |
| 111 | |
| 112 | if (static_cast<int>(fingerprint.size()) != |
| 113 | base::WriteFile( |
| 114 | unpack_path.Append(FILE_PATH_LITERAL("manifest.fingerprint")), |
| 115 | fingerprint.c_str(), base::checked_cast<int>(fingerprint.size()))) { |
| 116 | const CrxInstaller::Result result(InstallError::FINGERPRINT_WRITE_FAILED); |
| 117 | main_task_runner->PostTask( |
| 118 | FROM_HERE, |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 119 | base::BindOnce(std::move(callback), ErrorCategory::kInstall, |
Sorin Jianu | f40ab4b3 | 2017-10-06 22:53:41 | [diff] [blame] | 120 | static_cast<int>(result.error), result.extended_error)); |
| 121 | return; |
| 122 | } |
| 123 | |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 124 | installer->Install( |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 125 | unpack_path, public_key, std::move(install_params), |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 126 | base::BindOnce(&InstallComplete, main_task_runner, std::move(callback), |
| 127 | unpack_path_owner.Take())); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | void UnpackCompleteOnBlockingTaskRunner( |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 131 | scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 132 | const base::FilePath& crx_path, |
| 133 | const std::string& fingerprint, |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 134 | std::unique_ptr<CrxInstaller::InstallParams> install_params, |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 135 | scoped_refptr<CrxInstaller> installer, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 136 | InstallOnBlockingTaskRunnerCompleteCallback callback, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 137 | const ComponentUnpacker::Result& result) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 138 | update_client::DeleteFileAndEmptyParentDirectory(crx_path); |
| 139 | |
| 140 | if (result.error != UnpackerError::kNone) { |
| 141 | main_task_runner->PostTask( |
| 142 | FROM_HERE, |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 143 | base::BindOnce(std::move(callback), ErrorCategory::kUnpack, |
Sorin Jianu | ebd65246 | 2017-07-23 02:00:58 | [diff] [blame] | 144 | static_cast<int>(result.error), result.extended_error)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 145 | return; |
| 146 | } |
| 147 | |
Sami Kyostila | 14ca764 | 2019-08-01 17:52:25 | [diff] [blame] | 148 | base::PostTask(FROM_HERE, kTaskTraits, |
| 149 | base::BindOnce(&InstallOnBlockingTaskRunner, main_task_runner, |
| 150 | result.unpack_path, result.public_key, |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 151 | fingerprint, std::move(install_params), |
| 152 | installer, std::move(callback))); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | void StartInstallOnBlockingTaskRunner( |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 156 | scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 157 | const std::vector<uint8_t>& pk_hash, |
| 158 | const base::FilePath& crx_path, |
| 159 | const std::string& fingerprint, |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 160 | std::unique_ptr<CrxInstaller::InstallParams> install_params, |
Sorin Jianu | 4912633 | 2018-02-13 17:07:42 | [diff] [blame] | 161 | scoped_refptr<CrxInstaller> installer, |
Joshua Pawlicki | d5409e1 | 2019-04-06 00:23:11 | [diff] [blame] | 162 | std::unique_ptr<Unzipper> unzipper_, |
| 163 | scoped_refptr<Patcher> patcher_, |
Joshua Pawlicki | f4b33f38 | 2018-08-17 17:36:51 | [diff] [blame] | 164 | crx_file::VerifierFormat crx_format, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 165 | InstallOnBlockingTaskRunnerCompleteCallback callback) { |
Taiju Tsuiki | 36c517d | 2017-05-18 06:45:43 | [diff] [blame] | 166 | auto unpacker = base::MakeRefCounted<ComponentUnpacker>( |
Joshua Pawlicki | d5409e1 | 2019-04-06 00:23:11 | [diff] [blame] | 167 | pk_hash, crx_path, installer, std::move(unzipper_), std::move(patcher_), |
| 168 | crx_format); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 169 | |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 170 | unpacker->Unpack(base::BindOnce( |
| 171 | &UnpackCompleteOnBlockingTaskRunner, main_task_runner, crx_path, |
| 172 | fingerprint, std::move(install_params), installer, std::move(callback))); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 173 | } |
| 174 | |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 175 | // Returns a string literal corresponding to the value of the downloader |d|. |
| 176 | const char* DownloaderToString(CrxDownloader::DownloadMetrics::Downloader d) { |
| 177 | switch (d) { |
| 178 | case CrxDownloader::DownloadMetrics::kUrlFetcher: |
| 179 | return "direct"; |
| 180 | case CrxDownloader::DownloadMetrics::kBits: |
| 181 | return "bits"; |
| 182 | default: |
| 183 | return "unknown"; |
| 184 | } |
| 185 | } |
| 186 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 187 | } // namespace |
| 188 | |
| 189 | Component::Component(const UpdateContext& update_context, const std::string& id) |
| 190 | : id_(id), |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 191 | state_(std::make_unique<StateNew>(this)), |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 192 | update_context_(update_context) {} |
| 193 | |
| 194 | Component::~Component() {} |
| 195 | |
Sorin Jianu | b329616 | 2017-12-13 20:26:32 | [diff] [blame] | 196 | scoped_refptr<Configurator> Component::config() const { |
| 197 | return update_context_.config; |
| 198 | } |
| 199 | |
Sorin Jianu | d69d437 | 2018-02-07 19:44:22 | [diff] [blame] | 200 | std::string Component::session_id() const { |
| 201 | return update_context_.session_id; |
| 202 | } |
| 203 | |
Sorin Jianu | b41a592a | 2018-03-02 16:30:27 | [diff] [blame] | 204 | bool Component::is_foreground() const { |
| 205 | return update_context_.is_foreground; |
| 206 | } |
| 207 | |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 208 | void Component::Handle(CallbackHandleComplete callback_handle_complete) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 209 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 210 | DCHECK(state_); |
| 211 | |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 212 | callback_handle_complete_ = std::move(callback_handle_complete); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 213 | |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 214 | state_->Handle( |
| 215 | base::BindOnce(&Component::ChangeState, base::Unretained(this))); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | void Component::ChangeState(std::unique_ptr<State> next_state) { |
| 219 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 220 | |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 221 | previous_state_ = state(); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 222 | if (next_state) |
| 223 | state_ = std::move(next_state); |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 224 | else |
| 225 | is_handled_ = true; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 226 | |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 227 | base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 228 | FROM_HERE, std::move(callback_handle_complete_)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | CrxUpdateItem Component::GetCrxUpdateItem() const { |
| 232 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 233 | |
| 234 | CrxUpdateItem crx_update_item; |
| 235 | crx_update_item.state = state_->state(); |
| 236 | crx_update_item.id = id_; |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 237 | if (crx_component_) |
| 238 | crx_update_item.component = *crx_component_; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 239 | crx_update_item.last_check = last_check_; |
| 240 | crx_update_item.next_version = next_version_; |
| 241 | crx_update_item.next_fp = next_fp_; |
Sorin Jianu | afcb70dd | 2018-05-16 20:14:15 | [diff] [blame] | 242 | crx_update_item.error_category = error_category_; |
| 243 | crx_update_item.error_code = error_code_; |
| 244 | crx_update_item.extra_code1 = extra_code1_; |
Joshua Pawlicki | ca4f8fa1 | 2020-02-25 23:46:06 | [diff] [blame^] | 245 | crx_update_item.custom_updatecheck_data = custom_attrs_; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 246 | |
| 247 | return crx_update_item; |
| 248 | } |
| 249 | |
sorin | 7cff6e5 | 2017-05-17 16:37:23 | [diff] [blame] | 250 | void Component::SetParseResult(const ProtocolParser::Result& result) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 251 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 252 | |
| 253 | DCHECK_EQ(0, update_check_error_); |
| 254 | |
| 255 | status_ = result.status; |
sorin | 519656c | 2017-04-28 22:39:34 | [diff] [blame] | 256 | action_run_ = result.action_run; |
Joshua Pawlicki | ca4f8fa1 | 2020-02-25 23:46:06 | [diff] [blame^] | 257 | custom_attrs_ = result.custom_attributes; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 258 | |
| 259 | if (result.manifest.packages.empty()) |
| 260 | return; |
| 261 | |
| 262 | next_version_ = base::Version(result.manifest.version); |
| 263 | const auto& package = result.manifest.packages.front(); |
| 264 | next_fp_ = package.fingerprint; |
| 265 | |
| 266 | // Resolve the urls by combining the base urls with the package names. |
| 267 | for (const auto& crx_url : result.crx_urls) { |
| 268 | const GURL url = crx_url.Resolve(package.name); |
| 269 | if (url.is_valid()) |
| 270 | crx_urls_.push_back(url); |
| 271 | } |
| 272 | for (const auto& crx_diffurl : result.crx_diffurls) { |
| 273 | const GURL url = crx_diffurl.Resolve(package.namediff); |
| 274 | if (url.is_valid()) |
| 275 | crx_diffurls_.push_back(url); |
| 276 | } |
| 277 | |
| 278 | hash_sha256_ = package.hash_sha256; |
| 279 | hashdiff_sha256_ = package.hashdiff_sha256; |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 280 | |
| 281 | if (!result.manifest.run.empty()) { |
| 282 | install_params_ = base::make_optional(CrxInstaller::InstallParams( |
| 283 | result.manifest.run, result.manifest.arguments)); |
| 284 | } |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | void Component::Uninstall(const base::Version& version, int reason) { |
| 288 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 289 | |
| 290 | DCHECK_EQ(ComponentState::kNew, state()); |
| 291 | |
Sorin Jianu | 7390024 | 2018-08-17 01:11:53 | [diff] [blame] | 292 | crx_component_ = CrxComponent(); |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 293 | crx_component_->version = version; |
| 294 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 295 | previous_version_ = version; |
| 296 | next_version_ = base::Version("0"); |
| 297 | extra_code1_ = reason; |
| 298 | |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 299 | state_ = std::make_unique<StateUninstalled>(this); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 300 | } |
| 301 | |
Sorin Jianu | 888ec29 | 2018-06-01 15:35:42 | [diff] [blame] | 302 | void Component::SetUpdateCheckResult( |
| 303 | const base::Optional<ProtocolParser::Result>& result, |
| 304 | ErrorCategory error_category, |
| 305 | int error) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 306 | DCHECK(thread_checker_.CalledOnValidThread()); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 307 | DCHECK_EQ(ComponentState::kChecking, state()); |
| 308 | |
Sorin Jianu | 888ec29 | 2018-06-01 15:35:42 | [diff] [blame] | 309 | error_category_ = error_category; |
| 310 | error_code_ = error; |
Joshua Pawlicki | ca4f8fa1 | 2020-02-25 23:46:06 | [diff] [blame^] | 311 | |
Sorin Jianu | 888ec29 | 2018-06-01 15:35:42 | [diff] [blame] | 312 | if (result) |
| 313 | SetParseResult(result.value()); |
| 314 | |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 315 | base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 316 | FROM_HERE, std::move(update_check_complete_)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | bool Component::CanDoBackgroundDownload() const { |
Sorin Jianu | b41a592a | 2018-03-02 16:30:27 | [diff] [blame] | 320 | // Foreground component updates are always downloaded in foreground. |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 321 | return !is_foreground() && |
| 322 | (crx_component() && crx_component()->allows_background_download) && |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 323 | update_context_.config->EnabledBackgroundDownloader(); |
| 324 | } |
| 325 | |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 326 | void Component::AppendEvent(base::Value event) { |
| 327 | events_.push_back(std::move(event)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | void Component::NotifyObservers(UpdateClient::Observer::Events event) const { |
| 331 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 332 | update_context_.notify_observers_callback.Run(event, id_); |
| 333 | } |
| 334 | |
| 335 | base::TimeDelta Component::GetUpdateDuration() const { |
| 336 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 337 | |
| 338 | if (update_begin_.is_null()) |
| 339 | return base::TimeDelta(); |
| 340 | |
| 341 | const base::TimeDelta update_cost(base::TimeTicks::Now() - update_begin_); |
| 342 | DCHECK_GE(update_cost, base::TimeDelta()); |
| 343 | const base::TimeDelta max_update_delay = |
| 344 | base::TimeDelta::FromSeconds(update_context_.config->UpdateDelay()); |
| 345 | return std::min(update_cost, max_update_delay); |
| 346 | } |
| 347 | |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 348 | base::Value Component::MakeEventUpdateComplete() const { |
| 349 | base::Value event(base::Value::Type::DICTIONARY); |
| 350 | event.SetKey("eventtype", base::Value(3)); |
| 351 | event.SetKey( |
| 352 | "eventresult", |
| 353 | base::Value(static_cast<int>(state() == ComponentState::kUpdated))); |
| 354 | if (error_category() != ErrorCategory::kNone) |
| 355 | event.SetKey("errorcat", base::Value(static_cast<int>(error_category()))); |
| 356 | if (error_code()) |
| 357 | event.SetKey("errorcode", base::Value(error_code())); |
| 358 | if (extra_code1()) |
| 359 | event.SetKey("extracode1", base::Value(extra_code1())); |
| 360 | if (HasDiffUpdate(*this)) { |
| 361 | const int diffresult = static_cast<int>(!diff_update_failed()); |
| 362 | event.SetKey("diffresult", base::Value(diffresult)); |
| 363 | } |
| 364 | if (diff_error_category() != ErrorCategory::kNone) { |
| 365 | const int differrorcat = static_cast<int>(diff_error_category()); |
| 366 | event.SetKey("differrorcat", base::Value(differrorcat)); |
| 367 | } |
| 368 | if (diff_error_code()) |
| 369 | event.SetKey("differrorcode", base::Value(diff_error_code())); |
| 370 | if (diff_extra_code1()) |
| 371 | event.SetKey("diffextracode1", base::Value(diff_extra_code1())); |
| 372 | if (!previous_fp().empty()) |
| 373 | event.SetKey("previousfp", base::Value(previous_fp())); |
| 374 | if (!next_fp().empty()) |
| 375 | event.SetKey("nextfp", base::Value(next_fp())); |
| 376 | DCHECK(previous_version().IsValid()); |
| 377 | event.SetKey("previousversion", base::Value(previous_version().GetString())); |
| 378 | if (next_version().IsValid()) |
| 379 | event.SetKey("nextversion", base::Value(next_version().GetString())); |
| 380 | return event; |
| 381 | } |
| 382 | |
| 383 | base::Value Component::MakeEventDownloadMetrics( |
| 384 | const CrxDownloader::DownloadMetrics& dm) const { |
| 385 | base::Value event(base::Value::Type::DICTIONARY); |
| 386 | event.SetKey("eventtype", base::Value(14)); |
| 387 | event.SetKey("eventresult", base::Value(static_cast<int>(dm.error == 0))); |
| 388 | event.SetKey("downloader", base::Value(DownloaderToString(dm.downloader))); |
| 389 | if (dm.error) |
| 390 | event.SetKey("errorcode", base::Value(dm.error)); |
| 391 | event.SetKey("url", base::Value(dm.url.spec())); |
| 392 | |
| 393 | // -1 means that the byte counts are not known. |
Sorin Jianu | 55587d3 | 2018-11-14 21:43:27 | [diff] [blame] | 394 | if (dm.total_bytes != -1 && dm.total_bytes < kProtocolMaxInt) |
| 395 | event.SetKey("total", base::Value(static_cast<double>(dm.total_bytes))); |
| 396 | if (dm.downloaded_bytes != -1 && dm.total_bytes < kProtocolMaxInt) { |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 397 | event.SetKey("downloaded", |
Sorin Jianu | 55587d3 | 2018-11-14 21:43:27 | [diff] [blame] | 398 | base::Value(static_cast<double>(dm.downloaded_bytes))); |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 399 | } |
Sorin Jianu | 55587d3 | 2018-11-14 21:43:27 | [diff] [blame] | 400 | if (dm.download_time_ms && dm.total_bytes < kProtocolMaxInt) { |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 401 | event.SetKey("download_time_ms", |
Sorin Jianu | 55587d3 | 2018-11-14 21:43:27 | [diff] [blame] | 402 | base::Value(static_cast<double>(dm.download_time_ms))); |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 403 | } |
| 404 | DCHECK(previous_version().IsValid()); |
| 405 | event.SetKey("previousversion", base::Value(previous_version().GetString())); |
| 406 | if (next_version().IsValid()) |
| 407 | event.SetKey("nextversion", base::Value(next_version().GetString())); |
| 408 | return event; |
| 409 | } |
| 410 | |
| 411 | base::Value Component::MakeEventUninstalled() const { |
| 412 | DCHECK(state() == ComponentState::kUninstalled); |
| 413 | base::Value event(base::Value::Type::DICTIONARY); |
| 414 | event.SetKey("eventtype", base::Value(4)); |
| 415 | event.SetKey("eventresult", base::Value(1)); |
| 416 | if (extra_code1()) |
| 417 | event.SetKey("extracode1", base::Value(extra_code1())); |
| 418 | DCHECK(previous_version().IsValid()); |
| 419 | event.SetKey("previousversion", base::Value(previous_version().GetString())); |
| 420 | DCHECK(next_version().IsValid()); |
| 421 | event.SetKey("nextversion", base::Value(next_version().GetString())); |
| 422 | return event; |
| 423 | } |
| 424 | |
| 425 | base::Value Component::MakeEventActionRun(bool succeeded, |
| 426 | int error_code, |
| 427 | int extra_code1) const { |
| 428 | base::Value event(base::Value::Type::DICTIONARY); |
| 429 | event.SetKey("eventtype", base::Value(42)); |
| 430 | event.SetKey("eventresult", base::Value(static_cast<int>(succeeded))); |
| 431 | if (error_code) |
| 432 | event.SetKey("errorcode", base::Value(error_code)); |
| 433 | if (extra_code1) |
| 434 | event.SetKey("extracode1", base::Value(extra_code1)); |
| 435 | return event; |
| 436 | } |
| 437 | |
| 438 | std::vector<base::Value> Component::GetEvents() const { |
| 439 | std::vector<base::Value> events; |
| 440 | for (const auto& event : events_) |
| 441 | events.push_back(event.Clone()); |
| 442 | return events; |
| 443 | } |
| 444 | |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 445 | std::unique_ptr<CrxInstaller::InstallParams> Component::install_params() const { |
| 446 | return install_params_ |
| 447 | ? std::make_unique<CrxInstaller::InstallParams>(*install_params_) |
| 448 | : nullptr; |
| 449 | } |
| 450 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 451 | Component::State::State(Component* component, ComponentState state) |
| 452 | : state_(state), component_(*component) {} |
| 453 | |
| 454 | Component::State::~State() {} |
| 455 | |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 456 | void Component::State::Handle(CallbackNextState callback_next_state) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 457 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 458 | |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 459 | callback_next_state_ = std::move(callback_next_state); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 460 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 461 | DoHandle(); |
| 462 | } |
| 463 | |
| 464 | void Component::State::TransitionState(std::unique_ptr<State> next_state) { |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 465 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 466 | DCHECK(next_state); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 467 | |
| 468 | base::ThreadTaskRunnerHandle::Get()->PostTask( |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 469 | FROM_HERE, |
| 470 | base::BindOnce(std::move(callback_next_state_), std::move(next_state))); |
| 471 | } |
| 472 | |
| 473 | void Component::State::EndState() { |
| 474 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 475 | |
| 476 | base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 477 | FROM_HERE, base::BindOnce(std::move(callback_next_state_), nullptr)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | Component::StateNew::StateNew(Component* component) |
| 481 | : State(component, ComponentState::kNew) {} |
| 482 | |
| 483 | Component::StateNew::~StateNew() { |
| 484 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 485 | } |
| 486 | |
| 487 | void Component::StateNew::DoHandle() { |
| 488 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 489 | |
| 490 | auto& component = State::component(); |
Sorin Jianu | cb4431a | 2018-04-30 20:59:24 | [diff] [blame] | 491 | if (component.crx_component()) { |
| 492 | TransitionState(std::make_unique<StateChecking>(&component)); |
| 493 | } else { |
| 494 | component.error_code_ = static_cast<int>(Error::CRX_NOT_FOUND); |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 495 | component.error_category_ = ErrorCategory::kService; |
Sorin Jianu | cb4431a | 2018-04-30 20:59:24 | [diff] [blame] | 496 | TransitionState(std::make_unique<StateUpdateError>(&component)); |
| 497 | } |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | Component::StateChecking::StateChecking(Component* component) |
| 501 | : State(component, ComponentState::kChecking) {} |
| 502 | |
| 503 | Component::StateChecking::~StateChecking() { |
| 504 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 505 | } |
| 506 | |
| 507 | // Unlike how other states are handled, this function does not change the |
| 508 | // state right away. The state transition happens when the UpdateChecker |
| 509 | // calls Component::UpdateCheckComplete and |update_check_complete_| is invoked. |
| 510 | // This is an artifact of how multiple components must be checked for updates |
| 511 | // together but the state machine defines the transitions for one component |
| 512 | // at a time. |
| 513 | void Component::StateChecking::DoHandle() { |
| 514 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 515 | |
| 516 | auto& component = State::component(); |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 517 | DCHECK(component.crx_component()); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 518 | |
| 519 | component.last_check_ = base::TimeTicks::Now(); |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 520 | component.update_check_complete_ = base::BindOnce( |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 521 | &Component::StateChecking::UpdateCheckComplete, base::Unretained(this)); |
| 522 | |
| 523 | component.NotifyObservers(Events::COMPONENT_CHECKING_FOR_UPDATES); |
| 524 | } |
| 525 | |
| 526 | void Component::StateChecking::UpdateCheckComplete() { |
| 527 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 528 | auto& component = State::component(); |
Sorin Jianu | afcb70dd | 2018-05-16 20:14:15 | [diff] [blame] | 529 | if (!component.error_code_) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 530 | if (component.status_ == "ok") { |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 531 | TransitionState(std::make_unique<StateCanUpdate>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 532 | return; |
| 533 | } |
| 534 | |
| 535 | if (component.status_ == "noupdate") { |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 536 | if (component.action_run_.empty()) |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 537 | TransitionState(std::make_unique<StateUpToDate>(&component)); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 538 | else |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 539 | TransitionState(std::make_unique<StateRun>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 540 | return; |
| 541 | } |
| 542 | } |
| 543 | |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 544 | TransitionState(std::make_unique<StateUpdateError>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | Component::StateUpdateError::StateUpdateError(Component* component) |
| 548 | : State(component, ComponentState::kUpdateError) {} |
| 549 | |
| 550 | Component::StateUpdateError::~StateUpdateError() { |
| 551 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 552 | } |
| 553 | |
| 554 | void Component::StateUpdateError::DoHandle() { |
| 555 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 556 | |
| 557 | auto& component = State::component(); |
sorin | 117334f | 2017-05-19 02:36:25 | [diff] [blame] | 558 | |
Sorin Jianu | 888ec29 | 2018-06-01 15:35:42 | [diff] [blame] | 559 | DCHECK_NE(ErrorCategory::kNone, component.error_category_); |
| 560 | DCHECK_NE(0, component.error_code_); |
| 561 | |
sorin | 117334f | 2017-05-19 02:36:25 | [diff] [blame] | 562 | // Create an event only when the server response included an update. |
| 563 | if (component.IsUpdateAvailable()) |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 564 | component.AppendEvent(component.MakeEventUpdateComplete()); |
sorin | 117334f | 2017-05-19 02:36:25 | [diff] [blame] | 565 | |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 566 | EndState(); |
Sorin Jianu | cbb10e1 | 2018-01-23 18:01:44 | [diff] [blame] | 567 | component.NotifyObservers(Events::COMPONENT_UPDATE_ERROR); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | Component::StateCanUpdate::StateCanUpdate(Component* component) |
| 571 | : State(component, ComponentState::kCanUpdate) {} |
| 572 | |
| 573 | Component::StateCanUpdate::~StateCanUpdate() { |
| 574 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 575 | } |
| 576 | |
| 577 | void Component::StateCanUpdate::DoHandle() { |
| 578 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 579 | |
| 580 | auto& component = State::component(); |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 581 | DCHECK(component.crx_component()); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 582 | |
| 583 | component.is_update_available_ = true; |
| 584 | component.NotifyObservers(Events::COMPONENT_UPDATE_FOUND); |
| 585 | |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 586 | if (component.crx_component() |
| 587 | ->supports_group_policy_enable_component_updates && |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 588 | !component.update_context_.enabled_component_updates) { |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 589 | component.error_category_ = ErrorCategory::kService; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 590 | component.error_code_ = static_cast<int>(ServiceError::UPDATE_DISABLED); |
| 591 | component.extra_code1_ = 0; |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 592 | TransitionState(std::make_unique<StateUpdateError>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 593 | return; |
| 594 | } |
| 595 | |
| 596 | // Start computing the cost of the this update from here on. |
| 597 | component.update_begin_ = base::TimeTicks::Now(); |
| 598 | |
| 599 | if (CanTryDiffUpdate()) |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 600 | TransitionState(std::make_unique<StateDownloadingDiff>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 601 | else |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 602 | TransitionState(std::make_unique<StateDownloading>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | // Returns true if a differential update is available, it has not failed yet, |
| 606 | // and the configuration allows this update. |
| 607 | bool Component::StateCanUpdate::CanTryDiffUpdate() const { |
| 608 | const auto& component = Component::State::component(); |
| 609 | return HasDiffUpdate(component) && !component.diff_error_code_ && |
| 610 | component.update_context_.config->EnabledDeltas(); |
| 611 | } |
| 612 | |
| 613 | Component::StateUpToDate::StateUpToDate(Component* component) |
| 614 | : State(component, ComponentState::kUpToDate) {} |
| 615 | |
| 616 | Component::StateUpToDate::~StateUpToDate() { |
| 617 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 618 | } |
| 619 | |
| 620 | void Component::StateUpToDate::DoHandle() { |
| 621 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 622 | |
| 623 | auto& component = State::component(); |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 624 | DCHECK(component.crx_component()); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 625 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 626 | component.NotifyObservers(Events::COMPONENT_NOT_UPDATED); |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 627 | EndState(); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | Component::StateDownloadingDiff::StateDownloadingDiff(Component* component) |
| 631 | : State(component, ComponentState::kDownloadingDiff) {} |
| 632 | |
| 633 | Component::StateDownloadingDiff::~StateDownloadingDiff() { |
| 634 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 635 | } |
| 636 | |
| 637 | void Component::StateDownloadingDiff::DoHandle() { |
| 638 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 639 | |
| 640 | const auto& component = Component::State::component(); |
| 641 | const auto& update_context = component.update_context_; |
| 642 | |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 643 | DCHECK(component.crx_component()); |
| 644 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 645 | crx_downloader_ = update_context.crx_downloader_factory( |
| 646 | component.CanDoBackgroundDownload(), |
Sorin Jianu | 75e6bf2 | 2019-02-12 16:07:12 | [diff] [blame] | 647 | update_context.config->GetNetworkFetcherFactory()); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 648 | |
| 649 | const auto& id = component.id_; |
| 650 | crx_downloader_->set_progress_callback( |
Ken Rockot | 942a638 | 2019-12-18 21:31:41 | [diff] [blame] | 651 | base::BindRepeating(&Component::StateDownloadingDiff::DownloadProgress, |
| 652 | base::Unretained(this), id)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 653 | crx_downloader_->StartDownload( |
| 654 | component.crx_diffurls_, component.hashdiff_sha256_, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 655 | base::BindOnce(&Component::StateDownloadingDiff::DownloadComplete, |
| 656 | base::Unretained(this), id)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 657 | |
| 658 | component.NotifyObservers(Events::COMPONENT_UPDATE_DOWNLOADING); |
| 659 | } |
| 660 | |
Antonio Gomes | 31237fb | 2018-08-27 19:11:03 | [diff] [blame] | 661 | // Called when progress is being made downloading a CRX. Can be called multiple |
| 662 | // times due to how the CRX downloader switches between different downloaders |
| 663 | // and fallback urls. |
| 664 | void Component::StateDownloadingDiff::DownloadProgress(const std::string& id) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 665 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 666 | |
| 667 | component().NotifyObservers(Events::COMPONENT_UPDATE_DOWNLOADING); |
| 668 | } |
| 669 | |
| 670 | void Component::StateDownloadingDiff::DownloadComplete( |
| 671 | const std::string& id, |
| 672 | const CrxDownloader::Result& download_result) { |
| 673 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 674 | |
| 675 | auto& component = Component::State::component(); |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 676 | for (const auto& download_metrics : crx_downloader_->download_metrics()) |
| 677 | component.AppendEvent(component.MakeEventDownloadMetrics(download_metrics)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 678 | |
| 679 | crx_downloader_.reset(); |
| 680 | |
| 681 | if (download_result.error) { |
Sorin Jianu | 52de5fa | 2017-10-09 23:19:33 | [diff] [blame] | 682 | DCHECK(download_result.response.empty()); |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 683 | component.diff_error_category_ = ErrorCategory::kDownload; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 684 | component.diff_error_code_ = download_result.error; |
| 685 | |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 686 | TransitionState(std::make_unique<StateDownloading>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 687 | return; |
| 688 | } |
| 689 | |
| 690 | component.crx_path_ = download_result.response; |
| 691 | |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 692 | TransitionState(std::make_unique<StateUpdatingDiff>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | Component::StateDownloading::StateDownloading(Component* component) |
| 696 | : State(component, ComponentState::kDownloading) {} |
| 697 | |
| 698 | Component::StateDownloading::~StateDownloading() { |
| 699 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 700 | } |
| 701 | |
| 702 | void Component::StateDownloading::DoHandle() { |
| 703 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 704 | |
| 705 | const auto& component = Component::State::component(); |
| 706 | const auto& update_context = component.update_context_; |
| 707 | |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 708 | DCHECK(component.crx_component()); |
| 709 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 710 | crx_downloader_ = update_context.crx_downloader_factory( |
| 711 | component.CanDoBackgroundDownload(), |
Sorin Jianu | 75e6bf2 | 2019-02-12 16:07:12 | [diff] [blame] | 712 | update_context.config->GetNetworkFetcherFactory()); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 713 | |
| 714 | const auto& id = component.id_; |
| 715 | crx_downloader_->set_progress_callback( |
Ken Rockot | 942a638 | 2019-12-18 21:31:41 | [diff] [blame] | 716 | base::BindRepeating(&Component::StateDownloading::DownloadProgress, |
| 717 | base::Unretained(this), id)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 718 | crx_downloader_->StartDownload( |
| 719 | component.crx_urls_, component.hash_sha256_, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 720 | base::BindOnce(&Component::StateDownloading::DownloadComplete, |
| 721 | base::Unretained(this), id)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 722 | |
| 723 | component.NotifyObservers(Events::COMPONENT_UPDATE_DOWNLOADING); |
| 724 | } |
| 725 | |
Antonio Gomes | 31237fb | 2018-08-27 19:11:03 | [diff] [blame] | 726 | // Called when progress is being made downloading a CRX. Can be called multiple |
| 727 | // times due to how the CRX downloader switches between different downloaders |
| 728 | // and fallback urls. |
| 729 | void Component::StateDownloading::DownloadProgress(const std::string& id) { |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 730 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 731 | |
| 732 | component().NotifyObservers(Events::COMPONENT_UPDATE_DOWNLOADING); |
| 733 | } |
| 734 | |
| 735 | void Component::StateDownloading::DownloadComplete( |
| 736 | const std::string& id, |
| 737 | const CrxDownloader::Result& download_result) { |
| 738 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 739 | |
| 740 | auto& component = Component::State::component(); |
| 741 | |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 742 | for (const auto& download_metrics : crx_downloader_->download_metrics()) |
| 743 | component.AppendEvent(component.MakeEventDownloadMetrics(download_metrics)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 744 | |
| 745 | crx_downloader_.reset(); |
| 746 | |
| 747 | if (download_result.error) { |
Sorin Jianu | 52de5fa | 2017-10-09 23:19:33 | [diff] [blame] | 748 | DCHECK(download_result.response.empty()); |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 749 | component.error_category_ = ErrorCategory::kDownload; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 750 | component.error_code_ = download_result.error; |
| 751 | |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 752 | TransitionState(std::make_unique<StateUpdateError>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 753 | return; |
| 754 | } |
| 755 | |
| 756 | component.crx_path_ = download_result.response; |
| 757 | |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 758 | TransitionState(std::make_unique<StateUpdating>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | Component::StateUpdatingDiff::StateUpdatingDiff(Component* component) |
| 762 | : State(component, ComponentState::kUpdatingDiff) {} |
| 763 | |
| 764 | Component::StateUpdatingDiff::~StateUpdatingDiff() { |
| 765 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 766 | } |
| 767 | |
| 768 | void Component::StateUpdatingDiff::DoHandle() { |
| 769 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 770 | |
| 771 | const auto& component = Component::State::component(); |
| 772 | const auto& update_context = component.update_context_; |
| 773 | |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 774 | DCHECK(component.crx_component()); |
| 775 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 776 | component.NotifyObservers(Events::COMPONENT_UPDATE_READY); |
| 777 | |
Sami Kyostila | 14ca764 | 2019-08-01 17:52:25 | [diff] [blame] | 778 | base::CreateSequencedTaskRunner(kTaskTraits) |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 779 | ->PostTask( |
| 780 | FROM_HERE, |
| 781 | base::BindOnce( |
| 782 | &update_client::StartInstallOnBlockingTaskRunner, |
| 783 | base::ThreadTaskRunnerHandle::Get(), |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 784 | component.crx_component()->pk_hash, component.crx_path_, |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 785 | component.next_fp_, component.install_params(), |
| 786 | component.crx_component()->installer, |
Joshua Pawlicki | d5409e1 | 2019-04-06 00:23:11 | [diff] [blame] | 787 | update_context.config->GetUnzipperFactory()->Create(), |
| 788 | update_context.config->GetPatcherFactory()->Create(), |
Joshua Pawlicki | f4b33f38 | 2018-08-17 17:36:51 | [diff] [blame] | 789 | component.crx_component()->crx_format_requirement, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 790 | base::BindOnce(&Component::StateUpdatingDiff::InstallComplete, |
| 791 | base::Unretained(this)))); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 792 | } |
| 793 | |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 794 | void Component::StateUpdatingDiff::InstallComplete(ErrorCategory error_category, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 795 | int error_code, |
| 796 | int extra_code1) { |
| 797 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 798 | |
| 799 | auto& component = Component::State::component(); |
| 800 | |
| 801 | component.diff_error_category_ = error_category; |
| 802 | component.diff_error_code_ = error_code; |
| 803 | component.diff_extra_code1_ = extra_code1; |
| 804 | |
| 805 | if (component.diff_error_code_ != 0) { |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 806 | TransitionState(std::make_unique<StateDownloading>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 807 | return; |
| 808 | } |
| 809 | |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 810 | DCHECK_EQ(ErrorCategory::kNone, component.diff_error_category_); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 811 | DCHECK_EQ(0, component.diff_error_code_); |
| 812 | DCHECK_EQ(0, component.diff_extra_code1_); |
| 813 | |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 814 | DCHECK_EQ(ErrorCategory::kNone, component.error_category_); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 815 | DCHECK_EQ(0, component.error_code_); |
| 816 | DCHECK_EQ(0, component.extra_code1_); |
| 817 | |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 818 | if (component.action_run_.empty()) |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 819 | TransitionState(std::make_unique<StateUpdated>(&component)); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 820 | else |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 821 | TransitionState(std::make_unique<StateRun>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | Component::StateUpdating::StateUpdating(Component* component) |
sorin | ff403ef | 2017-05-16 21:48:42 | [diff] [blame] | 825 | : State(component, ComponentState::kUpdating) {} |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 826 | |
| 827 | Component::StateUpdating::~StateUpdating() { |
| 828 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 829 | } |
| 830 | |
| 831 | void Component::StateUpdating::DoHandle() { |
| 832 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 833 | |
| 834 | const auto& component = Component::State::component(); |
| 835 | const auto& update_context = component.update_context_; |
| 836 | |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 837 | DCHECK(component.crx_component()); |
| 838 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 839 | component.NotifyObservers(Events::COMPONENT_UPDATE_READY); |
| 840 | |
Sami Kyostila | 14ca764 | 2019-08-01 17:52:25 | [diff] [blame] | 841 | base::CreateSequencedTaskRunner(kTaskTraits) |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 842 | ->PostTask(FROM_HERE, |
| 843 | base::BindOnce( |
| 844 | &update_client::StartInstallOnBlockingTaskRunner, |
| 845 | base::ThreadTaskRunnerHandle::Get(), |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 846 | component.crx_component()->pk_hash, component.crx_path_, |
Sorin Jianu | 9d64af67 | 2020-02-05 19:14:34 | [diff] [blame] | 847 | component.next_fp_, component.install_params(), |
| 848 | component.crx_component()->installer, |
Joshua Pawlicki | d5409e1 | 2019-04-06 00:23:11 | [diff] [blame] | 849 | update_context.config->GetUnzipperFactory()->Create(), |
| 850 | update_context.config->GetPatcherFactory()->Create(), |
Joshua Pawlicki | f4b33f38 | 2018-08-17 17:36:51 | [diff] [blame] | 851 | component.crx_component()->crx_format_requirement, |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 852 | base::BindOnce(&Component::StateUpdating::InstallComplete, |
Sorin Jianu | ebd65246 | 2017-07-23 02:00:58 | [diff] [blame] | 853 | base::Unretained(this)))); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 854 | } |
| 855 | |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 856 | void Component::StateUpdating::InstallComplete(ErrorCategory error_category, |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 857 | int error_code, |
| 858 | int extra_code1) { |
| 859 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 860 | |
| 861 | auto& component = Component::State::component(); |
| 862 | |
| 863 | component.error_category_ = error_category; |
| 864 | component.error_code_ = error_code; |
| 865 | component.extra_code1_ = extra_code1; |
| 866 | |
| 867 | if (component.error_code_ != 0) { |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 868 | TransitionState(std::make_unique<StateUpdateError>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 869 | return; |
| 870 | } |
| 871 | |
Minh X. Nguyen | a4640cb | 2018-05-23 21:29:10 | [diff] [blame] | 872 | DCHECK_EQ(ErrorCategory::kNone, component.error_category_); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 873 | DCHECK_EQ(0, component.error_code_); |
| 874 | DCHECK_EQ(0, component.extra_code1_); |
| 875 | |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 876 | if (component.action_run_.empty()) |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 877 | TransitionState(std::make_unique<StateUpdated>(&component)); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 878 | else |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 879 | TransitionState(std::make_unique<StateRun>(&component)); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | Component::StateUpdated::StateUpdated(Component* component) |
| 883 | : State(component, ComponentState::kUpdated) { |
| 884 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 885 | } |
| 886 | |
| 887 | Component::StateUpdated::~StateUpdated() { |
| 888 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 889 | } |
| 890 | |
| 891 | void Component::StateUpdated::DoHandle() { |
| 892 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 893 | |
| 894 | auto& component = State::component(); |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 895 | DCHECK(component.crx_component()); |
| 896 | |
| 897 | component.crx_component_->version = component.next_version_; |
| 898 | component.crx_component_->fingerprint = component.next_fp_; |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 899 | |
Sorin Jianu | b925867 | 2020-02-19 16:52:17 | [diff] [blame] | 900 | component.update_context_.persisted_data->SetProductVersion( |
| 901 | component.id(), component.crx_component_->version); |
| 902 | component.update_context_.persisted_data->SetFingerprint( |
| 903 | component.id(), component.crx_component_->fingerprint); |
| 904 | |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 905 | component.AppendEvent(component.MakeEventUpdateComplete()); |
sorin | 117334f | 2017-05-19 02:36:25 | [diff] [blame] | 906 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 907 | component.NotifyObservers(Events::COMPONENT_UPDATED); |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 908 | EndState(); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | Component::StateUninstalled::StateUninstalled(Component* component) |
| 912 | : State(component, ComponentState::kUninstalled) { |
| 913 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 914 | } |
| 915 | |
| 916 | Component::StateUninstalled::~StateUninstalled() { |
| 917 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 918 | } |
| 919 | |
| 920 | void Component::StateUninstalled::DoHandle() { |
| 921 | DCHECK(thread_checker_.CalledOnValidThread()); |
sorin | 117334f | 2017-05-19 02:36:25 | [diff] [blame] | 922 | |
| 923 | auto& component = State::component(); |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 924 | DCHECK(component.crx_component()); |
| 925 | |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 926 | component.AppendEvent(component.MakeEventUninstalled()); |
sorin | 117334f | 2017-05-19 02:36:25 | [diff] [blame] | 927 | |
Sorin Jianu | ee5c0db | 2018-04-12 23:38:47 | [diff] [blame] | 928 | EndState(); |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 929 | } |
| 930 | |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 931 | Component::StateRun::StateRun(Component* component) |
| 932 | : State(component, ComponentState::kRun) {} |
| 933 | |
| 934 | Component::StateRun::~StateRun() { |
| 935 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 936 | } |
| 937 | |
| 938 | void Component::StateRun::DoHandle() { |
| 939 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 940 | |
| 941 | const auto& component = State::component(); |
Sorin Jianu | 7c22795b | 2018-04-26 22:16:52 | [diff] [blame] | 942 | DCHECK(component.crx_component()); |
| 943 | |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 944 | action_runner_ = std::make_unique<ActionRunner>(component); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 945 | action_runner_->Run( |
Sorin Jianu | a8ef73d | 2017-11-02 16:55:17 | [diff] [blame] | 946 | base::BindOnce(&StateRun::ActionRunComplete, base::Unretained(this))); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | void Component::StateRun::ActionRunComplete(bool succeeded, |
| 950 | int error_code, |
| 951 | int extra_code1) { |
| 952 | DCHECK(thread_checker_.CalledOnValidThread()); |
| 953 | |
| 954 | auto& component = State::component(); |
| 955 | |
| 956 | component.AppendEvent( |
Sorin Jianu | 039032b | 2018-10-12 21:48:13 | [diff] [blame] | 957 | component.MakeEventActionRun(succeeded, error_code, extra_code1)); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 958 | switch (component.previous_state_) { |
| 959 | case ComponentState::kChecking: |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 960 | TransitionState(std::make_unique<StateUpToDate>(&component)); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 961 | return; |
| 962 | case ComponentState::kUpdating: |
| 963 | case ComponentState::kUpdatingDiff: |
Jinho Bang | da4e428 | 2018-01-03 13:21:23 | [diff] [blame] | 964 | TransitionState(std::make_unique<StateUpdated>(&component)); |
Sorin Jianu | 4ab7c29 | 2017-06-15 18:40:21 | [diff] [blame] | 965 | return; |
| 966 | default: |
| 967 | break; |
| 968 | } |
| 969 | NOTREACHED(); |
| 970 | } |
| 971 | |
sorin | 30474f0 | 2017-04-27 00:45:48 | [diff] [blame] | 972 | } // namespace update_client |