OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_TRACING_TRACE_CONTROLLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ |
6 #define CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ | 6 #define CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_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/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "content/public/browser/trace_controller.h" | 14 #include "content/public/browser/trace_controller.h" |
15 | 15 |
16 class CommandLine; | 16 class CommandLine; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class TraceMessageFilter; | 19 class TraceMessageFilter; |
20 | 20 |
21 class TraceControllerImpl : public TraceController { | 21 class TraceControllerImpl : public TraceController { |
22 public: | 22 public: |
23 static TraceControllerImpl* GetInstance(); | 23 static TraceControllerImpl* GetInstance(); |
24 | 24 |
25 // Called on the main thread of the browser process to initialize | 25 // Called on the main thread of the browser process to initialize |
26 // startup tracing. | 26 // startup tracing. |
27 void InitStartupTracing(const CommandLine& command_line); | 27 void InitStartupTracing(const CommandLine& command_line); |
28 | 28 |
29 // Get set of known categories. This can change as new code paths are reached. | 29 // Get set of known category groups. This can change as new code paths are |
30 // If true is returned, subscriber->OnKnownCategoriesCollected will be called | 30 // reached. If true is returned, subscriber->OnKnownCategoriesCollected will |
31 // once the categories are retrieved from child processes. | 31 // be called once the categories are retrieved from child processes. |
32 bool GetKnownCategoriesAsync(TraceSubscriber* subscriber); | 32 bool GetKnownCategoryGroupsAsync(TraceSubscriber* subscriber); |
33 | 33 |
34 // Same as above, but specifies which categories to trace. | 34 // TraceController implementation. |
35 // If both included_categories and excluded_categories are empty, | |
36 // all categories are traced. | |
37 // Else if included_categories is non-empty, only those are traced. | |
38 // Else if excluded_categories is non-empty, everything but those are traced. | |
39 bool BeginTracing(TraceSubscriber* subscriber, | |
40 const std::vector<std::string>& included_categories, | |
41 const std::vector<std::string>& excluded_categories); | |
42 | |
43 // TraceController implementation: | |
44 virtual bool BeginTracing(TraceSubscriber* subscriber, | 35 virtual bool BeginTracing(TraceSubscriber* subscriber, |
45 const std::string& categories) OVERRIDE; | 36 const std::string& category_patterns) OVERRIDE; |
46 virtual bool EndTracingAsync(TraceSubscriber* subscriber) OVERRIDE; | 37 virtual bool EndTracingAsync(TraceSubscriber* subscriber) OVERRIDE; |
47 virtual bool GetTraceBufferPercentFullAsync( | 38 virtual bool GetTraceBufferPercentFullAsync( |
48 TraceSubscriber* subscriber) OVERRIDE; | 39 TraceSubscriber* subscriber) OVERRIDE; |
49 virtual bool SetWatchEvent(TraceSubscriber* subscriber, | 40 virtual bool SetWatchEvent(TraceSubscriber* subscriber, |
50 const std::string& category_name, | 41 const std::string& category_name, |
51 const std::string& event_name) OVERRIDE; | 42 const std::string& event_name) OVERRIDE; |
52 virtual bool CancelWatchEvent(TraceSubscriber* subscriber) OVERRIDE; | 43 virtual bool CancelWatchEvent(TraceSubscriber* subscriber) OVERRIDE; |
53 virtual void CancelSubscriber(TraceSubscriber* subscriber) OVERRIDE; | 44 virtual void CancelSubscriber(TraceSubscriber* subscriber) OVERRIDE; |
54 | 45 |
55 private: | 46 private: |
(...skipping 23 matching lines...) Expand all Loading... |
79 bool can_begin_tracing(TraceSubscriber* subscriber) const { | 70 bool can_begin_tracing(TraceSubscriber* subscriber) const { |
80 return !is_tracing_ && | 71 return !is_tracing_ && |
81 (subscriber_ == NULL || subscriber == subscriber_); | 72 (subscriber_ == NULL || subscriber == subscriber_); |
82 } | 73 } |
83 | 74 |
84 // Methods for use by TraceMessageFilter. | 75 // Methods for use by TraceMessageFilter. |
85 | 76 |
86 void AddFilter(TraceMessageFilter* filter); | 77 void AddFilter(TraceMessageFilter* filter); |
87 void RemoveFilter(TraceMessageFilter* filter); | 78 void RemoveFilter(TraceMessageFilter* filter); |
88 void OnTracingBegan(TraceSubscriber* subscriber); | 79 void OnTracingBegan(TraceSubscriber* subscriber); |
89 void OnEndTracingAck(const std::vector<std::string>& known_categories); | 80 void OnEndTracingAck(const std::vector<std::string>& known_category_groups); |
90 void OnTraceDataCollected( | 81 void OnTraceDataCollected( |
91 const scoped_refptr<base::RefCountedString>& events_str_ptr); | 82 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
92 void OnTraceNotification(int notification); | 83 void OnTraceNotification(int notification); |
93 void OnTraceBufferPercentFullReply(float percent_full); | 84 void OnTraceBufferPercentFullReply(float percent_full); |
94 | 85 |
95 FilterMap filters_; | 86 FilterMap filters_; |
96 TraceSubscriber* subscriber_; | 87 TraceSubscriber* subscriber_; |
97 // Pending acks for EndTracingAsync: | 88 // Pending acks for EndTracingAsync: |
98 int pending_end_ack_count_; | 89 int pending_end_ack_count_; |
99 // Pending acks for GetTraceBufferPercentFullAsync: | 90 // Pending acks for GetTraceBufferPercentFullAsync: |
100 int pending_bpf_ack_count_; | 91 int pending_bpf_ack_count_; |
101 float maximum_bpf_; | 92 float maximum_bpf_; |
102 bool is_tracing_; | 93 bool is_tracing_; |
103 bool is_get_categories_; | 94 bool is_get_category_groups_; |
104 std::set<std::string> known_categories_; | 95 std::set<std::string> known_category_groups_; |
105 std::vector<std::string> included_categories_; | 96 base::debug::CategoryFilter category_filter_; |
106 std::vector<std::string> excluded_categories_; | |
107 std::string watch_category_; | 97 std::string watch_category_; |
108 std::string watch_name_; | 98 std::string watch_name_; |
109 | 99 |
110 DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl); | 100 DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl); |
111 }; | 101 }; |
112 | 102 |
113 } // namespace content | 103 } // namespace content |
114 | 104 |
115 #endif // CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ | 105 #endif // CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ |
OLD | NEW |