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 #include "content/browser/devtools/protocol/tracing_handler.h" | 5 #include "content/browser/devtools/protocol/tracing_handler.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
17 #include "base/trace_event/memory_dump_manager.h" | 17 #include "base/trace_event/memory_dump_manager.h" |
18 #include "base/trace_event/trace_event_impl.h" | 18 #include "base/trace_event/trace_event_impl.h" |
19 #include "base/trace_event/tracing_agent.h" | 19 #include "base/trace_event/tracing_agent.h" |
20 #include "components/tracing/browser/trace_config_file.h" | 20 #include "components/tracing/browser/trace_config_file.h" |
21 #include "content/browser/devtools/devtools_io_context.h" | 21 #include "content/browser/devtools/devtools_io_context.h" |
| 22 #include "content/browser/devtools/devtools_session.h" |
22 #include "content/browser/tracing/tracing_controller_impl.h" | 23 #include "content/browser/tracing/tracing_controller_impl.h" |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 namespace protocol { | 26 namespace protocol { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 const double kMinimumReportingInterval = 250.0; | 30 const double kMinimumReportingInterval = 250.0; |
30 | 31 |
31 const char kRecordModeParam[] = "record_mode"; | 32 const char kRecordModeParam[] = "record_mode"; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 112 |
112 scoped_refptr<DevToolsIOContext::Stream> stream_; | 113 scoped_refptr<DevToolsIOContext::Stream> stream_; |
113 base::WeakPtr<TracingHandler> tracing_handler_; | 114 base::WeakPtr<TracingHandler> tracing_handler_; |
114 }; | 115 }; |
115 | 116 |
116 } // namespace | 117 } // namespace |
117 | 118 |
118 TracingHandler::TracingHandler(TracingHandler::Target target, | 119 TracingHandler::TracingHandler(TracingHandler::Target target, |
119 int frame_tree_node_id, | 120 int frame_tree_node_id, |
120 DevToolsIOContext* io_context) | 121 DevToolsIOContext* io_context) |
121 : target_(target), | 122 : DevToolsDomainHandler(Tracing::Metainfo::domainName), |
| 123 target_(target), |
122 io_context_(io_context), | 124 io_context_(io_context), |
123 frame_tree_node_id_(frame_tree_node_id), | 125 frame_tree_node_id_(frame_tree_node_id), |
124 did_initiate_recording_(false), | 126 did_initiate_recording_(false), |
125 return_as_stream_(false), | 127 return_as_stream_(false), |
126 weak_factory_(this) {} | 128 weak_factory_(this) {} |
127 | 129 |
128 TracingHandler::~TracingHandler() { | 130 TracingHandler::~TracingHandler() { |
129 } | 131 } |
130 | 132 |
| 133 // static |
| 134 TracingHandler* TracingHandler::FromSession(DevToolsSession* session) { |
| 135 return static_cast<TracingHandler*>( |
| 136 session->GetHandlerByName(Tracing::Metainfo::domainName)); |
| 137 } |
| 138 |
131 void TracingHandler::Wire(UberDispatcher* dispatcher) { | 139 void TracingHandler::Wire(UberDispatcher* dispatcher) { |
132 frontend_.reset(new Tracing::Frontend(dispatcher->channel())); | 140 frontend_.reset(new Tracing::Frontend(dispatcher->channel())); |
133 Tracing::Dispatcher::wire(dispatcher, this); | 141 Tracing::Dispatcher::wire(dispatcher, this); |
134 } | 142 } |
135 | 143 |
136 Response TracingHandler::Disable() { | 144 Response TracingHandler::Disable() { |
137 if (did_initiate_recording_) | 145 if (did_initiate_recording_) |
138 StopTracing(scoped_refptr<TracingController::TraceDataSink>()); | 146 StopTracing(scoped_refptr<TracingController::TraceDataSink>()); |
139 return Response::OK(); | 147 return Response::OK(); |
140 } | 148 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 359 |
352 std::string mode; | 360 std::string mode; |
353 if (tracing_dict->GetString(kRecordModeParam, &mode)) | 361 if (tracing_dict->GetString(kRecordModeParam, &mode)) |
354 tracing_dict->SetString(kRecordModeParam, ConvertFromCamelCase(mode, '-')); | 362 tracing_dict->SetString(kRecordModeParam, ConvertFromCamelCase(mode, '-')); |
355 | 363 |
356 return base::trace_event::TraceConfig(*tracing_dict); | 364 return base::trace_event::TraceConfig(*tracing_dict); |
357 } | 365 } |
358 | 366 |
359 } // namespace tracing | 367 } // namespace tracing |
360 } // namespace protocol | 368 } // namespace protocol |
OLD | NEW |