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

Side by Side Diff: base/threading/worker_pool_win.cc

Issue 8429009: Enable tracking of objects by default (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « base/threading/worker_pool_posix.cc ('k') | base/tracked_objects.h » ('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 (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"
11 #include "base/tracked_objects.h" 11 #include "base/tracked_objects.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 namespace { 15 namespace {
16 16
17 struct PendingTask { 17 struct PendingTask {
18 PendingTask( 18 PendingTask(
19 const tracked_objects::Location& posted_from, 19 const tracked_objects::Location& posted_from,
20 const base::Closure& task) 20 const base::Closure& task)
21 : posted_from(posted_from), 21 : posted_from(posted_from),
22 task(task) { 22 task(task) {
23 #if defined(TRACK_ALL_TASK_OBJECTS) 23 birth_tally = tracked_objects::ThreadData::TallyABirthIfActive(posted_from);
24 post_births = tracked_objects::ThreadData::TallyABirthIfActive(posted_from);
25 time_posted = tracked_objects::ThreadData::Now(); 24 time_posted = tracked_objects::ThreadData::Now();
26 #endif // defined(TRACK_ALL_TASK_OBJECTS)
27 } 25 }
28 26
29 #if defined(TRACK_ALL_TASK_OBJECTS)
30 // Counter for location where the Closure was posted from. 27 // Counter for location where the Closure was posted from.
31 tracked_objects::Births* post_births; 28 tracked_objects::Births* birth_tally;
32 29
33 // Time the task was posted. 30 // Time the task was posted.
34 TimeTicks time_posted; 31 tracked_objects::TrackedTime time_posted;
35 #endif // defined(TRACK_ALL_TASK_OBJECTS)
36 32
37 // The site this PendingTask was posted from. 33 // The site this PendingTask was posted from.
38 tracked_objects::Location posted_from; 34 tracked_objects::Location posted_from;
39 35
40 // The task to run. 36 // The task to run.
41 base::Closure task; 37 base::Closure task;
42 }; 38 };
43 39
44 DWORD CALLBACK WorkItemCallback(void* param) { 40 DWORD CALLBACK WorkItemCallback(void* param) {
45 PendingTask* pending_task = static_cast<PendingTask*>(param); 41 PendingTask* pending_task = static_cast<PendingTask*>(param);
46 UNSHIPPED_TRACE_EVENT2("task", "WorkItemCallback::Run", 42 UNSHIPPED_TRACE_EVENT2("task", "WorkItemCallback::Run",
47 "src_file", pending_task->posted_from.file_name(), 43 "src_file", pending_task->posted_from.file_name(),
48 "src_func", pending_task->posted_from.function_name()); 44 "src_func", pending_task->posted_from.function_name());
49 45
50 #if defined(TRACK_ALL_TASK_OBJECTS) 46 tracked_objects::TrackedTime start_time = tracked_objects::ThreadData::Now();
51 TimeTicks start_of_run = tracked_objects::ThreadData::Now(); 47
52 #endif // defined(TRACK_ALL_TASK_OBJECTS)
53 pending_task->task.Run(); 48 pending_task->task.Run();
54 #if defined(TRACK_ALL_TASK_OBJECTS) 49
55 tracked_objects::ThreadData::TallyADeathIfActive(pending_task->post_births, 50 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
56 pending_task->time_posted, TimeTicks::TimeTicks(), start_of_run, 51 pending_task->birth_tally, pending_task->time_posted,
57 tracked_objects::ThreadData::Now()); 52 start_time, tracked_objects::ThreadData::Now());
58 #endif // defined(TRACK_ALL_TASK_OBJECTS)
59 53
60 delete pending_task; 54 delete pending_task;
61 return 0; 55 return 0;
62 } 56 }
63 57
64 // Takes ownership of |pending_task| 58 // Takes ownership of |pending_task|
65 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { 59 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) {
66 ULONG flags = 0; 60 ULONG flags = 0;
67 if (task_is_slow) 61 if (task_is_slow)
68 flags |= WT_EXECUTELONGFUNCTION; 62 flags |= WT_EXECUTELONGFUNCTION;
(...skipping 18 matching lines...) Expand all
87 return PostTaskInternal(pending_task, task_is_slow); 81 return PostTaskInternal(pending_task, task_is_slow);
88 } 82 }
89 83
90 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, 84 bool WorkerPool::PostTask(const tracked_objects::Location& from_here,
91 const base::Closure& task, bool task_is_slow) { 85 const base::Closure& task, bool task_is_slow) {
92 PendingTask* pending_task = new PendingTask(from_here, task); 86 PendingTask* pending_task = new PendingTask(from_here, task);
93 return PostTaskInternal(pending_task, task_is_slow); 87 return PostTaskInternal(pending_task, task_is_slow);
94 } 88 }
95 89
96 } // namespace base 90 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/worker_pool_posix.cc ('k') | base/tracked_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698