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 { |
23 public: | 23 public: |
| 24 virtual void run() const = 0; |
| 25 virtual ~TracedTask(); |
| 26 |
| 27 protected: |
| 28 TracedTask(const TraceLocation&, const char* traceName); |
| 29 void endFlowTraceEvent() const; |
| 30 |
| 31 TraceLocation m_location; |
| 32 const char* m_traceName; |
| 33 |
| 34 private: |
| 35 // Declared volatile as it is atomically incremented. |
| 36 static volatile int s_nextFlowTraceID; |
| 37 uint64_t m_flowTraceID; |
| 38 }; |
| 39 |
| 40 class TracedStandardTask : public TracedTask { |
| 41 public: |
24 typedef Function<void()> Task; | 42 typedef Function<void()> Task; |
25 | 43 |
26 void run() const; | 44 virtual void run() const; |
| 45 virtual ~TracedStandardTask(); |
27 | 46 |
28 private: | 47 private: |
29 friend class Scheduler; | 48 friend class Scheduler; |
30 TracedTask(const Task&, const TraceLocation&, const char* traceName); | |
31 | 49 |
32 // Declared volatile as it is atomically incremented. | 50 TracedStandardTask(const Task&, const TraceLocation&, const char* traceName)
; |
33 static volatile int s_nextFlowTraceID; | |
34 | 51 |
35 uint64_t m_flowTraceID; | |
36 Task m_task; | 52 Task m_task; |
37 TraceLocation m_location; | 53 }; |
38 const char* m_traceName; | 54 |
| 55 class TracedIdleTask : public TracedTask { |
| 56 public: |
| 57 typedef Function<void(double deadlineSeconds)> IdleTask; |
| 58 |
| 59 virtual void run() const; |
| 60 virtual ~TracedIdleTask(); |
| 61 |
| 62 private: |
| 63 friend class Scheduler; |
| 64 |
| 65 TracedIdleTask(const IdleTask&, const TraceLocation&, const char* traceName)
; |
| 66 |
| 67 IdleTask m_idleTask; |
39 }; | 68 }; |
40 | 69 |
41 } // namespace blink | 70 } // namespace blink |
42 | 71 |
43 #endif // TracedTask_h | 72 #endif // TracedTask_h |
OLD | NEW |