OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/trace_event/trace_event_system_stats_monitor.h" | 5 #include "base/trace_event/trace_event_system_stats_monitor.h" |
6 | 6 |
7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "base/threading/thread_local_storage.h" | 15 #include "base/threading/thread_local_storage.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 namespace debug { | 19 namespace trace_event { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 ///////////////////////////////////////////////////////////////////////////// | 23 ///////////////////////////////////////////////////////////////////////////// |
24 // Holds profiled system stats until the tracing system needs to serialize it. | 24 // Holds profiled system stats until the tracing system needs to serialize it. |
25 class SystemStatsHolder : public base::debug::ConvertableToTraceFormat { | 25 class SystemStatsHolder : public base::trace_event::ConvertableToTraceFormat { |
26 public: | 26 public: |
27 SystemStatsHolder() { } | 27 SystemStatsHolder() { } |
28 | 28 |
29 // Fills system_metrics_ with profiled system memory and disk stats. | 29 // Fills system_metrics_ with profiled system memory and disk stats. |
30 // Uses the previous stats to compute rates if this is not the first profile. | 30 // Uses the previous stats to compute rates if this is not the first profile. |
31 void GetSystemProfilingStats(); | 31 void GetSystemProfilingStats(); |
32 | 32 |
33 // base::debug::ConvertableToTraceFormat overrides: | 33 // base::trace_event::ConvertableToTraceFormat overrides: |
34 void AppendAsTraceFormat(std::string* out) const override { | 34 void AppendAsTraceFormat(std::string* out) const override { |
35 AppendSystemProfileAsTraceFormat(system_stats_, out); | 35 AppendSystemProfileAsTraceFormat(system_stats_, out); |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 ~SystemStatsHolder() override {} | 39 ~SystemStatsHolder() override {} |
40 | 40 |
41 SystemMetrics system_stats_; | 41 SystemMetrics system_stats_; |
42 | 42 |
43 DISALLOW_COPY_AND_ASSIGN(SystemStatsHolder); | 43 DISALLOW_COPY_AND_ASSIGN(SystemStatsHolder); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return dump_timer_.IsRunning(); | 122 return dump_timer_.IsRunning(); |
123 } | 123 } |
124 | 124 |
125 void AppendSystemProfileAsTraceFormat(const SystemMetrics& system_metrics, | 125 void AppendSystemProfileAsTraceFormat(const SystemMetrics& system_metrics, |
126 std::string* output) { | 126 std::string* output) { |
127 std::string tmp; | 127 std::string tmp; |
128 base::JSONWriter::Write(system_metrics.ToValue().get(), &tmp); | 128 base::JSONWriter::Write(system_metrics.ToValue().get(), &tmp); |
129 *output += tmp; | 129 *output += tmp; |
130 } | 130 } |
131 | 131 |
132 } // namespace debug | 132 } // namespace trace_event |
133 } // namespace base | 133 } // namespace base |
OLD | NEW |