| Index: content/browser/tracing/tracing_controller_impl.h
|
| diff --git a/content/browser/tracing/tracing_controller_impl.h b/content/browser/tracing/tracing_controller_impl.h
|
| index 93d2c04cebe291959d5419d4671de3fc748678dc..c3fe2fffa017432268742beee51391fb565f4ebe 100644
|
| --- a/content/browser/tracing/tracing_controller_impl.h
|
| +++ b/content/browser/tracing/tracing_controller_impl.h
|
| @@ -19,6 +19,9 @@
|
| #include "base/trace_event/memory_dump_manager.h"
|
| #include "base/trace_event/tracing_agent.h"
|
| #include "content/public/browser/tracing_controller.h"
|
| +#include "mojo/common/data_pipe_drainer.h"
|
| +#include "services/resource_coordinator/public/interfaces/tracing/tracing.mojom.h"
|
| +#include "services/service_manager/public/cpp/connector.h"
|
|
|
| namespace base {
|
| class RefCountedString;
|
| @@ -45,9 +48,8 @@ class CONTENT_EXPORT TraceDataEndpoint
|
| virtual ~TraceDataEndpoint() {}
|
| };
|
|
|
| -class TracingControllerImpl
|
| - : public TracingController,
|
| - public base::trace_event::TracingAgent {
|
| +class TracingControllerImpl : public TracingController,
|
| + public mojo::common::DataPipeDrainer::Client {
|
| public:
|
| // Create an endpoint that may be supplied to any TraceDataSink to
|
| // dump the trace data to a callback.
|
| @@ -62,6 +64,8 @@ class TracingControllerImpl
|
|
|
| static TracingControllerImpl* GetInstance();
|
|
|
| + void Initialize(service_manager::Connector* connector);
|
| +
|
| // TracingController implementation.
|
| bool GetCategories(const GetCategoriesDoneCallback& callback) override;
|
| bool StartTracing(const base::trace_event::TraceConfig& trace_config,
|
| @@ -76,17 +80,6 @@ class TracingControllerImpl
|
| void RegisterTracingUI(TracingUI* tracing_ui);
|
| void UnregisterTracingUI(TracingUI* tracing_ui);
|
|
|
| - // base::trace_event::TracingAgent implementation.
|
| - std::string GetTracingAgentName() override;
|
| - std::string GetTraceEventLabel() override;
|
| - void StartAgentTracing(const base::trace_event::TraceConfig& trace_config,
|
| - const StartAgentTracingCallback& callback) override;
|
| - void StopAgentTracing(const StopAgentTracingCallback& callback) override;
|
| - bool SupportsExplicitClockSync() override;
|
| - void RecordClockSyncMarker(
|
| - const std::string& sync_id,
|
| - const RecordClockSyncMarkerCallback& callback) override;
|
| -
|
| class TraceMessageFilterObserver {
|
| public:
|
| virtual void OnTraceMessageFilterAdded(TraceMessageFilter* filter) = 0;
|
| @@ -102,112 +95,39 @@ class TracingControllerImpl
|
| TracingControllerImpl();
|
| ~TracingControllerImpl() override;
|
|
|
| - bool can_start_tracing() const { return !enabled_tracing_modes_; }
|
| -
|
| - bool can_stop_tracing() const {
|
| - return enabled_tracing_modes_ && !trace_data_sink_.get();
|
| - }
|
| -
|
| - bool can_start_monitoring() const {
|
| - return !is_monitoring_;
|
| - }
|
| -
|
| - bool can_stop_monitoring() const {
|
| - return is_monitoring_ && !monitoring_data_sink_.get();
|
| - }
|
| -
|
| - bool can_get_trace_buffer_usage() const {
|
| - return pending_trace_buffer_usage_callback_.is_null();
|
| - }
|
| -
|
| // Methods for use by TraceMessageFilter.
|
| void AddTraceMessageFilter(TraceMessageFilter* trace_message_filter);
|
| void RemoveTraceMessageFilter(TraceMessageFilter* trace_message_filter);
|
|
|
| - void OnTraceDataCollected(
|
| - 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);
|
| -
|
| - // Adds the tracing agent with the specified agent name to the list of
|
| - // additional tracing agents.
|
| - void AddTracingAgent(const std::string& agent_name);
|
| -
|
| - void OnStartAgentTracingAcked(const std::string& agent_name, bool success);
|
| -
|
| - void OnStopTracingAcked(
|
| - TraceMessageFilter* trace_message_filter,
|
| - const std::vector<std::string>& known_category_groups);
|
| -
|
| - void OnEndAgentTracingAcked(
|
| - const std::string& agent_name,
|
| - const std::string& events_label,
|
| - const scoped_refptr<base::RefCountedString>& events_str_ptr);
|
| -
|
| - void OnTraceLogStatusReply(TraceMessageFilter* trace_message_filter,
|
| - const base::trace_event::TraceLogStatus& status);
|
| -
|
| - void SetEnabledOnFileThread(
|
| - const base::trace_event::TraceConfig& trace_config,
|
| - const base::Closure& callback);
|
| - void SetDisabledOnFileThread(const base::Closure& callback);
|
| - void OnAllTracingAgentsStarted();
|
| - void StopTracingAfterClockSync();
|
| - void OnStopTracingDone();
|
| -
|
| - // Issue clock sync markers to the tracing agents.
|
| - void IssueClockSyncMarker();
|
| - void OnClockSyncMarkerRecordedByAgent(
|
| - const std::string& sync_id,
|
| - const base::TimeTicks& issue_ts,
|
| - const base::TimeTicks& issue_end_ts);
|
| -
|
| void AddFilteredMetadata(TracingController::TraceDataSink* sink,
|
| std::unique_ptr<base::DictionaryValue> metadata,
|
| const MetadataFilterPredicate& filter);
|
|
|
| - std::unique_ptr<base::DictionaryValue> GenerateTracingMetadataDict() const;
|
| + void GetCategoriesDone(const GetCategoriesDoneCallback& callback,
|
| + const std::string& categories);
|
| + void GetTraceBufferUsageDone(const GetTraceBufferUsageCallback& callback,
|
| + bool success,
|
| + float percent_full,
|
| + uint32_t approximate_count);
|
| +
|
| + // mojo::common::DataPipeDrainer::Client
|
| + void OnDataAvailable(const void* data, size_t num_bytes) override;
|
| + void OnDataComplete() override;
|
|
|
| typedef std::set<scoped_refptr<TraceMessageFilter>> TraceMessageFilterSet;
|
| TraceMessageFilterSet trace_message_filters_;
|
|
|
| - // Pending acks for StartTracing.
|
| - int pending_start_tracing_ack_count_;
|
| - base::OneShotTimer start_tracing_timer_;
|
| - StartTracingDoneCallback start_tracing_done_callback_;
|
| - std::unique_ptr<base::trace_event::TraceConfig> trace_config_;
|
| -
|
| - // Pending acks for StopTracing.
|
| - int pending_stop_tracing_ack_count_;
|
| - TraceMessageFilterSet pending_stop_tracing_filters_;
|
| -
|
| - // Pending acks for GetTraceLogStatus.
|
| - int pending_trace_log_status_ack_count_;
|
| - TraceMessageFilterSet pending_trace_log_status_filters_;
|
| - float maximum_trace_buffer_usage_;
|
| - size_t approximate_event_count_;
|
| -
|
| - std::vector<base::trace_event::TracingAgent*> additional_tracing_agents_;
|
| - int pending_clock_sync_ack_count_;
|
| - base::OneShotTimer clock_sync_timer_;
|
| -
|
| - uint8_t enabled_tracing_modes_;
|
| - bool is_monitoring_;
|
| -
|
| - GetCategoriesDoneCallback pending_get_categories_done_callback_;
|
| - GetTraceBufferUsageCallback pending_trace_buffer_usage_callback_;
|
| -
|
| base::ObserverList<TraceMessageFilterObserver>
|
| trace_message_filter_observers_;
|
|
|
| - std::set<std::string> known_category_groups_;
|
| std::set<TracingUI*> tracing_uis_;
|
| scoped_refptr<TraceDataSink> trace_data_sink_;
|
| scoped_refptr<TraceDataSink> monitoring_data_sink_;
|
| std::unique_ptr<base::DictionaryValue> metadata_;
|
| + bool is_tracing_ = false;
|
| +
|
| + resource_coordinator::tracing::mojom::CoordinatorPtr coordinator_;
|
| + std::unique_ptr<mojo::common::DataPipeDrainer> drainer_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
|
| };
|
|
|