OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_TRACE_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_TRACE_CONTROLLER_H_ |
6 #define CONTENT_BROWSER_TRACE_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_TRACE_CONTROLLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/memory/ref_counted_memory.h" |
13 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
15 | 16 |
16 class CommandLine; | 17 class CommandLine; |
17 class TraceMessageFilter; | 18 class TraceMessageFilter; |
18 | 19 |
19 // Objects interested in receiving trace data derive from TraceSubscriber. | 20 // Objects interested in receiving trace data derive from TraceSubscriber. |
20 // See also: trace_message_filter.h | 21 // See also: trace_message_filter.h |
21 // See also: child_trace_message_filter.h | 22 // See also: child_trace_message_filter.h |
22 class CONTENT_EXPORT TraceSubscriber { | 23 class CONTENT_EXPORT TraceSubscriber { |
23 public: | 24 public: |
24 // Called once after TraceController::EndTracingAsync. | 25 // Called once after TraceController::EndTracingAsync. |
25 virtual void OnEndTracingComplete() = 0; | 26 virtual void OnEndTracingComplete() = 0; |
26 // Called 0 or more times between TraceController::BeginTracing and | 27 // Called 0 or more times between TraceController::BeginTracing and |
27 // OnEndTracingComplete. Use base::debug::TraceResultBuffer to convert one or | 28 // OnEndTracingComplete. Use base::debug::TraceResultBuffer to convert one or |
28 // more trace fragments to JSON. | 29 // more trace fragments to JSON. |
29 virtual void OnTraceDataCollected(const std::string& trace_fragment) = 0; | 30 virtual void OnTraceDataCollected( |
| 31 const scoped_refptr<base::RefCountedString>& trace_fragment) = 0; |
30 // Called once after TraceController::GetKnownCategoriesAsync. | 32 // Called once after TraceController::GetKnownCategoriesAsync. |
31 virtual void OnKnownCategoriesCollected( | 33 virtual void OnKnownCategoriesCollected( |
32 const std::set<std::string>& known_categories); | 34 const std::set<std::string>& known_categories); |
33 virtual void OnTraceBufferPercentFullReply(float percent_full); | 35 virtual void OnTraceBufferPercentFullReply(float percent_full); |
34 | 36 |
35 protected: | 37 protected: |
36 virtual ~TraceSubscriber(); | 38 virtual ~TraceSubscriber(); |
37 }; | 39 }; |
38 | 40 |
39 // TraceController is used on the browser processes to enable/disable | 41 // TraceController is used on the browser processes to enable/disable |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 (subscriber_ == NULL || subscriber == subscriber_); | 149 (subscriber_ == NULL || subscriber == subscriber_); |
148 } | 150 } |
149 | 151 |
150 // Methods for use by TraceMessageFilter. | 152 // Methods for use by TraceMessageFilter. |
151 | 153 |
152 void AddFilter(TraceMessageFilter* filter); | 154 void AddFilter(TraceMessageFilter* filter); |
153 void RemoveFilter(TraceMessageFilter* filter); | 155 void RemoveFilter(TraceMessageFilter* filter); |
154 void OnTracingBegan(TraceSubscriber* subscriber); | 156 void OnTracingBegan(TraceSubscriber* subscriber); |
155 void OnEndTracingAck(const std::vector<std::string>& known_categories); | 157 void OnEndTracingAck(const std::vector<std::string>& known_categories); |
156 void OnTraceDataCollected( | 158 void OnTraceDataCollected( |
157 const scoped_refptr<base::debug::TraceLog::RefCountedString>& | 159 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
158 events_str_ptr); | |
159 void OnTraceBufferFull(); | 160 void OnTraceBufferFull(); |
160 void OnTraceBufferPercentFullReply(float percent_full); | 161 void OnTraceBufferPercentFullReply(float percent_full); |
161 | 162 |
162 FilterMap filters_; | 163 FilterMap filters_; |
163 TraceSubscriber* subscriber_; | 164 TraceSubscriber* subscriber_; |
164 // Pending acks for EndTracingAsync: | 165 // Pending acks for EndTracingAsync: |
165 int pending_end_ack_count_; | 166 int pending_end_ack_count_; |
166 // Pending acks for GetTraceBufferPercentFullAsync: | 167 // Pending acks for GetTraceBufferPercentFullAsync: |
167 int pending_bpf_ack_count_; | 168 int pending_bpf_ack_count_; |
168 float maximum_bpf_; | 169 float maximum_bpf_; |
169 bool is_tracing_; | 170 bool is_tracing_; |
170 bool is_get_categories_; | 171 bool is_get_categories_; |
171 std::set<std::string> known_categories_; | 172 std::set<std::string> known_categories_; |
172 std::vector<std::string> included_categories_; | 173 std::vector<std::string> included_categories_; |
173 std::vector<std::string> excluded_categories_; | 174 std::vector<std::string> excluded_categories_; |
174 | 175 |
175 DISALLOW_COPY_AND_ASSIGN(TraceController); | 176 DISALLOW_COPY_AND_ASSIGN(TraceController); |
176 }; | 177 }; |
177 | 178 |
178 #endif // CONTENT_BROWSER_TRACE_CONTROLLER_H_ | 179 #endif // CONTENT_BROWSER_TRACE_CONTROLLER_H_ |
179 | 180 |
OLD | NEW |