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