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

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 440893002: RundownTaskCounter needs to use a non-nestable task to block on the completion of already scheduled… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/browser_process_impl.h" 5 #include "chrome/browser/browser_process_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 : count_(1), waitable_event_(true, false) { 419 : count_(1), waitable_event_(true, false) {
420 } 420 }
421 421
422 void RundownTaskCounter::Post(base::SequencedTaskRunner* task_runner) { 422 void RundownTaskCounter::Post(base::SequencedTaskRunner* task_runner) {
423 // As the count starts off at one, it should never get to zero unless 423 // As the count starts off at one, it should never get to zero unless
424 // TimedWait has been called. 424 // TimedWait has been called.
425 DCHECK(!base::AtomicRefCountIsZero(&count_)); 425 DCHECK(!base::AtomicRefCountIsZero(&count_));
426 426
427 base::AtomicRefCountInc(&count_); 427 base::AtomicRefCountInc(&count_);
428 428
429 task_runner->PostTask(FROM_HERE, 429 // The task must be non-nestable to guarantee that it runs after all tasks
430 // currently scheduled on |task_runner| have completed.
431 task_runner->PostNonNestableTask(FROM_HERE,
430 base::Bind(&RundownTaskCounter::Decrement, this)); 432 base::Bind(&RundownTaskCounter::Decrement, this));
431 } 433 }
432 434
433 void RundownTaskCounter::Decrement() { 435 void RundownTaskCounter::Decrement() {
434 if (!base::AtomicRefCountDec(&count_)) 436 if (!base::AtomicRefCountDec(&count_))
435 waitable_event_.Signal(); 437 waitable_event_.Signal();
436 } 438 }
437 439
438 bool RundownTaskCounter::TimedWait(const base::TimeDelta& max_time) { 440 bool RundownTaskCounter::TimedWait(const base::TimeDelta& max_time) {
439 // Decrement the excess count from the constructor. 441 // Decrement the excess count from the constructor.
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 } 1203 }
1202 1204
1203 void BrowserProcessImpl::OnAutoupdateTimer() { 1205 void BrowserProcessImpl::OnAutoupdateTimer() {
1204 if (CanAutorestartForUpdate()) { 1206 if (CanAutorestartForUpdate()) {
1205 DLOG(WARNING) << "Detected update. Restarting browser."; 1207 DLOG(WARNING) << "Detected update. Restarting browser.";
1206 RestartBackgroundInstance(); 1208 RestartBackgroundInstance();
1207 } 1209 }
1208 } 1210 }
1209 1211
1210 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1212 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
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