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 // TODO(dgozman): remove sync version after migration. | 36 void OnTraceDataCollected(const std::string& trace_fragment); |
24 Response Start(const std::string& categories, | 37 void OnTraceComplete(); |
25 const std::string& options, | 38 |
26 const double* buffer_usage_reporting_interval); | |
27 scoped_refptr<DevToolsProtocol::Response> Start( | 39 scoped_refptr<DevToolsProtocol::Response> Start( |
28 const std::string& categories, | 40 const std::string& categories, |
29 const std::string& options, | 41 const std::string& options, |
30 const double* buffer_usage_reporting_interval, | 42 const double* buffer_usage_reporting_interval, |
31 scoped_refptr<DevToolsProtocol::Command> command); | 43 scoped_refptr<DevToolsProtocol::Command> command); |
32 | |
33 // TODO(dgozman): remove sync version after migration. | |
34 Response End(); | |
35 scoped_refptr<DevToolsProtocol::Response> End( | 44 scoped_refptr<DevToolsProtocol::Response> End( |
36 scoped_refptr<DevToolsProtocol::Command> command); | 45 scoped_refptr<DevToolsProtocol::Command> command); |
37 | |
38 scoped_refptr<DevToolsProtocol::Response> GetCategories( | 46 scoped_refptr<DevToolsProtocol::Response> GetCategories( |
39 scoped_refptr<DevToolsProtocol::Command> command); | 47 scoped_refptr<DevToolsProtocol::Command> command); |
40 | 48 |
41 private: | 49 private: |
50 void OnRecordingEnabled(scoped_refptr<DevToolsProtocol::Command> command); | |
51 void OnBufferUsage(float usage); | |
52 | |
53 void OnCategoriesReceived(scoped_refptr<DevToolsProtocol::Command> command, | |
54 const std::set<std::string>& category_set); | |
55 | |
56 base::debug::TraceOptions TraceOptionsFromString(const std::string& options); | |
57 | |
58 void SetupTimer(double usage_reporting_interval); | |
59 | |
60 void DisableRecording(bool abort); | |
61 | |
62 scoped_ptr<base::Timer> buffer_usage_poll_timer_; | |
63 Target target_; | |
64 bool is_recording_; | |
65 | |
66 static const char* kDefaultCategories; | |
caseq
2014/10/13 13:01:27
Do we need these exposed in the header file? Use a
dgozman
2014/10/14 12:42:22
We don't. I just moved this code as it was before.
| |
67 static const double kDefaultReportingInterval; | |
68 static const double kMinimumReportingInterval; | |
69 | |
42 scoped_ptr<Client> client_; | 70 scoped_ptr<Client> client_; |
71 base::WeakPtrFactory<TracingHandler> weak_factory_; | |
43 | 72 |
44 DISALLOW_COPY_AND_ASSIGN(TracingHandler); | 73 DISALLOW_COPY_AND_ASSIGN(TracingHandler); |
45 }; | 74 }; |
46 | 75 |
47 } // namespace tracing | 76 } // namespace tracing |
48 } // namespace devtools | 77 } // namespace devtools |
49 } // namespace content | 78 } // namespace content |
50 | 79 |
51 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ | 80 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ |
OLD | NEW |