OLD | NEW |
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 "base/threading/worker_pool.h" | 5 #include "base/threading/worker_pool.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( | 39 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( |
40 pending_task->birth_tally, pending_task->time_posted, stopwatch); | 40 pending_task->birth_tally, pending_task->time_posted, stopwatch); |
41 | 41 |
42 delete pending_task; | 42 delete pending_task; |
43 return 0; | 43 return 0; |
44 } | 44 } |
45 | 45 |
46 // Takes ownership of |pending_task| | 46 // Takes ownership of |pending_task| |
47 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { | 47 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { |
48 DCHECK(pending_task->task); | 48 // Use CHECK instead of DCHECK to crash earlier. See http://crbug.com/711167 |
| 49 // for details. |
| 50 CHECK(pending_task->task); |
49 | 51 |
50 ULONG flags = 0; | 52 ULONG flags = 0; |
51 if (task_is_slow) | 53 if (task_is_slow) |
52 flags |= WT_EXECUTELONGFUNCTION; | 54 flags |= WT_EXECUTELONGFUNCTION; |
53 | 55 |
54 if (!QueueUserWorkItem(WorkItemCallback, pending_task, flags)) { | 56 if (!QueueUserWorkItem(WorkItemCallback, pending_task, flags)) { |
55 DPLOG(ERROR) << "QueueUserWorkItem failed"; | 57 DPLOG(ERROR) << "QueueUserWorkItem failed"; |
56 delete pending_task; | 58 delete pending_task; |
57 return false; | 59 return false; |
58 } | 60 } |
(...skipping 10 matching lines...) Expand all Loading... |
69 PendingTask* pending_task = new PendingTask(from_here, std::move(task)); | 71 PendingTask* pending_task = new PendingTask(from_here, std::move(task)); |
70 return PostTaskInternal(pending_task, task_is_slow); | 72 return PostTaskInternal(pending_task, task_is_slow); |
71 } | 73 } |
72 | 74 |
73 // static | 75 // static |
74 bool WorkerPool::RunsTasksOnCurrentThread() { | 76 bool WorkerPool::RunsTasksOnCurrentThread() { |
75 return GetWorkerPoolRunningOnThisThread()->Get(); | 77 return GetWorkerPoolRunningOnThisThread()->Get(); |
76 } | 78 } |
77 | 79 |
78 } // namespace base | 80 } // namespace base |
OLD | NEW |