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

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

Issue 67683003: Remove TraceController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: keep existing devtools protocol Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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" 12 #include "base/files/file_path.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "content/public/browser/trace_subscriber.h"
15 #include "content/public/browser/tracing_controller.h" 14 #include "content/public/browser/tracing_controller.h"
16 15
16 namespace base {
17 class RefCountedString;
18 class DictionaryValue;
19 }
20
17 namespace content { 21 namespace content {
18 22
19 class TraceMessageFilter; 23 class TraceMessageFilter;
20 24
21 class TracingControllerImpl : public TracingController { 25 class TracingControllerImpl : public TracingController {
22 public: 26 public:
23 static TracingControllerImpl* GetInstance(); 27 static TracingControllerImpl* GetInstance();
24 28
25 // TracingController implementation. 29 // TracingController implementation.
26 virtual void GetCategories( 30 virtual void GetCategories(
27 const GetCategoriesDoneCallback& callback) OVERRIDE; 31 const GetCategoriesDoneCallback& callback) OVERRIDE;
28 virtual bool EnableRecording( 32 virtual bool EnableRecording(
29 const base::debug::CategoryFilter& filter, 33 const std::string& category_filter,
30 TracingController::Options options, 34 TracingController::Options options,
31 const EnableRecordingDoneCallback& callback) OVERRIDE; 35 const EnableRecordingDoneCallback& callback) OVERRIDE;
32 virtual bool DisableRecording( 36 virtual bool DisableRecording(
33 const base::FilePath& result_file_path, 37 const base::FilePath& result_file_path,
34 const TracingFileResultCallback& callback) OVERRIDE; 38 const TracingFileResultCallback& callback) OVERRIDE;
35 virtual bool EnableMonitoring(const base::debug::CategoryFilter& filter, 39 virtual bool EnableMonitoring(const std::string& category_filter,
36 TracingController::Options options, 40 TracingController::Options options,
37 const EnableMonitoringDoneCallback& callback) OVERRIDE; 41 const EnableMonitoringDoneCallback& callback) OVERRIDE;
38 virtual bool DisableMonitoring( 42 virtual bool DisableMonitoring(
39 const DisableMonitoringDoneCallback& callback) OVERRIDE; 43 const DisableMonitoringDoneCallback& callback) OVERRIDE;
40 virtual void GetMonitoringStatus( 44 virtual void GetMonitoringStatus(
41 bool* out_enabled, 45 bool* out_enabled,
42 base::debug::CategoryFilter* out_filter, 46 std::string* out_category_filter,
43 TracingController::Options* out_options) OVERRIDE; 47 TracingController::Options* out_options) OVERRIDE;
44 virtual void CaptureMonitoringSnapshot( 48 virtual void CaptureMonitoringSnapshot(
45 const base::FilePath& result_file_path, 49 const base::FilePath& result_file_path,
46 const TracingFileResultCallback& callback) OVERRIDE; 50 const TracingFileResultCallback& callback) OVERRIDE;
47 virtual bool GetTraceBufferPercentFull( 51 virtual bool GetTraceBufferPercentFull(
48 const GetTraceBufferPercentFullCallback& callback) OVERRIDE; 52 const GetTraceBufferPercentFullCallback& callback) OVERRIDE;
53 virtual bool SetWatchEvent(const std::string& category_name,
54 const std::string& event_name,
55 const WatchEventCallback& callback) OVERRIDE;
56 virtual bool CancelWatchEvent() OVERRIDE;
57
58 // Parse tracing filter and options from a DictionaryValue which is in the
59 // following format:
60 // { "categoryFilter": <category_filter_string>,
61 // "useSystemTracing": <bool>,
62 // "useContinuousTracing": <bool>,
63 // "useSampling": <bool> }
64 static bool ParseTracingParams(const base::DictionaryValue* params,
65 std::string* category_filter,
66 Options* options);
67 // Encode tracing filter and options into a JSON string.
68 static void EncodeTracingParams(const std::string& category_filter,
69 Options options,
70 base::DictionaryValue* result);
49 71
50 private: 72 private:
51 typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap; 73 typedef std::set<scoped_refptr<TraceMessageFilter> > TraceMessageFilterMap;
52 class ResultFile; 74 class ResultFile;
53 75
54 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; 76 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>;
55 friend class TraceMessageFilter; 77 friend class TraceMessageFilter;
56 78
57 TracingControllerImpl(); 79 TracingControllerImpl();
58 virtual ~TracingControllerImpl(); 80 virtual ~TracingControllerImpl();
59 81
60 bool can_enable_recording() const { 82 bool can_enable_recording() const {
61 return !is_recording_; 83 return !is_recording_;
62 } 84 }
63 85
64 bool can_disable_recording() const { 86 bool can_disable_recording() const {
65 return is_recording_ && !result_file_; 87 return is_recording_ && !result_file_;
66 } 88 }
67 89
68 bool can_enable_monitoring() const { 90 bool can_enable_monitoring() const {
69 return !is_monitoring_; 91 return !is_monitoring_;
70 } 92 }
71 93
72 bool can_disable_monitoring() const { 94 bool can_disable_monitoring() const {
73 return is_monitoring_ && !monitoring_snapshot_file_; 95 return is_monitoring_ && !monitoring_snapshot_file_;
74 } 96 }
75 97
76 bool can_get_trace_buffer_percent_full() const { 98 bool can_get_trace_buffer_percent_full() const {
77 return pending_trace_buffer_percent_full_callback_.is_null(); 99 return pending_trace_buffer_percent_full_callback_.is_null();
78 } 100 }
79 101
102 bool can_set_watch_event() const {
103 return watch_event_callback_.is_null();
104 }
105
106 bool can_cancel_watch_event() const {
107 return !watch_event_callback_.is_null();
108 }
109
80 // Methods for use by TraceMessageFilter. 110 // Methods for use by TraceMessageFilter.
81 void AddFilter(TraceMessageFilter* filter); 111 void AddTraceMessageFilter(TraceMessageFilter* trace_message_filter);
82 void RemoveFilter(TraceMessageFilter* filter); 112 void RemoveTraceMessageFilter(TraceMessageFilter* trace_message_filter);
83 113
84 void OnTraceDataCollected( 114 void OnTraceDataCollected(
85 const scoped_refptr<base::RefCountedString>& events_str_ptr); 115 const scoped_refptr<base::RefCountedString>& events_str_ptr);
86 void OnMonitoringTraceDataCollected( 116 void OnMonitoringTraceDataCollected(
87 const scoped_refptr<base::RefCountedString>& events_str_ptr); 117 const scoped_refptr<base::RefCountedString>& events_str_ptr);
88 118
89 // Callback of TraceLog::Flush() for the local trace. 119 // Callback of TraceLog::Flush() for the local trace.
90 void OnLocalTraceDataCollected( 120 void OnLocalTraceDataCollected(
91 const scoped_refptr<base::RefCountedString>& events_str_ptr, 121 const scoped_refptr<base::RefCountedString>& events_str_ptr,
92 bool has_more_events); 122 bool has_more_events);
93 // Callback of TraceLog::FlushMonitoring() for the local trace. 123 // Callback of TraceLog::FlushMonitoring() for the local trace.
94 void OnLocalMonitoringTraceDataCollected( 124 void OnLocalMonitoringTraceDataCollected(
95 const scoped_refptr<base::RefCountedString>& events_str_ptr, 125 const scoped_refptr<base::RefCountedString>& events_str_ptr,
96 bool has_more_events); 126 bool has_more_events);
97 127
98 void OnDisableRecordingAcked( 128 void OnDisableRecordingAcked(
99 const std::vector<std::string>& known_category_groups); 129 const std::vector<std::string>& known_category_groups);
100 void OnResultFileClosed(); 130 void OnResultFileClosed();
101 131
102 void OnCaptureMonitoringSnapshotAcked(); 132 void OnCaptureMonitoringSnapshotAcked();
103 void OnMonitoringSnapshotFileClosed(); 133 void OnMonitoringSnapshotFileClosed();
104 134
105 void OnTraceNotification(int notification);
106 void OnTraceBufferPercentFullReply(float percent_full); 135 void OnTraceBufferPercentFullReply(float percent_full);
107 136
108 FilterMap filters_; 137 void OnWatchEventMatched();
138
139 TraceMessageFilterMap trace_message_filters_;
109 // Pending acks for DisableRecording. 140 // Pending acks for DisableRecording.
110 int pending_disable_recording_ack_count_; 141 int pending_disable_recording_ack_count_;
111 // Pending acks for CaptureMonitoringSnapshot. 142 // Pending acks for CaptureMonitoringSnapshot.
112 int pending_capture_monitoring_snapshot_ack_count_; 143 int pending_capture_monitoring_snapshot_ack_count_;
113 // Pending acks for GetTraceBufferPercentFull. 144 // Pending acks for GetTraceBufferPercentFull.
114 int pending_trace_buffer_percent_full_ack_count_; 145 int pending_trace_buffer_percent_full_ack_count_;
115 float maximum_trace_buffer_percent_full_; 146 float maximum_trace_buffer_percent_full_;
116 147
117 bool is_recording_; 148 bool is_recording_;
118 bool is_monitoring_; 149 bool is_monitoring_;
119 150
120 GetCategoriesDoneCallback pending_get_categories_done_callback_; 151 GetCategoriesDoneCallback pending_get_categories_done_callback_;
121 TracingFileResultCallback pending_disable_recording_done_callback_; 152 TracingFileResultCallback pending_disable_recording_done_callback_;
122 TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_; 153 TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_;
123 GetTraceBufferPercentFullCallback pending_trace_buffer_percent_full_callback_; 154 GetTraceBufferPercentFullCallback pending_trace_buffer_percent_full_callback_;
155 WatchEventCallback watch_event_callback_;
124 156
125 std::set<std::string> known_category_groups_; 157 std::set<std::string> known_category_groups_;
126 base::debug::CategoryFilter category_filter_;
127 scoped_ptr<ResultFile> result_file_; 158 scoped_ptr<ResultFile> result_file_;
128 scoped_ptr<ResultFile> monitoring_snapshot_file_; 159 scoped_ptr<ResultFile> monitoring_snapshot_file_;
129 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); 160 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
130 }; 161 };
131 162
132 } // namespace content 163 } // namespace content
133 164
134 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 165 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698