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

Side by Side Diff: content/renderer/v8_heap_statistics_monitor.h

Issue 196103006: Add V8 heap statistics in a time-line manner in tracing. (Closed) Base URL: /home/dmikurube/repos/chromium@work-sai-json
Patch Set: rebased Created 6 years, 5 months 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
OLDNEW
(Empty)
1 // Copyright 2013 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 CONTENT_RENDERER_V8_STATS_MONITOR_H_
6 #define CONTENT_RENDERER_V8_STATS_MONITOR_H_
7
8 #include "base/base_export.h"
9 #include "base/debug/trace_event_impl.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/timer/timer.h"
14 #include "content/public/renderer/v8_heap_statistics_collector.h"
15
16 namespace base {
17 class SingleThreadTaskRunner;
18 }
19
20 namespace content {
21
22 // Watches for chrome://tracing to be enabled or disabled. When tracing is
23 // enabled, also enables system events profiling. This class is the preferred
24 // way to turn system tracing on and off.
25 class BASE_EXPORT V8HeapStatisticsMonitor
26 : public base::debug::TraceLog::EnabledStateObserver {
27 public:
28 // Length of time interval between stat profiles.
29 static const int kSamplingIntervalMilliseconds = 2000;
30
31 // |task_runner| must be the primary thread for the client
32 // process, e.g. the UI thread in a browser.
33 explicit V8HeapStatisticsMonitor(
34 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
35
36 virtual ~V8HeapStatisticsMonitor();
37
38 // base::debug::TraceLog::EnabledStateChangedObserver overrides:
39 virtual void OnTraceLogEnabled() OVERRIDE;
40 virtual void OnTraceLogDisabled() OVERRIDE;
41
42
43 bool IsMonitoring() const;
44 void BeginAnotherDump() { BeginDumpingHeapStats(); }
45
46 private:
47 FRIEND_TEST_ALL_PREFIXES(TraceSystemHeapStatisticsMonitorTest,
48 V8HeapStatisticsMonitor);
49
50 void StartProfiling();
51
52 void StopProfiling();
53
54 void BeginDumpingHeapStats();
55 void FinalizeDumpOfHeapStats(const V8HeapStatisticsCollector::Statistics&);
56
57 bool dump_pending_;
58 V8HeapStatisticsCollector::Statistics last_dumped_stats_;
59
60 // Ensures the observer starts and stops tracing on the primary thread.
61 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
62
63 // Timer to schedule system profile dumps.
64 base::RepeatingTimer<V8HeapStatisticsMonitor> dump_timer_;
65
66 base::WeakPtrFactory<V8HeapStatisticsMonitor> weak_factory_;
67
68 DISALLOW_COPY_AND_ASSIGN(V8HeapStatisticsMonitor);
69 };
70
71 } // namespace content
72
73 #endif // CONTENT_RENDERER_V8_STATS_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698