| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ |
| 7 | 7 |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/debug/trace_event.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h" | 8 #include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h" |
| 14 #include "content/public/browser/tracing_controller.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class RefCountedString; | |
| 18 class Timer; | |
| 19 } | |
| 20 | 9 |
| 21 namespace content { | 10 namespace content { |
| 22 namespace devtools { | 11 namespace devtools { |
| 23 namespace tracing { | 12 namespace tracing { |
| 24 | 13 |
| 25 class TracingHandler { | 14 class TracingHandler { |
| 26 public: | 15 public: |
| 27 typedef DevToolsProtocolClient::Response Response; | 16 typedef DevToolsProtocolClient::Response Response; |
| 28 | 17 |
| 29 enum Target { Browser, Renderer }; | 18 TracingHandler(); |
| 30 explicit TracingHandler(Target target); | |
| 31 virtual ~TracingHandler(); | 19 virtual ~TracingHandler(); |
| 32 | 20 |
| 33 void SetClient(scoped_ptr<Client> client); | 21 void SetClient(scoped_ptr<Client> client); |
| 34 void Detached(); | |
| 35 | 22 |
| 36 void OnTraceDataCollected(const std::string& trace_fragment); | 23 scoped_refptr<DevToolsProtocol::Response> Start( |
| 37 void OnTraceComplete(); | 24 const std::string& categories, |
| 38 | 25 const std::string& options, |
| 26 const double* buffer_usage_reporting_interval, |
| 27 scoped_refptr<DevToolsProtocol::Command> command); |
| 39 scoped_refptr<DevToolsProtocol::Response> Start( | 28 scoped_refptr<DevToolsProtocol::Response> Start( |
| 40 const std::string* categories, | 29 const std::string* categories, |
| 41 const std::string* options, | 30 const std::string* options, |
| 42 const double* buffer_usage_reporting_interval, | 31 const double* buffer_usage_reporting_interval, |
| 43 scoped_refptr<DevToolsProtocol::Command> command); | 32 scoped_refptr<DevToolsProtocol::Command> command); |
| 44 | 33 |
| 45 scoped_refptr<DevToolsProtocol::Response> End( | 34 scoped_refptr<DevToolsProtocol::Response> End( |
| 46 scoped_refptr<DevToolsProtocol::Command> command); | 35 scoped_refptr<DevToolsProtocol::Command> command); |
| 36 |
| 47 scoped_refptr<DevToolsProtocol::Response> GetCategories( | 37 scoped_refptr<DevToolsProtocol::Response> GetCategories( |
| 48 scoped_refptr<DevToolsProtocol::Command> command); | 38 scoped_refptr<DevToolsProtocol::Command> command); |
| 49 | 39 |
| 50 private: | 40 private: |
| 51 void OnRecordingEnabled(scoped_refptr<DevToolsProtocol::Command> command); | |
| 52 void OnBufferUsage(float usage); | |
| 53 | |
| 54 void OnCategoriesReceived(scoped_refptr<DevToolsProtocol::Command> command, | |
| 55 const std::set<std::string>& category_set); | |
| 56 | |
| 57 base::debug::TraceOptions TraceOptionsFromString(const std::string* options); | |
| 58 | |
| 59 void SetupTimer(double usage_reporting_interval); | |
| 60 | |
| 61 void DisableRecording(bool abort); | |
| 62 | |
| 63 scoped_ptr<base::Timer> buffer_usage_poll_timer_; | |
| 64 Target target_; | |
| 65 bool is_recording_; | |
| 66 | |
| 67 scoped_ptr<Client> client_; | 41 scoped_ptr<Client> client_; |
| 68 base::WeakPtrFactory<TracingHandler> weak_factory_; | |
| 69 | 42 |
| 70 DISALLOW_COPY_AND_ASSIGN(TracingHandler); | 43 DISALLOW_COPY_AND_ASSIGN(TracingHandler); |
| 71 }; | 44 }; |
| 72 | 45 |
| 73 } // namespace tracing | 46 } // namespace tracing |
| 74 } // namespace devtools | 47 } // namespace devtools |
| 75 } // namespace content | 48 } // namespace content |
| 76 | 49 |
| 77 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ | 50 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ |
| OLD | NEW |