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

Side by Side Diff: components/component_updater/component_updater_service.cc

Issue 2494343002: Fix for potential crash due to scheduling an empty callback. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/component_updater/component_updater_service.h" 5 #include "components/component_updater/component_updater_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 246
247 callback.Run(); // Unblock the request if the request can't be throttled. 247 callback.Run(); // Unblock the request if the request can't be throttled.
248 } 248 }
249 249
250 void CrxUpdateService::OnDemandUpdate(const std::string& id, 250 void CrxUpdateService::OnDemandUpdate(const std::string& id,
251 const Callback& callback) { 251 const Callback& callback) {
252 DCHECK(thread_checker_.CalledOnValidThread()); 252 DCHECK(thread_checker_.CalledOnValidThread());
253 253
254 if (!GetComponent(id)) { 254 if (!GetComponent(id)) {
255 base::ThreadTaskRunnerHandle::Get()->PostTask( 255 if (!callback.is_null()) {
256 FROM_HERE, 256 base::ThreadTaskRunnerHandle::Get()->PostTask(
257 base::Bind(callback, update_client::Error::INVALID_ARGUMENT)); 257 FROM_HERE,
258 base::Bind(callback, update_client::Error::INVALID_ARGUMENT));
259 }
258 return; 260 return;
259 } 261 }
260 262
261 OnDemandUpdateInternal(id, callback); 263 OnDemandUpdateInternal(id, callback);
262 } 264 }
263 265
264 bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) { 266 bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) {
265 DCHECK(thread_checker_.CalledOnValidThread()); 267 DCHECK(thread_checker_.CalledOnValidThread());
266 268
267 DCHECK(GetComponent(id)); 269 DCHECK(GetComponent(id));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // is the job of the browser process. 459 // is the job of the browser process.
458 // TODO(sorin): consider making this a singleton. 460 // TODO(sorin): consider making this a singleton.
459 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory( 461 std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory(
460 const scoped_refptr<Configurator>& config) { 462 const scoped_refptr<Configurator>& config) {
461 DCHECK(config); 463 DCHECK(config);
462 auto update_client = update_client::UpdateClientFactory(config); 464 auto update_client = update_client::UpdateClientFactory(config);
463 return base::MakeUnique<CrxUpdateService>(config, std::move(update_client)); 465 return base::MakeUnique<CrxUpdateService>(config, std::move(update_client));
464 } 466 }
465 467
466 } // namespace component_updater 468 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698