OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // The task to run. | 36 // The task to run. |
37 base::Closure task; | 37 base::Closure task; |
38 }; | 38 }; |
39 | 39 |
40 DWORD CALLBACK WorkItemCallback(void* param) { | 40 DWORD CALLBACK WorkItemCallback(void* param) { |
41 PendingTask* pending_task = static_cast<PendingTask*>(param); | 41 PendingTask* pending_task = static_cast<PendingTask*>(param); |
42 UNSHIPPED_TRACE_EVENT2("task", "WorkItemCallback::Run", | 42 UNSHIPPED_TRACE_EVENT2("task", "WorkItemCallback::Run", |
43 "src_file", pending_task->posted_from.file_name(), | 43 "src_file", pending_task->posted_from.file_name(), |
44 "src_func", pending_task->posted_from.function_name()); | 44 "src_func", pending_task->posted_from.function_name()); |
45 | 45 |
46 tracked_objects::TrackedTime start_time = tracked_objects::ThreadData::Now(); | 46 tracked_objects::TrackedTime start_time = |
| 47 tracked_objects::ThreadData::NowForStartOfRun(); |
47 | 48 |
48 pending_task->task.Run(); | 49 pending_task->task.Run(); |
49 | 50 |
50 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( | 51 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( |
51 pending_task->birth_tally, pending_task->time_posted, | 52 pending_task->birth_tally, pending_task->time_posted, |
52 start_time, tracked_objects::ThreadData::Now()); | 53 start_time, tracked_objects::ThreadData::NowForEndOfRun()); |
53 | 54 |
54 delete pending_task; | 55 delete pending_task; |
55 return 0; | 56 return 0; |
56 } | 57 } |
57 | 58 |
58 // Takes ownership of |pending_task| | 59 // Takes ownership of |pending_task| |
59 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { | 60 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { |
60 ULONG flags = 0; | 61 ULONG flags = 0; |
61 if (task_is_slow) | 62 if (task_is_slow) |
62 flags |= WT_EXECUTELONGFUNCTION; | 63 flags |= WT_EXECUTELONGFUNCTION; |
(...skipping 18 matching lines...) Expand all Loading... |
81 return PostTaskInternal(pending_task, task_is_slow); | 82 return PostTaskInternal(pending_task, task_is_slow); |
82 } | 83 } |
83 | 84 |
84 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, | 85 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, |
85 const base::Closure& task, bool task_is_slow) { | 86 const base::Closure& task, bool task_is_slow) { |
86 PendingTask* pending_task = new PendingTask(from_here, task); | 87 PendingTask* pending_task = new PendingTask(from_here, task); |
87 return PostTaskInternal(pending_task, task_is_slow); | 88 return PostTaskInternal(pending_task, task_is_slow); |
88 } | 89 } |
89 | 90 |
90 } // namespace base | 91 } // namespace base |
OLD | NEW |