| OLD | NEW |
| 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> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 const EnableMonitoringDoneCallback& callback) OVERRIDE; | 37 const EnableMonitoringDoneCallback& callback) OVERRIDE; |
| 38 virtual bool DisableMonitoring( | 38 virtual bool DisableMonitoring( |
| 39 const DisableMonitoringDoneCallback& callback) OVERRIDE; | 39 const DisableMonitoringDoneCallback& callback) OVERRIDE; |
| 40 virtual void GetMonitoringStatus( | 40 virtual void GetMonitoringStatus( |
| 41 bool* out_enabled, | 41 bool* out_enabled, |
| 42 base::debug::CategoryFilter* out_filter, | 42 base::debug::CategoryFilter* out_filter, |
| 43 TracingController::Options* out_options) OVERRIDE; | 43 TracingController::Options* out_options) OVERRIDE; |
| 44 virtual void CaptureMonitoringSnapshot( | 44 virtual void CaptureMonitoringSnapshot( |
| 45 const base::FilePath& result_file_path, | 45 const base::FilePath& result_file_path, |
| 46 const TracingFileResultCallback& callback) OVERRIDE; | 46 const TracingFileResultCallback& callback) OVERRIDE; |
| 47 virtual bool GetTraceBufferPercentFull( |
| 48 const GetTraceBufferPercentFullCallback& callback) OVERRIDE; |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap; | 51 typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap; |
| 50 class ResultFile; | 52 class ResultFile; |
| 51 | 53 |
| 52 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; | 54 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; |
| 53 friend class TraceMessageFilter; | 55 friend class TraceMessageFilter; |
| 54 | 56 |
| 55 TracingControllerImpl(); | 57 TracingControllerImpl(); |
| 56 virtual ~TracingControllerImpl(); | 58 virtual ~TracingControllerImpl(); |
| 57 | 59 |
| 58 bool can_enable_recording() const { | 60 bool can_enable_recording() const { |
| 59 return !is_recording_; | 61 return !is_recording_; |
| 60 } | 62 } |
| 61 | 63 |
| 62 bool can_disable_recording() const { | 64 bool can_disable_recording() const { |
| 63 return is_recording_ && pending_disable_recording_ack_count_ == 0; | 65 return is_recording_ && pending_disable_recording_ack_count_ == 0; |
| 64 } | 66 } |
| 65 | 67 |
| 66 bool can_enable_monitoring() const { | 68 bool can_enable_monitoring() const { |
| 67 return !is_monitoring_; | 69 return !is_monitoring_; |
| 68 } | 70 } |
| 69 | 71 |
| 70 bool can_disable_monitoring() const { | 72 bool can_disable_monitoring() const { |
| 71 return is_monitoring_ && | 73 return is_monitoring_ && |
| 72 pending_capture_monitoring_snapshot_ack_count_ == 0; | 74 pending_capture_monitoring_snapshot_ack_count_ == 0; |
| 73 } | 75 } |
| 74 | 76 |
| 77 bool can_get_trace_buffer_percent_full() const { |
| 78 return pending_trace_buffer_percent_full_callback_.is_null(); |
| 79 } |
| 80 |
| 75 // Methods for use by TraceMessageFilter. | 81 // Methods for use by TraceMessageFilter. |
| 76 void AddFilter(TraceMessageFilter* filter); | 82 void AddFilter(TraceMessageFilter* filter); |
| 77 void RemoveFilter(TraceMessageFilter* filter); | 83 void RemoveFilter(TraceMessageFilter* filter); |
| 78 | 84 |
| 79 void OnTraceDataCollected( | 85 void OnTraceDataCollected( |
| 80 const scoped_refptr<base::RefCountedString>& events_str_ptr); | 86 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
| 81 void OnMonitoringTraceDataCollected( | 87 void OnMonitoringTraceDataCollected( |
| 82 const scoped_refptr<base::RefCountedString>& events_str_ptr); | 88 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
| 83 | 89 |
| 84 // Callback of TraceLog::Flush() for the local trace. | 90 // Callback of TraceLog::Flush() for the local trace. |
| 85 void OnLocalTraceDataCollected( | 91 void OnLocalTraceDataCollected( |
| 86 const scoped_refptr<base::RefCountedString>& events_str_ptr, | 92 const scoped_refptr<base::RefCountedString>& events_str_ptr, |
| 87 bool has_more_events); | 93 bool has_more_events); |
| 88 // Callback of TraceLog::FlushMonitoring() for the local trace. | 94 // Callback of TraceLog::FlushMonitoring() for the local trace. |
| 89 void OnLocalMonitoringTraceDataCollected( | 95 void OnLocalMonitoringTraceDataCollected( |
| 90 const scoped_refptr<base::RefCountedString>& events_str_ptr, | 96 const scoped_refptr<base::RefCountedString>& events_str_ptr, |
| 91 bool has_more_events); | 97 bool has_more_events); |
| 92 | 98 |
| 93 void OnDisableRecordingAcked( | 99 void OnDisableRecordingAcked( |
| 94 const std::vector<std::string>& known_category_groups); | 100 const std::vector<std::string>& known_category_groups); |
| 95 void OnCaptureMonitoringSnapshotAcked(); | 101 void OnCaptureMonitoringSnapshotAcked(); |
| 96 | 102 |
| 103 void OnTraceNotification(int notification); |
| 104 void OnTraceBufferPercentFullReply(float percent_full); |
| 105 |
| 97 FilterMap filters_; | 106 FilterMap filters_; |
| 98 // Pending acks for DisableRecording. | 107 // Pending acks for DisableRecording. |
| 99 int pending_disable_recording_ack_count_; | 108 int pending_disable_recording_ack_count_; |
| 100 // Pending acks for CaptureMonitoringSnapshot. | 109 // Pending acks for CaptureMonitoringSnapshot. |
| 101 int pending_capture_monitoring_snapshot_ack_count_; | 110 int pending_capture_monitoring_snapshot_ack_count_; |
| 111 // Pending acks for GetTraceBufferPercentFull. |
| 112 int pending_trace_buffer_percent_full_ack_count_; |
| 113 float maximum_trace_buffer_percent_full_; |
| 114 |
| 102 bool is_recording_; | 115 bool is_recording_; |
| 103 bool is_monitoring_; | 116 bool is_monitoring_; |
| 117 |
| 104 GetCategoriesDoneCallback pending_get_categories_done_callback_; | 118 GetCategoriesDoneCallback pending_get_categories_done_callback_; |
| 105 TracingFileResultCallback pending_disable_recording_done_callback_; | 119 TracingFileResultCallback pending_disable_recording_done_callback_; |
| 106 TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_; | 120 TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_; |
| 121 GetTraceBufferPercentFullCallback pending_trace_buffer_percent_full_callback_; |
| 122 |
| 107 std::set<std::string> known_category_groups_; | 123 std::set<std::string> known_category_groups_; |
| 108 base::debug::CategoryFilter category_filter_; | 124 base::debug::CategoryFilter category_filter_; |
| 109 scoped_ptr<ResultFile> result_file_; | 125 scoped_ptr<ResultFile> result_file_; |
| 110 scoped_ptr<ResultFile> monitoring_snapshot_file_; | 126 scoped_ptr<ResultFile> monitoring_snapshot_file_; |
| 111 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); | 127 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); |
| 112 }; | 128 }; |
| 113 | 129 |
| 114 } // namespace content | 130 } // namespace content |
| 115 | 131 |
| 116 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ | 132 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ |
| OLD | NEW |