1 // Copyright (c) 2012 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_DEVTOOLS_TRACING_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_
11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/devtools/devtools_protocol.h"
13 #include "content/public/browser/tracing_controller.h"
16 class RefCountedString
;
22 // This class bridges DevTools remote debugging server with the trace
24 class DevToolsTracingHandler
: public DevToolsProtocol::Handler
{
26 enum Target
{ Browser
, Renderer
};
27 explicit DevToolsTracingHandler(Target target
);
28 virtual ~DevToolsTracingHandler();
30 void OnClientDetached();
33 void BeginReadingRecordingResult(const base::FilePath
& path
);
34 void ReadRecordingResult(const scoped_refptr
<base::RefCountedString
>& result
);
35 void OnTraceDataCollected(const std::string
& trace_fragment
);
36 void OnTracingStarted(scoped_refptr
<DevToolsProtocol::Command
> command
);
37 void OnBufferUsage(float usage
);
39 scoped_refptr
<DevToolsProtocol::Response
> OnStart(
40 scoped_refptr
<DevToolsProtocol::Command
> command
);
41 scoped_refptr
<DevToolsProtocol::Response
> OnEnd(
42 scoped_refptr
<DevToolsProtocol::Command
> command
);
44 scoped_refptr
<DevToolsProtocol::Response
> OnGetCategories(
45 scoped_refptr
<DevToolsProtocol::Command
> command
);
46 void OnCategoriesReceived(scoped_refptr
<DevToolsProtocol::Command
> command
,
47 const std::set
<std::string
>& category_set
);
49 TracingController::Options
TraceOptionsFromString(const std::string
& options
);
51 void DisableRecording(
52 const TracingController::TracingFileResultCallback
& callback
=
53 TracingController::TracingFileResultCallback());
55 base::WeakPtrFactory
<DevToolsTracingHandler
> weak_factory_
;
56 scoped_ptr
<base::Timer
> buffer_usage_poll_timer_
;
58 DISALLOW_COPY_AND_ASSIGN(DevToolsTracingHandler
);
61 } // namespace content
63 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_