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

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 build following removal of cast opterator in scoped_refptr 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 scoped_refptr<TraceDataSink> CreateStringSink(
30 const base::Callback<void(base::RefCountedMemory*)>& callback);
31 static scoped_refptr<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(
37 const base::FilePath& result_file_path, 42 const scoped_refptr<TraceDataSink>& sink) OVERRIDE;
38 const TracingFileResultCallback& callback) OVERRIDE;
39 virtual bool EnableMonitoring( 43 virtual bool EnableMonitoring(
40 const base::debug::CategoryFilter& category_filter, 44 const base::debug::CategoryFilter& category_filter,
41 const base::debug::TraceOptions& trace_options, 45 const base::debug::TraceOptions& trace_options,
42 const EnableMonitoringDoneCallback& callback) OVERRIDE; 46 const EnableMonitoringDoneCallback& callback) OVERRIDE;
43 virtual bool DisableMonitoring( 47 virtual bool DisableMonitoring(
44 const DisableMonitoringDoneCallback& callback) OVERRIDE; 48 const DisableMonitoringDoneCallback& callback) OVERRIDE;
45 virtual void GetMonitoringStatus( 49 virtual void GetMonitoringStatus(
46 bool* out_enabled, 50 bool* out_enabled,
47 base::debug::CategoryFilter* out_category_filter, 51 base::debug::CategoryFilter* out_category_filter,
48 base::debug::TraceOptions* out_trace_options) OVERRIDE; 52 base::debug::TraceOptions* out_trace_options) OVERRIDE;
49 virtual bool CaptureMonitoringSnapshot( 53 virtual bool CaptureMonitoringSnapshot(
50 const base::FilePath& result_file_path, 54 const scoped_refptr<TraceDataSink>& sink) OVERRIDE;
51 const TracingFileResultCallback& callback) OVERRIDE;
52 virtual bool GetTraceBufferPercentFull( 55 virtual bool GetTraceBufferPercentFull(
53 const GetTraceBufferPercentFullCallback& callback) OVERRIDE; 56 const GetTraceBufferPercentFullCallback& callback) OVERRIDE;
54 virtual bool SetWatchEvent(const std::string& category_name, 57 virtual bool SetWatchEvent(const std::string& category_name,
55 const std::string& event_name, 58 const std::string& event_name,
56 const WatchEventCallback& callback) OVERRIDE; 59 const WatchEventCallback& callback) OVERRIDE;
57 virtual bool CancelWatchEvent() OVERRIDE; 60 virtual bool CancelWatchEvent() OVERRIDE;
58 61
59 void RegisterTracingUI(TracingUI* tracing_ui); 62 void RegisterTracingUI(TracingUI* tracing_ui);
60 void UnregisterTracingUI(TracingUI* tracing_ui); 63 void UnregisterTracingUI(TracingUI* tracing_ui);
61 64
62 private: 65 private:
63 typedef std::set<scoped_refptr<TraceMessageFilter> > TraceMessageFilterSet; 66 typedef std::set<scoped_refptr<TraceMessageFilter> > TraceMessageFilterSet;
64 class ResultFile;
65 67
66 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; 68 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>;
67 friend class TraceMessageFilter; 69 friend class TraceMessageFilter;
68 70
69 TracingControllerImpl(); 71 TracingControllerImpl();
70 virtual ~TracingControllerImpl(); 72 virtual ~TracingControllerImpl();
71 73
72 bool can_enable_recording() const { 74 bool can_enable_recording() const {
73 return !is_recording_; 75 return !is_recording_;
74 } 76 }
75 77
76 bool can_disable_recording() const { 78 bool can_disable_recording() const {
77 return is_recording_ && !result_file_; 79 return is_recording_ && !trace_data_sink_.get();
78 } 80 }
79 81
80 bool can_enable_monitoring() const { 82 bool can_enable_monitoring() const {
81 return !is_monitoring_; 83 return !is_monitoring_;
82 } 84 }
83 85
84 bool can_disable_monitoring() const { 86 bool can_disable_monitoring() const {
85 return is_monitoring_ && !monitoring_snapshot_file_; 87 return is_monitoring_ && !monitoring_data_sink_.get();
86 } 88 }
87 89
88 bool can_get_trace_buffer_percent_full() const { 90 bool can_get_trace_buffer_percent_full() const {
89 return pending_trace_buffer_percent_full_callback_.is_null(); 91 return pending_trace_buffer_percent_full_callback_.is_null();
90 } 92 }
91 93
92 bool can_cancel_watch_event() const { 94 bool can_cancel_watch_event() const {
93 return !watch_event_callback_.is_null(); 95 return !watch_event_callback_.is_null();
94 } 96 }
95 97
(...skipping 11 matching lines...) Expand all
107 const scoped_refptr<base::RefCountedString>& events_str_ptr, 109 const scoped_refptr<base::RefCountedString>& events_str_ptr,
108 bool has_more_events); 110 bool has_more_events);
109 // Callback of TraceLog::FlushMonitoring() for the local trace. 111 // Callback of TraceLog::FlushMonitoring() for the local trace.
110 void OnLocalMonitoringTraceDataCollected( 112 void OnLocalMonitoringTraceDataCollected(
111 const scoped_refptr<base::RefCountedString>& events_str_ptr, 113 const scoped_refptr<base::RefCountedString>& events_str_ptr,
112 bool has_more_events); 114 bool has_more_events);
113 115
114 void OnDisableRecordingAcked( 116 void OnDisableRecordingAcked(
115 TraceMessageFilter* trace_message_filter, 117 TraceMessageFilter* trace_message_filter,
116 const std::vector<std::string>& known_category_groups); 118 const std::vector<std::string>& known_category_groups);
117 void OnDisableRecordingComplete();
118 void OnResultFileClosed();
119 119
120 #if defined(OS_CHROMEOS) || defined(OS_WIN) 120 #if defined(OS_CHROMEOS) || defined(OS_WIN)
121 void OnEndSystemTracingAcked( 121 void OnEndSystemTracingAcked(
122 const scoped_refptr<base::RefCountedString>& events_str_ptr); 122 const scoped_refptr<base::RefCountedString>& events_str_ptr);
123 #endif 123 #endif
124 124
125 void OnCaptureMonitoringSnapshotAcked( 125 void OnCaptureMonitoringSnapshotAcked(
126 TraceMessageFilter* trace_message_filter); 126 TraceMessageFilter* trace_message_filter);
127 void OnMonitoringSnapshotFileClosed();
128 127
129 void OnTraceBufferPercentFullReply( 128 void OnTraceBufferPercentFullReply(
130 TraceMessageFilter* trace_message_filter, 129 TraceMessageFilter* trace_message_filter,
131 float percent_full); 130 float percent_full);
132 131
133 void OnWatchEventMatched(); 132 void OnWatchEventMatched();
134 133
135 void SetEnabledOnFileThread( 134 void SetEnabledOnFileThread(
136 const base::debug::CategoryFilter& category_filter, 135 const base::debug::CategoryFilter& category_filter,
137 int mode, 136 int mode,
138 const base::debug::TraceOptions& trace_options, 137 const base::debug::TraceOptions& trace_options,
139 const base::Closure& callback); 138 const base::Closure& callback);
140 void SetDisabledOnFileThread(const base::Closure& callback); 139 void SetDisabledOnFileThread(const base::Closure& callback);
141 void OnEnableRecordingDone(const base::debug::CategoryFilter& category_filter, 140 void OnEnableRecordingDone(const base::debug::CategoryFilter& category_filter,
142 const base::debug::TraceOptions& trace_options, 141 const base::debug::TraceOptions& trace_options,
143 const EnableRecordingDoneCallback& callback); 142 const EnableRecordingDoneCallback& callback);
144 void OnDisableRecordingDone(const base::FilePath& result_file_path, 143 void OnDisableRecordingDone();
145 const TracingFileResultCallback& callback);
146 void OnEnableMonitoringDone( 144 void OnEnableMonitoringDone(
147 const base::debug::CategoryFilter& category_filter, 145 const base::debug::CategoryFilter& category_filter,
148 const base::debug::TraceOptions& trace_options, 146 const base::debug::TraceOptions& trace_options,
149 const EnableMonitoringDoneCallback& callback); 147 const EnableMonitoringDoneCallback& callback);
150 void OnDisableMonitoringDone(const DisableMonitoringDoneCallback& callback); 148 void OnDisableMonitoringDone(const DisableMonitoringDoneCallback& callback);
151 149
152 void OnMonitoringStateChanged(bool is_monitoring); 150 void OnMonitoringStateChanged(bool is_monitoring);
153 151
154 TraceMessageFilterSet trace_message_filters_; 152 TraceMessageFilterSet trace_message_filters_;
155 153
156 // Pending acks for DisableRecording. 154 // Pending acks for DisableRecording.
157 int pending_disable_recording_ack_count_; 155 int pending_disable_recording_ack_count_;
158 TraceMessageFilterSet pending_disable_recording_filters_; 156 TraceMessageFilterSet pending_disable_recording_filters_;
159 // Pending acks for CaptureMonitoringSnapshot. 157 // Pending acks for CaptureMonitoringSnapshot.
160 int pending_capture_monitoring_snapshot_ack_count_; 158 int pending_capture_monitoring_snapshot_ack_count_;
161 TraceMessageFilterSet pending_capture_monitoring_filters_; 159 TraceMessageFilterSet pending_capture_monitoring_filters_;
162 // Pending acks for GetTraceBufferPercentFull. 160 // Pending acks for GetTraceBufferPercentFull.
163 int pending_trace_buffer_percent_full_ack_count_; 161 int pending_trace_buffer_percent_full_ack_count_;
164 TraceMessageFilterSet pending_trace_buffer_percent_full_filters_; 162 TraceMessageFilterSet pending_trace_buffer_percent_full_filters_;
165 float maximum_trace_buffer_percent_full_; 163 float maximum_trace_buffer_percent_full_;
166 164
167 #if defined(OS_CHROMEOS) || defined(OS_WIN) 165 #if defined(OS_CHROMEOS) || defined(OS_WIN)
168 bool is_system_tracing_; 166 bool is_system_tracing_;
169 #endif 167 #endif
170 bool is_recording_; 168 bool is_recording_;
171 bool is_monitoring_; 169 bool is_monitoring_;
172 base::debug::TraceOptions trace_options_; 170 base::debug::TraceOptions trace_options_;
173 171
174 GetCategoriesDoneCallback pending_get_categories_done_callback_; 172 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_; 173 GetTraceBufferPercentFullCallback pending_trace_buffer_percent_full_callback_;
178 174
179 std::string watch_category_name_; 175 std::string watch_category_name_;
180 std::string watch_event_name_; 176 std::string watch_event_name_;
181 WatchEventCallback watch_event_callback_; 177 WatchEventCallback watch_event_callback_;
182 178
183 std::set<std::string> known_category_groups_; 179 std::set<std::string> known_category_groups_;
184 std::set<TracingUI*> tracing_uis_; 180 std::set<TracingUI*> tracing_uis_;
185 scoped_ptr<ResultFile> result_file_; 181 scoped_refptr<TraceDataSink> trace_data_sink_;
186 scoped_ptr<ResultFile> monitoring_snapshot_file_; 182 scoped_refptr<TraceDataSink> monitoring_data_sink_;
187 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); 183 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
188 }; 184 };
189 185
190 } // namespace content 186 } // namespace content
191 187
192 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 188 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698