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 category groups 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 base::debug::TraceLog::Options options); | |
43 | |
44 // TraceController implementation: | |
45 virtual bool BeginTracing(TraceSubscriber* subscriber, | 35 virtual bool BeginTracing(TraceSubscriber* subscriber, |
46 const std::string& categories, | 36 const std::string& category_patterns, |
47 base::debug::TraceLog::Options options) OVERRIDE; | 37 base::debug::TraceLog::Options options) OVERRIDE; |
48 virtual bool EndTracingAsync(TraceSubscriber* subscriber) OVERRIDE; | 38 virtual bool EndTracingAsync(TraceSubscriber* subscriber) OVERRIDE; |
49 virtual bool GetTraceBufferPercentFullAsync( | 39 virtual bool GetTraceBufferPercentFullAsync( |
50 TraceSubscriber* subscriber) OVERRIDE; | 40 TraceSubscriber* subscriber) OVERRIDE; |
51 virtual bool SetWatchEvent(TraceSubscriber* subscriber, | 41 virtual bool SetWatchEvent(TraceSubscriber* subscriber, |
52 const std::string& category_name, | 42 const std::string& category_name, |
53 const std::string& event_name) OVERRIDE; | 43 const std::string& event_name) OVERRIDE; |
54 virtual bool CancelWatchEvent(TraceSubscriber* subscriber) OVERRIDE; | 44 virtual bool CancelWatchEvent(TraceSubscriber* subscriber) OVERRIDE; |
55 virtual void CancelSubscriber(TraceSubscriber* subscriber) OVERRIDE; | 45 virtual void CancelSubscriber(TraceSubscriber* subscriber) OVERRIDE; |
56 | 46 |
(...skipping 24 matching lines...) Expand all Loading... |
81 bool can_begin_tracing(TraceSubscriber* subscriber) const { | 71 bool can_begin_tracing(TraceSubscriber* subscriber) const { |
82 return !is_tracing_ && | 72 return !is_tracing_ && |
83 (subscriber_ == NULL || subscriber == subscriber_); | 73 (subscriber_ == NULL || subscriber == subscriber_); |
84 } | 74 } |
85 | 75 |
86 // Methods for use by TraceMessageFilter. | 76 // Methods for use by TraceMessageFilter. |
87 | 77 |
88 void AddFilter(TraceMessageFilter* filter); | 78 void AddFilter(TraceMessageFilter* filter); |
89 void RemoveFilter(TraceMessageFilter* filter); | 79 void RemoveFilter(TraceMessageFilter* filter); |
90 void OnTracingBegan(TraceSubscriber* subscriber); | 80 void OnTracingBegan(TraceSubscriber* subscriber); |
91 void OnEndTracingAck(const std::vector<std::string>& known_categories); | 81 void OnEndTracingAck(const std::vector<std::string>& known_category_groups); |
92 void OnTraceDataCollected( | 82 void OnTraceDataCollected( |
93 const scoped_refptr<base::RefCountedString>& events_str_ptr); | 83 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
94 void OnTraceNotification(int notification); | 84 void OnTraceNotification(int notification); |
95 void OnTraceBufferPercentFullReply(float percent_full); | 85 void OnTraceBufferPercentFullReply(float percent_full); |
96 | 86 |
97 FilterMap filters_; | 87 FilterMap filters_; |
98 TraceSubscriber* subscriber_; | 88 TraceSubscriber* subscriber_; |
99 // Pending acks for EndTracingAsync: | 89 // Pending acks for EndTracingAsync: |
100 int pending_end_ack_count_; | 90 int pending_end_ack_count_; |
101 // Pending acks for GetTraceBufferPercentFullAsync: | 91 // Pending acks for GetTraceBufferPercentFullAsync: |
102 int pending_bpf_ack_count_; | 92 int pending_bpf_ack_count_; |
103 float maximum_bpf_; | 93 float maximum_bpf_; |
104 bool is_tracing_; | 94 bool is_tracing_; |
105 bool is_get_categories_; | 95 bool is_get_category_groups_; |
106 std::set<std::string> known_categories_; | 96 std::set<std::string> known_category_groups_; |
107 std::vector<std::string> included_categories_; | 97 base::debug::CategoryFilter category_filter_; |
108 std::vector<std::string> excluded_categories_; | |
109 std::string watch_category_; | 98 std::string watch_category_; |
110 std::string watch_name_; | 99 std::string watch_name_; |
111 base::debug::TraceLog::Options trace_options_; | 100 base::debug::TraceLog::Options trace_options_; |
112 | 101 |
113 DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl); | 102 DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl); |
114 }; | 103 }; |
115 | 104 |
116 } // namespace content | 105 } // namespace content |
117 | 106 |
118 #endif // CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ | 107 #endif // CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ |
OLD | NEW |