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/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 | 15 |
16 class TraceMessageFilter; | 16 class TraceMessageFilter; |
17 | 17 |
18 // Objects interested in receiving trace data derive from TraceSubscriber. | 18 // Objects interested in receiving trace data derive from TraceSubscriber. |
19 // See also: trace_message_filter.h | 19 // See also: trace_message_filter.h |
20 // See also: child_trace_message_filter.h | 20 // See also: child_trace_message_filter.h |
21 class CONTENT_EXPORT TraceSubscriber { | 21 class CONTENT_EXPORT TraceSubscriber { |
22 public: | 22 public: |
23 // Called once after TraceController::EndTracingAsync. | 23 // Called once after TraceController::EndTracingAsync. |
24 virtual void OnEndTracingComplete() = 0; | 24 virtual void OnEndTracingComplete() = 0; |
25 // Called 0 or more times between TraceController::BeginTracing and | 25 // Called 0 or more times between TraceController::BeginTracing and |
26 // OnEndTracingComplete. Use base::debug::TraceResultBuffer to convert one or | 26 // OnEndTracingComplete. |
27 // more trace fragments to JSON. | 27 virtual void OnTraceDataCollected(const std::string& json_events) = 0; |
28 virtual void OnTraceDataCollected(const std::string& trace_fragment) = 0; | |
29 // Called once after TraceController::GetKnownCategoriesAsync. | 28 // Called once after TraceController::GetKnownCategoriesAsync. |
30 virtual void OnKnownCategoriesCollected( | 29 virtual void OnKnownCategoriesCollected( |
31 const std::set<std::string>& known_categories) {} | 30 const std::set<std::string>& known_categories) {} |
32 virtual void OnTraceBufferPercentFullReply(float percent_full) {} | 31 virtual void OnTraceBufferPercentFullReply(float percent_full) {} |
33 }; | 32 }; |
34 | 33 |
35 // TraceController is used on the browser processes to enable/disable | 34 // TraceController is used on the browser processes to enable/disable |
36 // trace status and collect trace data. Only the browser UI thread is allowed | 35 // trace status and collect trace data. Only the browser UI thread is allowed |
37 // to interact with the TraceController object. All calls on the TraceSubscriber | 36 // to interact with the TraceController object. All calls on the TraceSubscriber |
38 // happen on the UI thread. | 37 // happen on the UI thread. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 127 |
129 // Methods for use by TraceMessageFilter. | 128 // Methods for use by TraceMessageFilter. |
130 | 129 |
131 // Passing as scoped_refptr so that the method can be run asynchronously as | 130 // Passing as scoped_refptr so that the method can be run asynchronously as |
132 // a task safely (otherwise the TraceMessageFilter could be destructed). | 131 // a task safely (otherwise the TraceMessageFilter could be destructed). |
133 void AddFilter(TraceMessageFilter* filter); | 132 void AddFilter(TraceMessageFilter* filter); |
134 void RemoveFilter(TraceMessageFilter* filter); | 133 void RemoveFilter(TraceMessageFilter* filter); |
135 void OnEndTracingAck(const std::vector<std::string>& known_categories); | 134 void OnEndTracingAck(const std::vector<std::string>& known_categories); |
136 void OnTraceDataCollected( | 135 void OnTraceDataCollected( |
137 const scoped_refptr<base::debug::TraceLog::RefCountedString>& | 136 const scoped_refptr<base::debug::TraceLog::RefCountedString>& |
138 events_str_ptr); | 137 json_events_str_ptr); |
139 void OnTraceBufferFull(); | 138 void OnTraceBufferFull(); |
140 void OnTraceBufferPercentFullReply(float percent_full); | 139 void OnTraceBufferPercentFullReply(float percent_full); |
141 | 140 |
142 FilterMap filters_; | 141 FilterMap filters_; |
143 TraceSubscriber* subscriber_; | 142 TraceSubscriber* subscriber_; |
144 // Pending acks for EndTracingAsync: | 143 // Pending acks for EndTracingAsync: |
145 int pending_end_ack_count_; | 144 int pending_end_ack_count_; |
146 // Pending acks for GetTraceBufferPercentFullAsync: | 145 // Pending acks for GetTraceBufferPercentFullAsync: |
147 int pending_bpf_ack_count_; | 146 int pending_bpf_ack_count_; |
148 float maximum_bpf_; | 147 float maximum_bpf_; |
149 bool is_tracing_; | 148 bool is_tracing_; |
150 bool is_get_categories_; | 149 bool is_get_categories_; |
151 std::set<std::string> known_categories_; | 150 std::set<std::string> known_categories_; |
152 std::vector<std::string> included_categories_; | 151 std::vector<std::string> included_categories_; |
153 std::vector<std::string> excluded_categories_; | 152 std::vector<std::string> excluded_categories_; |
154 | 153 |
155 DISALLOW_COPY_AND_ASSIGN(TraceController); | 154 DISALLOW_COPY_AND_ASSIGN(TraceController); |
156 }; | 155 }; |
157 | 156 |
158 #endif // CONTENT_BROWSER_TRACE_CONTROLLER_H_ | 157 #endif // CONTENT_BROWSER_TRACE_CONTROLLER_H_ |
159 | 158 |
OLD | NEW |