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. 4 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ 7 8 #include "base/memory/weak_ptr.h" 9 #include "content/browser/devtools/devtools_protocol.h" 10 #include "content/public/browser/tracing_controller.h" 11 12 namespace base { 13 class RefCountedString; 14 } 15 16 namespace content { 17 18 // This class bridges DevTools remote debugging server with the trace 19 // infrastructure. 20 class DevToolsTracingHandler : public DevToolsProtocol::Handler { 21 public: 22 DevToolsTracingHandler(); 23 virtual ~DevToolsTracingHandler(); 24 25 private: 26 void BeginReadingRecordingResult(const base::FilePath& path); 27 void ReadRecordingResult(const scoped_refptr<base::RefCountedString>& result); 28 void OnTraceDataCollected(const std::string& trace_fragment); 29 30 scoped_refptr<DevToolsProtocol::Response> OnStart( 31 scoped_refptr<DevToolsProtocol::Command> command); 32 scoped_refptr<DevToolsProtocol::Response> OnEnd( 33 scoped_refptr<DevToolsProtocol::Command> command); 34 35 TracingController::Options TraceOptionsFromString(const std::string& options); 36 37 base::WeakPtrFactory<DevToolsTracingHandler> weak_factory_; 38 39 DISALLOW_COPY_AND_ASSIGN(DevToolsTracingHandler); 40 }; 41 42 } // namespace content 43 44 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ 45