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

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

Issue 2785943004: DCHECK tasks posted by TaskRunner::PostTask (Closed)
Patch Set: win build fix 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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 const int kMinDelaySec = 0; 68 const int kMinDelaySec = 0;
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);
79 CHECK(queued_task->task);
80
78 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 81 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
79 BrowserThread::PostTask( 82 BrowserThread::PostTask(
80 BrowserThread::UI, FROM_HERE, 83 BrowserThread::UI, FROM_HERE,
81 base::Bind(QueueTask, base::Passed(std::move(queued_task)))); 84 base::Bind(QueueTask, base::Passed(std::move(queued_task))));
82 return; 85 return;
83 } 86 }
84 87
85 // The flag may have been set while the task to invoke this method 88 // The flag may have been set while the task to invoke this method
86 // on the UI thread was inflight. 89 // on the UI thread was inflight.
87 if (IsBrowserStartupComplete()) { 90 if (IsBrowserStartupComplete()) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return ::IsBrowserStartupComplete(); 248 return ::IsBrowserStartupComplete();
246 } 249 }
247 250
248 void AfterStartupTaskUtils::UnsafeResetForTesting() { 251 void AfterStartupTaskUtils::UnsafeResetForTesting() {
249 DCHECK(g_after_startup_tasks.Get().empty()); 252 DCHECK(g_after_startup_tasks.Get().empty());
250 if (!IsBrowserStartupComplete()) 253 if (!IsBrowserStartupComplete())
251 return; 254 return;
252 g_startup_complete_flag.Get().UnsafeResetForTesting(); 255 g_startup_complete_flag.Get().UnsafeResetForTesting();
253 DCHECK(!IsBrowserStartupComplete()); 256 DCHECK(!IsBrowserStartupComplete());
254 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698