Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: content/browser/tracing/tracing_controller_impl.h

Issue 541763002: tracing: get rid of files in TracingController interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed android Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_TRACING_CONTROLLER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
6 #define CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 6 #define CONTENT_BROWSER_TRACING_TRACING_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/files/file_path.h"
13 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
14 #include "content/public/browser/tracing_controller.h" 13 #include "content/public/browser/tracing_controller.h"
15 14
16 namespace base { 15 namespace base {
17 class RefCountedString; 16 class RefCountedString;
17 class RefCountedMemory;
18 } 18 }
19 19
20 namespace content { 20 namespace content {
21 21
22 class TraceMessageFilter; 22 class TraceMessageFilter;
23 class TracingUI; 23 class TracingUI;
24 24
25 class TracingControllerImpl : public TracingController { 25 class TracingControllerImpl : public TracingController {
26 public: 26 public:
27 static TracingControllerImpl* GetInstance(); 27 static TracingControllerImpl* GetInstance();
28 28
29 static TraceDataSink* CreateStringSink(
30 const base::Callback<void(base::RefCountedMemory*)>& callback);
31 static TraceDataSink* CreateFileSink(
32 const base::FilePath& file_path, const base::Closure& callback);
33
29 // TracingController implementation. 34 // TracingController implementation.
30 virtual bool GetCategories( 35 virtual bool GetCategories(
31 const GetCategoriesDoneCallback& callback) OVERRIDE; 36 const GetCategoriesDoneCallback& callback) OVERRIDE;
32 virtual bool EnableRecording( 37 virtual bool EnableRecording(
33 const base::debug::CategoryFilter& category_filter, 38 const base::debug::CategoryFilter& category_filter,
34 const base::debug::TraceOptions& trace_options, 39 const base::debug::TraceOptions& trace_options,
35 const EnableRecordingDoneCallback& callback) OVERRIDE; 40 const EnableRecordingDoneCallback& callback) OVERRIDE;
36 virtual bool DisableRecording( 41 virtual bool DisableRecording(TraceDataSink* sink) OVERRIDE;
37 const base::FilePath& result_file_path,
38 const TracingFileResultCallback& callback) OVERRIDE;
39 virtual bool EnableMonitoring( 42 virtual bool EnableMonitoring(
40 const base::debug::CategoryFilter& category_filter, 43 const base::debug::CategoryFilter& category_filter,
41 const base::debug::TraceOptions& trace_options, 44 const base::debug::TraceOptions& trace_options,
42 const EnableMonitoringDoneCallback& callback) OVERRIDE; 45 const EnableMonitoringDoneCallback& callback) OVERRIDE;
43 virtual bool DisableMonitoring( 46 virtual bool DisableMonitoring(
44 const DisableMonitoringDoneCallback& callback) OVERRIDE; 47 const DisableMonitoringDoneCallback& callback) OVERRIDE;
45 virtual void GetMonitoringStatus( 48 virtual void GetMonitoringStatus(
46 bool* out_enabled, 49 bool* out_enabled,
47 base::debug::CategoryFilter* out_category_filter, 50 base::debug::CategoryFilter* out_category_filter,
48 base::debug::TraceOptions* out_trace_options) OVERRIDE; 51 base::debug::TraceOptions* out_trace_options) OVERRIDE;
49 virtual bool CaptureMonitoringSnapshot( 52 virtual bool CaptureMonitoringSnapshot(TraceDataSink* sink) OVERRIDE;
50 const base::FilePath& result_file_path,
51 const TracingFileResultCallback& callback) OVERRIDE;
52 virtual bool GetTraceBufferPercentFull( 53 virtual bool GetTraceBufferPercentFull(
53 const GetTraceBufferPercentFullCallback& callback) OVERRIDE; 54 const GetTraceBufferPercentFullCallback& callback) OVERRIDE;
54 virtual bool SetWatchEvent(const std::string& category_name, 55 virtual bool SetWatchEvent(const std::string& category_name,
55 const std::string& event_name, 56 const std::string& event_name,
56 const WatchEventCallback& callback) OVERRIDE; 57 const WatchEventCallback& callback) OVERRIDE;
57 virtual bool CancelWatchEvent() OVERRIDE; 58 virtual bool CancelWatchEvent() OVERRIDE;
58 59
59 void RegisterTracingUI(TracingUI* tracing_ui); 60 void RegisterTracingUI(TracingUI* tracing_ui);
60 void UnregisterTracingUI(TracingUI* tracing_ui); 61 void UnregisterTracingUI(TracingUI* tracing_ui);
61 62
62 private: 63 private:
63 typedef std::set<scoped_refptr<TraceMessageFilter> > TraceMessageFilterSet; 64 typedef std::set<scoped_refptr<TraceMessageFilter> > TraceMessageFilterSet;
64 class ResultFile;
65 65
66 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; 66 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>;
67 friend class TraceMessageFilter; 67 friend class TraceMessageFilter;
68 68
69 TracingControllerImpl(); 69 TracingControllerImpl();
70 virtual ~TracingControllerImpl(); 70 virtual ~TracingControllerImpl();
71 71
72 bool can_enable_recording() const { 72 bool can_enable_recording() const {
73 return !is_recording_; 73 return !is_recording_;
74 } 74 }
75 75
76 bool can_disable_recording() const { 76 bool can_disable_recording() const {
77 return is_recording_ && !result_file_; 77 return is_recording_ && !trace_data_sink_;
78 } 78 }
79 79
80 bool can_enable_monitoring() const { 80 bool can_enable_monitoring() const {
81 return !is_monitoring_; 81 return !is_monitoring_;
82 } 82 }
83 83
84 bool can_disable_monitoring() const { 84 bool can_disable_monitoring() const {
85 return is_monitoring_ && !monitoring_snapshot_file_; 85 return is_monitoring_ && !monitoring_data_sink_;
86 } 86 }
87 87
88 bool can_get_trace_buffer_percent_full() const { 88 bool can_get_trace_buffer_percent_full() const {
89 return pending_trace_buffer_percent_full_callback_.is_null(); 89 return pending_trace_buffer_percent_full_callback_.is_null();
90 } 90 }
91 91
92 bool can_cancel_watch_event() const { 92 bool can_cancel_watch_event() const {
93 return !watch_event_callback_.is_null(); 93 return !watch_event_callback_.is_null();
94 } 94 }
95 95
(...skipping 11 matching lines...) Expand all
107 const scoped_refptr<base::RefCountedString>& events_str_ptr, 107 const scoped_refptr<base::RefCountedString>& events_str_ptr,
108 bool has_more_events); 108 bool has_more_events);
109 // Callback of TraceLog::FlushMonitoring() for the local trace. 109 // Callback of TraceLog::FlushMonitoring() for the local trace.
110 void OnLocalMonitoringTraceDataCollected( 110 void OnLocalMonitoringTraceDataCollected(
111 const scoped_refptr<base::RefCountedString>& events_str_ptr, 111 const scoped_refptr<base::RefCountedString>& events_str_ptr,
112 bool has_more_events); 112 bool has_more_events);
113 113
114 void OnDisableRecordingAcked( 114 void OnDisableRecordingAcked(
115 TraceMessageFilter* trace_message_filter, 115 TraceMessageFilter* trace_message_filter,
116 const std::vector<std::string>& known_category_groups); 116 const std::vector<std::string>& known_category_groups);
117 void OnDisableRecordingComplete();
118 void OnResultFileClosed();
119 117
120 #if defined(OS_CHROMEOS) || defined(OS_WIN) 118 #if defined(OS_CHROMEOS) || defined(OS_WIN)
121 void OnEndSystemTracingAcked( 119 void OnEndSystemTracingAcked(
122 const scoped_refptr<base::RefCountedString>& events_str_ptr); 120 const scoped_refptr<base::RefCountedString>& events_str_ptr);
123 #endif 121 #endif
124 122
125 void OnCaptureMonitoringSnapshotAcked( 123 void OnCaptureMonitoringSnapshotAcked(
126 TraceMessageFilter* trace_message_filter); 124 TraceMessageFilter* trace_message_filter);
127 void OnMonitoringSnapshotFileClosed();
128 125
129 void OnTraceBufferPercentFullReply( 126 void OnTraceBufferPercentFullReply(
130 TraceMessageFilter* trace_message_filter, 127 TraceMessageFilter* trace_message_filter,
131 float percent_full); 128 float percent_full);
132 129
133 void OnWatchEventMatched(); 130 void OnWatchEventMatched();
134 131
135 void SetEnabledOnFileThread( 132 void SetEnabledOnFileThread(
136 const base::debug::CategoryFilter& category_filter, 133 const base::debug::CategoryFilter& category_filter,
137 int mode, 134 int mode,
138 const base::debug::TraceOptions& trace_options, 135 const base::debug::TraceOptions& trace_options,
139 const base::Closure& callback); 136 const base::Closure& callback);
140 void SetDisabledOnFileThread(const base::Closure& callback); 137 void SetDisabledOnFileThread(const base::Closure& callback);
141 void OnEnableRecordingDone(const base::debug::CategoryFilter& category_filter, 138 void OnEnableRecordingDone(const base::debug::CategoryFilter& category_filter,
142 const base::debug::TraceOptions& trace_options, 139 const base::debug::TraceOptions& trace_options,
143 const EnableRecordingDoneCallback& callback); 140 const EnableRecordingDoneCallback& callback);
144 void OnDisableRecordingDone(const base::FilePath& result_file_path, 141 void OnDisableRecordingDone(TraceDataSink* trace_data_sink);
145 const TracingFileResultCallback& callback);
146 void OnEnableMonitoringDone( 142 void OnEnableMonitoringDone(
147 const base::debug::CategoryFilter& category_filter, 143 const base::debug::CategoryFilter& category_filter,
148 const base::debug::TraceOptions& trace_options, 144 const base::debug::TraceOptions& trace_options,
149 const EnableMonitoringDoneCallback& callback); 145 const EnableMonitoringDoneCallback& callback);
150 void OnDisableMonitoringDone(const DisableMonitoringDoneCallback& callback); 146 void OnDisableMonitoringDone(const DisableMonitoringDoneCallback& callback);
151 147
152 void OnMonitoringStateChanged(bool is_monitoring); 148 void OnMonitoringStateChanged(bool is_monitoring);
153 149
154 TraceMessageFilterSet trace_message_filters_; 150 TraceMessageFilterSet trace_message_filters_;
155 151
156 // Pending acks for DisableRecording. 152 // Pending acks for DisableRecording.
157 int pending_disable_recording_ack_count_; 153 int pending_disable_recording_ack_count_;
158 TraceMessageFilterSet pending_disable_recording_filters_; 154 TraceMessageFilterSet pending_disable_recording_filters_;
159 // Pending acks for CaptureMonitoringSnapshot. 155 // Pending acks for CaptureMonitoringSnapshot.
160 int pending_capture_monitoring_snapshot_ack_count_; 156 int pending_capture_monitoring_snapshot_ack_count_;
161 TraceMessageFilterSet pending_capture_monitoring_filters_; 157 TraceMessageFilterSet pending_capture_monitoring_filters_;
162 // Pending acks for GetTraceBufferPercentFull. 158 // Pending acks for GetTraceBufferPercentFull.
163 int pending_trace_buffer_percent_full_ack_count_; 159 int pending_trace_buffer_percent_full_ack_count_;
164 TraceMessageFilterSet pending_trace_buffer_percent_full_filters_; 160 TraceMessageFilterSet pending_trace_buffer_percent_full_filters_;
165 float maximum_trace_buffer_percent_full_; 161 float maximum_trace_buffer_percent_full_;
166 162
167 #if defined(OS_CHROMEOS) || defined(OS_WIN) 163 #if defined(OS_CHROMEOS) || defined(OS_WIN)
168 bool is_system_tracing_; 164 bool is_system_tracing_;
169 #endif 165 #endif
170 bool is_recording_; 166 bool is_recording_;
171 bool is_monitoring_; 167 bool is_monitoring_;
172 base::debug::TraceOptions trace_options_; 168 base::debug::TraceOptions trace_options_;
173 169
174 GetCategoriesDoneCallback pending_get_categories_done_callback_; 170 GetCategoriesDoneCallback pending_get_categories_done_callback_;
175 TracingFileResultCallback pending_disable_recording_done_callback_;
176 TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_;
177 GetTraceBufferPercentFullCallback pending_trace_buffer_percent_full_callback_; 171 GetTraceBufferPercentFullCallback pending_trace_buffer_percent_full_callback_;
178 172
179 std::string watch_category_name_; 173 std::string watch_category_name_;
180 std::string watch_event_name_; 174 std::string watch_event_name_;
181 WatchEventCallback watch_event_callback_; 175 WatchEventCallback watch_event_callback_;
182 176
183 std::set<std::string> known_category_groups_; 177 std::set<std::string> known_category_groups_;
184 std::set<TracingUI*> tracing_uis_; 178 std::set<TracingUI*> tracing_uis_;
185 scoped_ptr<ResultFile> result_file_; 179 TraceDataSink* trace_data_sink_;
186 scoped_ptr<ResultFile> monitoring_snapshot_file_; 180 TraceDataSink* monitoring_data_sink_;
187 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); 181 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
188 }; 182 };
189 183
190 } // namespace content 184 } // namespace content
191 185
192 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 186 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698