OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_DEVTOOLS_TRACING_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 // This class bridges DevTools remote debugging server with the trace | 23 // This class bridges DevTools remote debugging server with the trace |
24 // infrastructure. | 24 // infrastructure. |
25 class DevToolsTracingHandler : public DevToolsProtocol::Handler { | 25 class DevToolsTracingHandler : public DevToolsProtocol::Handler { |
26 public: | 26 public: |
27 enum Target { Browser, Renderer }; | 27 enum Target { Browser, Renderer }; |
28 explicit DevToolsTracingHandler(Target target); | 28 explicit DevToolsTracingHandler(Target target); |
29 virtual ~DevToolsTracingHandler(); | 29 virtual ~DevToolsTracingHandler(); |
30 | 30 |
31 void OnClientDetached(); | 31 void OnClientDetached(); |
32 | 32 |
| 33 void EnableTracing(const std::string& category_filter); |
| 34 void DisableTracing(); |
| 35 |
33 private: | 36 private: |
34 void BeginReadingRecordingResult(const base::FilePath& path); | 37 void BeginReadingRecordingResult(const base::FilePath& path); |
35 void ReadRecordingResult(const scoped_refptr<base::RefCountedString>& result); | 38 void ReadRecordingResult(const scoped_refptr<base::RefCountedString>& result); |
36 void OnTraceDataCollected(const std::string& trace_fragment); | 39 void OnTraceDataCollected(const std::string& trace_fragment); |
37 void OnRecordingEnabled(scoped_refptr<DevToolsProtocol::Command> command); | 40 void OnRecordingEnabled(scoped_refptr<DevToolsProtocol::Command> command); |
38 void OnBufferUsage(float usage); | 41 void OnBufferUsage(float usage); |
39 | 42 |
40 scoped_refptr<DevToolsProtocol::Response> OnStart( | 43 scoped_refptr<DevToolsProtocol::Response> OnStart( |
41 scoped_refptr<DevToolsProtocol::Command> command); | 44 scoped_refptr<DevToolsProtocol::Command> command); |
42 scoped_refptr<DevToolsProtocol::Response> OnEnd( | 45 scoped_refptr<DevToolsProtocol::Response> OnEnd( |
43 scoped_refptr<DevToolsProtocol::Command> command); | 46 scoped_refptr<DevToolsProtocol::Command> command); |
44 | 47 |
45 scoped_refptr<DevToolsProtocol::Response> OnGetCategories( | 48 scoped_refptr<DevToolsProtocol::Response> OnGetCategories( |
46 scoped_refptr<DevToolsProtocol::Command> command); | 49 scoped_refptr<DevToolsProtocol::Command> command); |
47 | 50 |
48 void OnTracingStarted( | |
49 scoped_refptr<DevToolsProtocol::Notification> notification); | |
50 | |
51 void OnTracingStopped( | |
52 scoped_refptr<DevToolsProtocol::Notification> notification); | |
53 | |
54 void OnCategoriesReceived(scoped_refptr<DevToolsProtocol::Command> command, | 51 void OnCategoriesReceived(scoped_refptr<DevToolsProtocol::Command> command, |
55 const std::set<std::string>& category_set); | 52 const std::set<std::string>& category_set); |
56 | 53 |
57 base::debug::TraceOptions TraceOptionsFromString(const std::string& options); | 54 base::debug::TraceOptions TraceOptionsFromString(const std::string& options); |
58 | 55 |
59 void SetupTimer(double usage_reporting_interval); | 56 void SetupTimer(double usage_reporting_interval); |
60 | 57 |
61 void DisableRecording( | 58 void DisableRecording( |
62 const TracingController::TracingFileResultCallback& callback = | 59 const TracingController::TracingFileResultCallback& callback = |
63 TracingController::TracingFileResultCallback()); | 60 TracingController::TracingFileResultCallback()); |
64 | 61 |
65 base::WeakPtrFactory<DevToolsTracingHandler> weak_factory_; | 62 base::WeakPtrFactory<DevToolsTracingHandler> weak_factory_; |
66 scoped_ptr<base::Timer> buffer_usage_poll_timer_; | 63 scoped_ptr<base::Timer> buffer_usage_poll_timer_; |
67 Target target_; | 64 Target target_; |
68 bool is_recording_; | 65 bool is_recording_; |
69 | 66 |
70 static const char* kDefaultCategories; | 67 static const char* kDefaultCategories; |
71 static const double kDefaultReportingInterval; | 68 static const double kDefaultReportingInterval; |
72 static const double kMinimumReportingInterval; | 69 static const double kMinimumReportingInterval; |
73 | 70 |
74 DISALLOW_COPY_AND_ASSIGN(DevToolsTracingHandler); | 71 DISALLOW_COPY_AND_ASSIGN(DevToolsTracingHandler); |
75 }; | 72 }; |
76 | 73 |
77 } // namespace content | 74 } // namespace content |
78 | 75 |
79 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ | 76 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_ |
OLD | NEW |