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" |
8 #include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h" | 13 #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 } |
9 | 20 |
10 namespace content { | 21 namespace content { |
11 namespace devtools { | 22 namespace devtools { |
12 namespace tracing { | 23 namespace tracing { |
13 | 24 |
14 class TracingHandler { | 25 class TracingHandler { |
15 public: | 26 public: |
16 typedef DevToolsProtocolClient::Response Response; | 27 typedef DevToolsProtocolClient::Response Response; |
17 | 28 |
18 TracingHandler(); | 29 enum Target { Browser, Renderer }; |
| 30 explicit TracingHandler(Target target); |
19 virtual ~TracingHandler(); | 31 virtual ~TracingHandler(); |
20 | 32 |
21 void SetClient(scoped_ptr<Client> client); | 33 void SetClient(scoped_ptr<Client> client); |
| 34 void Detached(); |
22 | 35 |
23 scoped_refptr<DevToolsProtocol::Response> Start( | 36 void OnTraceDataCollected(const std::string& trace_fragment); |
24 const std::string& categories, | 37 void OnTraceComplete(); |
25 const std::string& options, | 38 |
26 const double* buffer_usage_reporting_interval, | |
27 scoped_refptr<DevToolsProtocol::Command> command); | |
28 scoped_refptr<DevToolsProtocol::Response> Start( | 39 scoped_refptr<DevToolsProtocol::Response> Start( |
29 const std::string* categories, | 40 const std::string* categories, |
30 const std::string* options, | 41 const std::string* options, |
31 const double* buffer_usage_reporting_interval, | 42 const double* buffer_usage_reporting_interval, |
32 scoped_refptr<DevToolsProtocol::Command> command); | 43 scoped_refptr<DevToolsProtocol::Command> command); |
33 | 44 |
34 scoped_refptr<DevToolsProtocol::Response> End( | 45 scoped_refptr<DevToolsProtocol::Response> End( |
35 scoped_refptr<DevToolsProtocol::Command> command); | 46 scoped_refptr<DevToolsProtocol::Command> command); |
36 | |
37 scoped_refptr<DevToolsProtocol::Response> GetCategories( | 47 scoped_refptr<DevToolsProtocol::Response> GetCategories( |
38 scoped_refptr<DevToolsProtocol::Command> command); | 48 scoped_refptr<DevToolsProtocol::Command> command); |
39 | 49 |
40 private: | 50 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 |
41 scoped_ptr<Client> client_; | 67 scoped_ptr<Client> client_; |
| 68 base::WeakPtrFactory<TracingHandler> weak_factory_; |
42 | 69 |
43 DISALLOW_COPY_AND_ASSIGN(TracingHandler); | 70 DISALLOW_COPY_AND_ASSIGN(TracingHandler); |
44 }; | 71 }; |
45 | 72 |
46 } // namespace tracing | 73 } // namespace tracing |
47 } // namespace devtools | 74 } // namespace devtools |
48 } // namespace content | 75 } // namespace content |
49 | 76 |
50 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ | 77 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ |
OLD | NEW |