Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_TRIGGER_H | |
| 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_TRIGGER_H | |
| 7 | |
| 8 #include "base/atomicops.h" | |
| 9 #include "base/base_export.h" | |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/timer/timer.h" | |
| 13 #include "base/trace_event/trace_config.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class SingleThreadTaskRunner; | |
| 17 | |
| 18 namespace trace_event { | |
| 19 | |
| 20 class MemoryDumpManager; | |
| 21 | |
| 22 // Sets up memory dump triggers to start global dump requests based on the trace | |
| 23 // config. | |
| 24 class BASE_EXPORT MemoryDumpTrigger { | |
|
Primiano Tucci (use gerrit)
2017/01/18 16:16:06
I think a better name for this class would be Memo
ssid
2017/01/20 23:07:27
Makes sense. I didn't find a better name.
| |
| 25 public: | |
| 26 using TriggerList = std::vector<TraceConfig::MemoryDumpConfig::Trigger>; | |
| 27 | |
| 28 MemoryDumpTrigger(MemoryDumpManager* mdm_, bool is_coordinator); | |
| 29 ~MemoryDumpTrigger(); | |
| 30 | |
| 31 // Sets up peak dump triggers for global memory dumps according to | |
| 32 // |trigger_list|. | |
| 33 void SetupPeakTriggers( | |
|
Primiano Tucci (use gerrit)
2017/01/18 16:16:07
This one I find a bit confusing. You require to pa
ssid
2017/01/20 23:07:27
2 reasons:
1. Maybe in future we will need more th
| |
| 34 const TriggerList& trigger_list, | |
| 35 scoped_refptr<SingleThreadTaskRunner> polling_task_runner); | |
| 36 | |
| 37 // Sets up periodic dump triggers for global memory dumps according to | |
| 38 // |trigger_list|. | |
| 39 void SetupPeriodicTriggers(const TriggerList& trigger_list); | |
| 40 | |
| 41 // Disables all triggers. It must be called after the polling task runner | |
| 42 // stops running. | |
| 43 void Disable(); | |
|
Primiano Tucci (use gerrit)
2017/01/18 16:16:07
I'd be a bit more explicit and call this either Cl
ssid
2017/01/20 23:07:27
Done.
| |
| 44 | |
| 45 // Returns true if periodic timer is running. | |
| 46 bool IsPeriodicDumpTimerRunning() const; | |
|
Primiano Tucci (use gerrit)
2017/01/18 16:16:07
"Timer running" here is an implementation detail.
ssid
2017/01/20 23:07:27
Done.
| |
| 47 | |
| 48 private: | |
| 49 FRIEND_TEST_ALL_PREFIXES(MemoryDumpManagerTest, TestTriggerDumpAtPeak); | |
| 50 FRIEND_TEST_ALL_PREFIXES(MemoryDumpManagerTest, TestPollingOnDumpThread); | |
| 51 | |
| 52 static void SetPollingIntervalForTesting(uint32_t interval); | |
| 53 | |
| 54 // Periodically called by the timer. | |
| 55 void RequestPeriodicGlobalDump(); | |
| 56 | |
| 57 // Called for polling memory usage and trigger dumps if peak is detected. | |
| 58 void PollMemoryOnPollingThread(); | |
| 59 | |
| 60 MemoryDumpManager* mdm_; | |
| 61 | |
| 62 // When true, this trigger is in charge of coordinating periodic dumps. | |
| 63 bool is_coordinator_; | |
|
Primiano Tucci (use gerrit)
2017/01/18 16:16:07
Hmm I don't think this should be here, at most in
ssid
2017/01/20 23:07:27
Yes I think it's fair to keep this in MDM. I moved
| |
| 64 | |
| 65 // Timer for periodic dumps. | |
| 66 RepeatingTimer timer_; | |
| 67 | |
| 68 subtle::AtomicWord polling_enabled_; | |
| 69 scoped_refptr<SingleThreadTaskRunner> polling_task_runner_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(MemoryDumpTrigger); | |
| 72 }; | |
| 73 | |
| 74 } // namespace trace_event | |
| 75 } // namespace base | |
| 76 | |
| 77 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_TRIGGER_H | |
| OLD | NEW |