| 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> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 13 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
| 14 #include "content/public/browser/tracing_controller.h" | 14 #include "content/public/browser/tracing_controller.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class RefCountedString; | 17 class RefCountedString; |
| 18 class Timer; | 18 class Timer; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 namespace devtools { | 22 namespace devtools { |
| 23 |
| 24 class DevToolsIOContext; |
| 25 |
| 23 namespace tracing { | 26 namespace tracing { |
| 24 | 27 |
| 25 class TracingHandler { | 28 class TracingHandler { |
| 26 public: | 29 public: |
| 27 typedef DevToolsProtocolClient::Response Response; | 30 typedef DevToolsProtocolClient::Response Response; |
| 28 | 31 |
| 29 enum Target { Browser, Renderer }; | 32 enum Target { Browser, Renderer }; |
| 30 explicit TracingHandler(Target target); | 33 TracingHandler(Target target, DevToolsIOContext* io_context); |
| 31 virtual ~TracingHandler(); | 34 virtual ~TracingHandler(); |
| 32 | 35 |
| 33 void SetClient(scoped_ptr<Client> client); | 36 void SetClient(scoped_ptr<Client> client); |
| 34 void Detached(); | 37 void Detached(); |
| 35 | 38 |
| 36 void OnTraceDataCollected(const std::string& trace_fragment); | 39 void OnTraceDataCollected(const std::string& trace_fragment); |
| 37 void OnTraceComplete(); | 40 void OnTraceComplete(); |
| 41 void OnTraceToStreamComplete(const std::string& stream_id); |
| 38 | 42 |
| 43 // Protocol methods. |
| 39 Response Start(DevToolsCommandId command_id, | 44 Response Start(DevToolsCommandId command_id, |
| 40 const std::string* categories, | 45 const std::string* categories, |
| 41 const std::string* options, | 46 const std::string* options, |
| 42 const double* buffer_usage_reporting_interval); | 47 const double* buffer_usage_reporting_interval); |
| 43 Response End(DevToolsCommandId command_id); | 48 Response End(DevToolsCommandId command_id); |
| 49 Response End(DevToolsCommandId command_id, const bool* return_as_stream); |
| 44 Response GetCategories(DevToolsCommandId command); | 50 Response GetCategories(DevToolsCommandId command); |
| 45 Response RequestMemoryDump(DevToolsCommandId command_id); | 51 Response RequestMemoryDump(DevToolsCommandId command_id); |
| 52 |
| 46 bool did_initiate_recording() { return did_initiate_recording_; } | 53 bool did_initiate_recording() { return did_initiate_recording_; } |
| 47 | 54 |
| 48 private: | 55 private: |
| 49 void OnRecordingEnabled(DevToolsCommandId command_id); | 56 void OnRecordingEnabled(DevToolsCommandId command_id); |
| 50 void OnBufferUsage(float percent_full, size_t approximate_event_count); | 57 void OnBufferUsage(float percent_full, size_t approximate_event_count); |
| 51 | 58 |
| 52 void OnCategoriesReceived(DevToolsCommandId command_id, | 59 void OnCategoriesReceived(DevToolsCommandId command_id, |
| 53 const std::set<std::string>& category_set); | 60 const std::set<std::string>& category_set); |
| 54 void OnMemoryDumpFinished(DevToolsCommandId command_id, | 61 void OnMemoryDumpFinished(DevToolsCommandId command_id, |
| 55 uint64 dump_guid, | 62 uint64 dump_guid, |
| 56 bool success); | 63 bool success); |
| 57 | 64 |
| 58 void SetupTimer(double usage_reporting_interval); | 65 void SetupTimer(double usage_reporting_interval); |
| 59 | 66 |
| 60 void DisableRecording(bool abort); | 67 void DisableRecording( |
| 68 const scoped_refptr<TracingController::TraceDataSink>& trace_data_sink); |
| 61 | 69 |
| 62 bool IsRecording() const; | 70 bool IsRecording() const; |
| 63 | 71 |
| 64 scoped_ptr<base::Timer> buffer_usage_poll_timer_; | 72 scoped_ptr<base::Timer> buffer_usage_poll_timer_; |
| 65 Target target_; | 73 Target target_; |
| 66 | 74 |
| 67 scoped_ptr<Client> client_; | 75 scoped_ptr<Client> client_; |
| 68 bool did_initiate_recording_; | 76 bool did_initiate_recording_; |
| 77 DevToolsIOContext* io_context_; |
| 69 base::WeakPtrFactory<TracingHandler> weak_factory_; | 78 base::WeakPtrFactory<TracingHandler> weak_factory_; |
| 70 | 79 |
| 71 DISALLOW_COPY_AND_ASSIGN(TracingHandler); | 80 DISALLOW_COPY_AND_ASSIGN(TracingHandler); |
| 72 }; | 81 }; |
| 73 | 82 |
| 74 } // namespace tracing | 83 } // namespace tracing |
| 75 } // namespace devtools | 84 } // namespace devtools |
| 76 } // namespace content | 85 } // namespace content |
| 77 | 86 |
| 78 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ | 87 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ |
| OLD | NEW |