summaryrefslogtreecommitdiff
path: root/chromium/content/browser/tracing/tracing_controller_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/tracing/tracing_controller_impl.h')
-rw-r--r--chromium/content/browser/tracing/tracing_controller_impl.h107
1 files changed, 78 insertions, 29 deletions
diff --git a/chromium/content/browser/tracing/tracing_controller_impl.h b/chromium/content/browser/tracing/tracing_controller_impl.h
index 22192255444..ed3c8fd6519 100644
--- a/chromium/content/browser/tracing/tracing_controller_impl.h
+++ b/chromium/content/browser/tracing/tracing_controller_impl.h
@@ -9,42 +9,54 @@
#include <string>
#include <vector>
+#include "base/files/file_path.h"
#include "base/lazy_instance.h"
-#include "content/public/browser/trace_subscriber.h"
#include "content/public/browser/tracing_controller.h"
+namespace base {
+class RefCountedString;
+}
+
namespace content {
class TraceMessageFilter;
-class TracingControllerImpl :
- public TracingController, public TraceSubscriber {
+class TracingControllerImpl : public TracingController {
public:
static TracingControllerImpl* GetInstance();
// TracingController implementation.
- virtual void GetCategories(
+ virtual bool GetCategories(
const GetCategoriesDoneCallback& callback) OVERRIDE;
- virtual void EnableRecording(
- const base::debug::CategoryFilter& filter,
+ virtual bool EnableRecording(
+ const std::string& category_filter,
TracingController::Options options,
const EnableRecordingDoneCallback& callback) OVERRIDE;
- virtual void DisableRecording(
+ virtual bool DisableRecording(
+ const base::FilePath& result_file_path,
const TracingFileResultCallback& callback) OVERRIDE;
- virtual void EnableMonitoring(const base::debug::CategoryFilter& filter,
+ virtual bool EnableMonitoring(const std::string& category_filter,
TracingController::Options options,
const EnableMonitoringDoneCallback& callback) OVERRIDE;
- virtual void DisableMonitoring(
+ virtual bool DisableMonitoring(
const DisableMonitoringDoneCallback& callback) OVERRIDE;
virtual void GetMonitoringStatus(
bool* out_enabled,
- base::debug::CategoryFilter* out_filter,
+ std::string* out_category_filter,
TracingController::Options* out_options) OVERRIDE;
- virtual void CaptureCurrentMonitoringSnapshot(
+ virtual bool CaptureMonitoringSnapshot(
+ const base::FilePath& result_file_path,
const TracingFileResultCallback& callback) OVERRIDE;
+ virtual bool GetTraceBufferPercentFull(
+ const GetTraceBufferPercentFullCallback& callback) OVERRIDE;
+ virtual bool SetWatchEvent(const std::string& category_name,
+ const std::string& event_name,
+ const WatchEventCallback& callback) OVERRIDE;
+ virtual bool CancelWatchEvent() OVERRIDE;
private:
- typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap;
+ typedef std::set<scoped_refptr<TraceMessageFilter> > TraceMessageFilterMap;
+ class ResultFile;
friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>;
friend class TraceMessageFilter;
@@ -52,46 +64,83 @@ class TracingControllerImpl :
TracingControllerImpl();
virtual ~TracingControllerImpl();
- // TraceSubscriber implementation.
- virtual void OnEndTracingComplete() OVERRIDE;
- virtual void OnTraceDataCollected(
- const scoped_refptr<base::RefCountedString>& events_str_ptr) OVERRIDE;
-
bool can_enable_recording() const {
return !is_recording_;
}
- bool can_end_recording() const {
- return is_recording_ && pending_end_ack_count_ == 0;
+ bool can_disable_recording() const {
+ return is_recording_ && !result_file_;
+ }
+
+ bool can_enable_monitoring() const {
+ return !is_monitoring_;
+ }
+
+ bool can_disable_monitoring() const {
+ return is_monitoring_ && !monitoring_snapshot_file_;
+ }
+
+ bool can_get_trace_buffer_percent_full() const {
+ return pending_trace_buffer_percent_full_callback_.is_null();
}
- bool is_recording_enabled() const {
- return can_end_recording();
+ bool can_cancel_watch_event() const {
+ return !watch_event_callback_.is_null();
}
// Methods for use by TraceMessageFilter.
- void AddFilter(TraceMessageFilter* filter);
- void RemoveFilter(TraceMessageFilter* filter);
+ void AddTraceMessageFilter(TraceMessageFilter* trace_message_filter);
+ void RemoveTraceMessageFilter(TraceMessageFilter* trace_message_filter);
+
+ void OnTraceDataCollected(
+ const scoped_refptr<base::RefCountedString>& events_str_ptr);
+ void OnMonitoringTraceDataCollected(
+ const scoped_refptr<base::RefCountedString>& events_str_ptr);
// Callback of TraceLog::Flush() for the local trace.
void OnLocalTraceDataCollected(
const scoped_refptr<base::RefCountedString>& events_str_ptr,
bool has_more_events);
+ // Callback of TraceLog::FlushMonitoring() for the local trace.
+ void OnLocalMonitoringTraceDataCollected(
+ const scoped_refptr<base::RefCountedString>& events_str_ptr,
+ bool has_more_events);
void OnDisableRecordingAcked(
const std::vector<std::string>& known_category_groups);
+ void OnResultFileClosed();
+
+ void OnCaptureMonitoringSnapshotAcked();
+ void OnMonitoringSnapshotFileClosed();
+
+ void OnTraceBufferPercentFullReply(float percent_full);
- FilterMap filters_;
+ void OnWatchEventMatched();
+
+ TraceMessageFilterMap trace_message_filters_;
// Pending acks for DisableRecording.
- int pending_end_ack_count_;
+ int pending_disable_recording_ack_count_;
+ // Pending acks for CaptureMonitoringSnapshot.
+ int pending_capture_monitoring_snapshot_ack_count_;
+ // Pending acks for GetTraceBufferPercentFull.
+ int pending_trace_buffer_percent_full_ack_count_;
+ float maximum_trace_buffer_percent_full_;
+
bool is_recording_;
+ bool is_monitoring_;
+
GetCategoriesDoneCallback pending_get_categories_done_callback_;
TracingFileResultCallback pending_disable_recording_done_callback_;
- std::set<std::string> known_category_groups_;
- base::debug::TraceLog::Options trace_options_;
- base::debug::CategoryFilter category_filter_;
- scoped_ptr<base::FilePath> recording_result_file_;
+ TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_;
+ GetTraceBufferPercentFullCallback pending_trace_buffer_percent_full_callback_;
+ std::string watch_category_name_;
+ std::string watch_event_name_;
+ WatchEventCallback watch_event_callback_;
+
+ std::set<std::string> known_category_groups_;
+ scoped_ptr<ResultFile> result_file_;
+ scoped_ptr<ResultFile> monitoring_snapshot_file_;
DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
};