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_dispatcher.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
);
45 Response
RequestMemoryDump(DevToolsCommandId command_id
);
46 bool did_initiate_recording() { return did_initiate_recording_
; }
49 void OnRecordingEnabled(DevToolsCommandId command_id
);
50 void OnBufferUsage(float percent_full
, size_t approximate_event_count
);
52 void OnCategoriesReceived(DevToolsCommandId command_id
,
53 const std::set
<std::string
>& category_set
);
54 void OnMemoryDumpFinished(DevToolsCommandId command_id
,
58 void SetupTimer(double usage_reporting_interval
);
60 void DisableRecording(bool abort
);
62 bool IsRecording() const;
64 scoped_ptr
<base::Timer
> buffer_usage_poll_timer_
;
67 scoped_ptr
<Client
> client_
;
68 bool did_initiate_recording_
;
69 base::WeakPtrFactory
<TracingHandler
> weak_factory_
;
71 DISALLOW_COPY_AND_ASSIGN(TracingHandler
);
74 } // namespace tracing
75 } // namespace devtools
76 } // namespace content
78 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_