OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H | 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H |
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H | 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // Resets time for triggering dump to account for minimum time between the | 44 // Resets time for triggering dump to account for minimum time between the |
45 // dumps. | 45 // dumps. |
46 void NotifyDumpTriggered(); | 46 void NotifyDumpTriggered(); |
47 | 47 |
48 // Disables all triggers. | 48 // Disables all triggers. |
49 void DisableAllTriggers(); | 49 void DisableAllTriggers(); |
50 | 50 |
51 private: | 51 private: |
52 friend class MemoryDumpManagerTest; | 52 friend class MemoryDumpManagerTest; |
| 53 friend class MemoryDumpSchedulerPollingTest; |
53 FRIEND_TEST_ALL_PREFIXES(MemoryDumpManagerTest, TestPollingOnDumpThread); | 54 FRIEND_TEST_ALL_PREFIXES(MemoryDumpManagerTest, TestPollingOnDumpThread); |
54 | 55 |
55 // Helper class to schdule periodic memory dumps. | 56 // Helper class to schdule periodic memory dumps. |
56 struct PeriodicTriggerState { | 57 struct BASE_EXPORT PeriodicTriggerState { |
57 PeriodicTriggerState(); | 58 PeriodicTriggerState(); |
58 ~PeriodicTriggerState(); | 59 ~PeriodicTriggerState(); |
59 | 60 |
60 bool is_configured; | 61 bool is_configured; |
61 | 62 |
62 RepeatingTimer timer; | 63 RepeatingTimer timer; |
63 uint32_t dump_count; | 64 uint32_t dump_count; |
64 uint32_t min_timer_period_ms; | 65 uint32_t min_timer_period_ms; |
65 uint32_t light_dumps_rate; | 66 uint32_t light_dumps_rate; |
66 uint32_t heavy_dumps_rate; | 67 uint32_t heavy_dumps_rate; |
67 | 68 |
68 uint32_t light_dump_period_ms; | 69 uint32_t light_dump_period_ms; |
69 uint32_t heavy_dump_period_ms; | 70 uint32_t heavy_dump_period_ms; |
70 | 71 |
71 DISALLOW_COPY_AND_ASSIGN(PeriodicTriggerState); | 72 DISALLOW_COPY_AND_ASSIGN(PeriodicTriggerState); |
72 }; | 73 }; |
73 | 74 |
74 struct PollingTriggerState { | 75 struct BASE_EXPORT PollingTriggerState { |
75 enum State { | 76 enum State { |
76 CONFIGURED, // Polling trigger was added. | 77 CONFIGURED, // Polling trigger was added. |
77 ENABLED, // Polling is running. | 78 ENABLED, // Polling is running. |
78 DISABLED // Polling is disabled. | 79 DISABLED // Polling is disabled. |
79 }; | 80 }; |
80 | 81 |
81 static const uint32_t kMaxNumMemorySamples = 50; | 82 static const uint32_t kMaxNumMemorySamples = 50; |
82 | 83 |
83 explicit PollingTriggerState( | 84 explicit PollingTriggerState( |
84 scoped_refptr<SingleThreadTaskRunner> polling_task_runner); | 85 scoped_refptr<SingleThreadTaskRunner> polling_task_runner); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 PeriodicTriggerState periodic_state_; | 133 PeriodicTriggerState periodic_state_; |
133 PollingTriggerState polling_state_; | 134 PollingTriggerState polling_state_; |
134 | 135 |
135 DISALLOW_COPY_AND_ASSIGN(MemoryDumpScheduler); | 136 DISALLOW_COPY_AND_ASSIGN(MemoryDumpScheduler); |
136 }; | 137 }; |
137 | 138 |
138 } // namespace trace_event | 139 } // namespace trace_event |
139 } // namespace base | 140 } // namespace base |
140 | 141 |
141 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H | 142 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H |
OLD | NEW |