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/debug/trace_event_impl.h" | 10 #include "base/debug/trace_event_impl.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 weak_factory_.GetWeakPtr(), | 135 weak_factory_.GetWeakPtr(), |
136 command)); | 136 command)); |
137 return command->AsyncResponsePromise(); | 137 return command->AsyncResponsePromise(); |
138 } | 138 } |
139 | 139 |
140 void TracingHandler::OnRecordingEnabled( | 140 void TracingHandler::OnRecordingEnabled( |
141 scoped_refptr<DevToolsProtocol::Command> command) { | 141 scoped_refptr<DevToolsProtocol::Command> command) { |
142 client_->SendStartResponse(command, StartResponse::Create()); | 142 client_->SendStartResponse(command, StartResponse::Create()); |
143 } | 143 } |
144 | 144 |
145 void TracingHandler::OnBufferUsage(float usage) { | 145 void TracingHandler::OnBufferUsage(float percent_full, |
146 client_->BufferUsage(BufferUsageParams::Create()->set_value(usage)); | 146 size_t approximate_event_count) { |
147 client_->BufferUsage(BufferUsageParams::Create()->set_value(percent_full)); | |
nduca
2014/11/14 18:11:16
i think you're changing the protocol response to b
yurys
2014/11/17 09:10:01
I'm not changing the event here. My plan was to ad
| |
147 } | 148 } |
148 | 149 |
149 void TracingHandler::OnCategoriesReceived( | 150 void TracingHandler::OnCategoriesReceived( |
150 scoped_refptr<DevToolsProtocol::Command> command, | 151 scoped_refptr<DevToolsProtocol::Command> command, |
151 const std::set<std::string>& category_set) { | 152 const std::set<std::string>& category_set) { |
152 std::vector<std::string> categories; | 153 std::vector<std::string> categories; |
153 for (const std::string& category : category_set) | 154 for (const std::string& category : category_set) |
154 categories.push_back(category); | 155 categories.push_back(category); |
155 client_->SendGetCategoriesResponse(command, | 156 client_->SendGetCategoriesResponse(command, |
156 GetCategoriesResponse::Create()->set_categories(categories)); | 157 GetCategoriesResponse::Create()->set_categories(categories)); |
(...skipping 25 matching lines...) Expand all Loading... | |
182 | 183 |
183 void TracingHandler::SetupTimer(double usage_reporting_interval) { | 184 void TracingHandler::SetupTimer(double usage_reporting_interval) { |
184 if (usage_reporting_interval == 0) return; | 185 if (usage_reporting_interval == 0) return; |
185 | 186 |
186 if (usage_reporting_interval < kMinimumReportingInterval) | 187 if (usage_reporting_interval < kMinimumReportingInterval) |
187 usage_reporting_interval = kMinimumReportingInterval; | 188 usage_reporting_interval = kMinimumReportingInterval; |
188 | 189 |
189 base::TimeDelta interval = base::TimeDelta::FromMilliseconds( | 190 base::TimeDelta interval = base::TimeDelta::FromMilliseconds( |
190 std::ceil(usage_reporting_interval)); | 191 std::ceil(usage_reporting_interval)); |
191 buffer_usage_poll_timer_.reset(new base::Timer( | 192 buffer_usage_poll_timer_.reset(new base::Timer( |
192 FROM_HERE, | 193 FROM_HERE, interval, |
193 interval, | 194 base::Bind(base::IgnoreResult(&TracingController::GetTraceBufferUsage), |
194 base::Bind( | 195 base::Unretained(TracingController::GetInstance()), |
195 base::IgnoreResult(&TracingController::GetTraceBufferPercentFull), | 196 base::Bind(&TracingHandler::OnBufferUsage, |
196 base::Unretained(TracingController::GetInstance()), | 197 weak_factory_.GetWeakPtr())), |
197 base::Bind(&TracingHandler::OnBufferUsage, | |
198 weak_factory_.GetWeakPtr())), | |
199 true)); | 198 true)); |
200 buffer_usage_poll_timer_->Reset(); | 199 buffer_usage_poll_timer_->Reset(); |
201 } | 200 } |
202 | 201 |
203 void TracingHandler::DisableRecording(bool abort) { | 202 void TracingHandler::DisableRecording(bool abort) { |
204 is_recording_ = false; | 203 is_recording_ = false; |
205 buffer_usage_poll_timer_.reset(); | 204 buffer_usage_poll_timer_.reset(); |
206 TracingController::GetInstance()->DisableRecording( | 205 TracingController::GetInstance()->DisableRecording( |
207 abort ? nullptr : new DevToolsTraceSinkProxy(weak_factory_.GetWeakPtr())); | 206 abort ? nullptr : new DevToolsTraceSinkProxy(weak_factory_.GetWeakPtr())); |
208 } | 207 } |
209 | 208 |
210 } // namespace tracing | 209 } // namespace tracing |
211 } // namespace devtools | 210 } // namespace devtools |
212 } // namespace content | 211 } // namespace content |
OLD | NEW |