OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef TracedTask_h | 5 #ifndef TracedTask_h |
6 #define TracedTask_h | 6 #define TracedTask_h |
7 | 7 |
8 #include "platform/Task.h" | 8 #include "platform/Task.h" |
9 #include "platform/TraceEvent.h" | 9 #include "platform/TraceEvent.h" |
10 #include "platform/TraceLocation.h" | 10 #include "platform/TraceLocation.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 #ifdef MANGLE_COMPILES_ON_WIN_OK | 14 #ifdef MANGLE_COMPILES_ON_WIN_OK |
15 // TODO: Once win version compiles correctly when using TRACE_ID_MANGLE remove | 15 // TODO: Once win version compiles correctly when using TRACE_ID_MANGLE remove |
16 // the ifdef to always mangle | 16 // the ifdef to always mangle |
17 #define MANGLE(id) TRACE_ID_MANGLE(id) | 17 #define MANGLE(id) TRACE_ID_MANGLE(id) |
18 #else | 18 #else |
19 #define MANGLE(id) (id) | 19 #define MANGLE(id) (id) |
20 #endif | 20 #endif |
21 | 21 |
22 class TracedTask { | 22 class TracedTask { |
Sami
2014/09/24 14:00:40
Note to self: this should probably be renamed as P
rmcilroy
2014/09/29 17:42:58
Acknowledged.
| |
23 public: | 23 public: |
24 typedef Function<void()> Task; | 24 virtual void run() const = 0; |
25 virtual ~TracedTask(); | |
25 | 26 |
26 void run() const; | 27 protected: |
28 TracedTask(const TraceLocation&, const char* traceName); | |
29 void traceRun() const; | |
27 | 30 |
28 private: | 31 private: |
29 friend class Scheduler; | |
30 TracedTask(const Task&, const TraceLocation&, const char* traceName); | |
31 | 32 |
32 // Declared volatile as it is atomically incremented. | 33 // Declared volatile as it is atomically incremented. |
33 static volatile int s_nextFlowTraceID; | 34 static volatile int s_nextFlowTraceID; |
34 | 35 |
35 uint64_t m_flowTraceID; | 36 uint64_t m_flowTraceID; |
36 Task m_task; | |
37 TraceLocation m_location; | 37 TraceLocation m_location; |
38 const char* m_traceName; | 38 const char* m_traceName; |
39 }; | 39 }; |
40 | 40 |
41 class TracedStandardTask : public TracedTask { | |
42 public: | |
43 typedef Function<void()> Task; | |
44 | |
45 virtual void run() const; | |
46 virtual ~TracedStandardTask(); | |
47 | |
48 private: | |
49 friend class Scheduler; | |
50 | |
51 TracedStandardTask(const Task&, const TraceLocation&, const char* traceName) ; | |
52 | |
53 Task m_task; | |
54 }; | |
55 | |
56 class TracedIdleTask : public TracedTask { | |
57 public: | |
58 typedef Function<void(double deadlineSeconds)> IdleTask; | |
59 | |
60 virtual void run() const; | |
61 virtual ~TracedIdleTask(); | |
62 | |
63 private: | |
64 friend class Scheduler; | |
65 | |
66 TracedIdleTask(const IdleTask&, const TraceLocation&, const char* traceName) ; | |
67 | |
68 IdleTask m_idleTask; | |
69 }; | |
70 | |
41 } // namespace blink | 71 } // namespace blink |
42 | 72 |
43 #endif // TracedTask_h | 73 #endif // TracedTask_h |
OLD | NEW |