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

Side by Side Diff: components/update_client/update_engine.cc

Issue 2853903002: Handle the case where the update check for components fails. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/update_client/update_client_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 FROM_HERE, base::Bind(&UpdateEngine::UpdateCheckComplete, 212 FROM_HERE, base::Bind(&UpdateEngine::UpdateCheckComplete,
213 base::Unretained(this), it)); 213 base::Unretained(this), it));
214 } 214 }
215 215
216 void UpdateEngine::UpdateCheckComplete(const UpdateContextIterator& it) { 216 void UpdateEngine::UpdateCheckComplete(const UpdateContextIterator& it) {
217 DCHECK(thread_checker_.CalledOnValidThread()); 217 DCHECK(thread_checker_.CalledOnValidThread());
218 218
219 const auto& update_context = *it; 219 const auto& update_context = *it;
220 DCHECK(update_context); 220 DCHECK(update_context);
221 221
222 if (update_context->update_check_error) {
223 base::ThreadTaskRunnerHandle::Get()->PostTask(
224 FROM_HERE,
225 base::Bind(&UpdateEngine::UpdateComplete, base::Unretained(this), it,
226 Error::UPDATE_CHECK_ERROR));
227 return;
228 }
229
230 for (const auto& id : update_context->ids) 222 for (const auto& id : update_context->ids)
231 update_context->component_queue.push(id); 223 update_context->component_queue.push(id);
232 224
233 base::ThreadTaskRunnerHandle::Get()->PostTask( 225 base::ThreadTaskRunnerHandle::Get()->PostTask(
234 FROM_HERE, 226 FROM_HERE,
235 base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it)); 227 base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it));
236 } 228 }
237 229
238 void UpdateEngine::HandleComponent(const UpdateContextIterator& it) { 230 void UpdateEngine::HandleComponent(const UpdateContextIterator& it) {
239 DCHECK(thread_checker_.CalledOnValidThread()); 231 DCHECK(thread_checker_.CalledOnValidThread());
240 232
241 auto& update_context = *it; 233 auto& update_context = *it;
242 DCHECK(update_context); 234 DCHECK(update_context);
243 235
244 auto& queue = update_context->component_queue; 236 auto& queue = update_context->component_queue;
245 237
246 if (queue.empty()) { 238 if (queue.empty()) {
239 const Error error = update_context->update_check_error
240 ? Error::UPDATE_CHECK_ERROR
241 : Error::NONE;
247 base::ThreadTaskRunnerHandle::Get()->PostTask( 242 base::ThreadTaskRunnerHandle::Get()->PostTask(
248 FROM_HERE, base::Bind(&UpdateEngine::UpdateComplete, 243 FROM_HERE, base::Bind(&UpdateEngine::UpdateComplete,
249 base::Unretained(this), it, Error::NONE)); 244 base::Unretained(this), it, error));
250 return; 245 return;
251 } 246 }
252 247
253 const auto& id = queue.front(); 248 const auto& id = queue.front();
254 DCHECK_EQ(1u, update_context->components.count(id)); 249 DCHECK_EQ(1u, update_context->components.count(id));
255 const auto& component = update_context->components.at(id); 250 const auto& component = update_context->components.at(id);
256 DCHECK(component); 251 DCHECK(component);
257 252
258 auto& next_update_delay = (*it)->next_update_delay; 253 auto& next_update_delay = (*it)->next_update_delay;
259 if (!next_update_delay.is_zero() && component->IsUpdateAvailable()) { 254 if (!next_update_delay.is_zero() && component->IsUpdateAvailable()) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 component->Uninstall(version, reason); 361 component->Uninstall(version, reason);
367 362
368 update_context->component_queue.push(id); 363 update_context->component_queue.push(id);
369 364
370 base::ThreadTaskRunnerHandle::Get()->PostTask( 365 base::ThreadTaskRunnerHandle::Get()->PostTask(
371 FROM_HERE, 366 FROM_HERE,
372 base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it)); 367 base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it));
373 } 368 }
374 369
375 } // namespace update_client 370 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/update_client_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698