1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_
11 #include "base/memory/weak_ptr.h"
12 #include "base/trace_event/trace_event.h"
13 #include "content/browser/devtools/protocol/devtools_protocol_handler.h"
14 #include "content/public/browser/tracing_controller.h"
17 class RefCountedString
;
25 class TracingHandler
{
27 typedef DevToolsProtocolClient::Response Response
;
29 enum Target
{ Browser
, Renderer
};
30 explicit TracingHandler(Target target
);
31 virtual ~TracingHandler();
33 void SetClient(scoped_ptr
<Client
> client
);
36 void OnTraceDataCollected(const std::string
& trace_fragment
);
37 void OnTraceComplete();
39 Response
Start(DevToolsCommandId command_id
,
40 const std::string
* categories
,
41 const std::string
* options
,
42 const double* buffer_usage_reporting_interval
);
43 Response
End(DevToolsCommandId command_id
);
44 Response
GetCategories(DevToolsCommandId command
);
47 void OnRecordingEnabled(DevToolsCommandId command_id
);
48 void OnBufferUsage(float percent_full
, size_t approximate_event_count
);
50 void OnCategoriesReceived(DevToolsCommandId command_id
,
51 const std::set
<std::string
>& category_set
);
53 base::trace_event::TraceOptions
TraceOptionsFromString(
54 const std::string
* options
);
56 void SetupTimer(double usage_reporting_interval
);
58 void DisableRecording(bool abort
);
60 scoped_ptr
<base::Timer
> buffer_usage_poll_timer_
;
64 scoped_ptr
<Client
> client_
;
65 base::WeakPtrFactory
<TracingHandler
> weak_factory_
;
67 DISALLOW_COPY_AND_ASSIGN(TracingHandler
);
70 } // namespace tracing
71 } // namespace devtools
72 } // namespace content
74 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_