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

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

Issue 2815573002: CHECK tasks posted by TaskRunner::PostTask (Closed)
Patch Set: +comment Created 3 years, 8 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 | « base/threading/worker_pool_win.cc ('k') | content/renderer/categorized_worker_pool.cc » ('j') | 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 "chrome/browser/after_startup_task_utils.h" 5 #include "chrome/browser/after_startup_task_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const int kMaxDelaySec = 10; 69 const int kMaxDelaySec = 10;
70 scoped_refptr<base::TaskRunner> target_runner = queued_task->task_runner; 70 scoped_refptr<base::TaskRunner> target_runner = queued_task->task_runner;
71 tracked_objects::Location from_here = queued_task->from_here; 71 tracked_objects::Location from_here = queued_task->from_here;
72 target_runner->PostDelayedTask( 72 target_runner->PostDelayedTask(
73 from_here, base::Bind(&RunTask, base::Passed(std::move(queued_task))), 73 from_here, base::Bind(&RunTask, base::Passed(std::move(queued_task))),
74 base::TimeDelta::FromSeconds(base::RandInt(kMinDelaySec, kMaxDelaySec))); 74 base::TimeDelta::FromSeconds(base::RandInt(kMinDelaySec, kMaxDelaySec)));
75 } 75 }
76 76
77 void QueueTask(std::unique_ptr<AfterStartupTask> queued_task) { 77 void QueueTask(std::unique_ptr<AfterStartupTask> queued_task) {
78 DCHECK(queued_task); 78 DCHECK(queued_task);
79 DCHECK(queued_task->task); 79
80 // Use CHECK instead of DCHECK to crash earlier. See http://crbug.com/711167
81 // for details.
82 CHECK(queued_task->task);
83
80 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 84 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
81 BrowserThread::PostTask( 85 BrowserThread::PostTask(
82 BrowserThread::UI, FROM_HERE, 86 BrowserThread::UI, FROM_HERE,
83 base::Bind(QueueTask, base::Passed(std::move(queued_task)))); 87 base::Bind(QueueTask, base::Passed(std::move(queued_task))));
84 return; 88 return;
85 } 89 }
86 90
87 // The flag may have been set while the task to invoke this method 91 // The flag may have been set while the task to invoke this method
88 // on the UI thread was inflight. 92 // on the UI thread was inflight.
89 if (IsBrowserStartupComplete()) { 93 if (IsBrowserStartupComplete()) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return ::IsBrowserStartupComplete(); 251 return ::IsBrowserStartupComplete();
248 } 252 }
249 253
250 void AfterStartupTaskUtils::UnsafeResetForTesting() { 254 void AfterStartupTaskUtils::UnsafeResetForTesting() {
251 DCHECK(g_after_startup_tasks.Get().empty()); 255 DCHECK(g_after_startup_tasks.Get().empty());
252 if (!IsBrowserStartupComplete()) 256 if (!IsBrowserStartupComplete())
253 return; 257 return;
254 g_startup_complete_flag.Get().UnsafeResetForTesting(); 258 g_startup_complete_flag.Get().UnsafeResetForTesting();
255 DCHECK(!IsBrowserStartupComplete()); 259 DCHECK(!IsBrowserStartupComplete());
256 } 260 }
OLDNEW
« no previous file with comments | « base/threading/worker_pool_win.cc ('k') | content/renderer/categorized_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698