| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/devtools_tracing_handler.h" | 5 #include "content/browser/devtools/devtools_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/callback.h" | 10 #include "base/callback.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 base::IgnoreResult(&TracingController::GetTraceBufferPercentFull), | 162 base::IgnoreResult(&TracingController::GetTraceBufferPercentFull), |
| 163 base::Unretained(TracingController::GetInstance()), | 163 base::Unretained(TracingController::GetInstance()), |
| 164 base::Bind(&DevToolsTracingHandler::OnBufferUsage, | 164 base::Bind(&DevToolsTracingHandler::OnBufferUsage, |
| 165 weak_factory_.GetWeakPtr())), | 165 weak_factory_.GetWeakPtr())), |
| 166 true)); | 166 true)); |
| 167 buffer_usage_poll_timer_->Reset(); | 167 buffer_usage_poll_timer_->Reset(); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 TracingController::GetInstance()->EnableRecording( | 171 TracingController::GetInstance()->EnableRecording( |
| 172 categories, options, TracingController::EnableRecordingDoneCallback()); | 172 categories, options, |
| 173 base::Bind(&DevToolsTracingHandler::OnTracingStarted, |
| 174 weak_factory_.GetWeakPtr(), |
| 175 command)); |
| 173 | 176 |
| 174 return command->SuccessResponse(NULL); | 177 return command->AsyncResponsePromise(); |
| 178 } |
| 179 |
| 180 void DevToolsTracingHandler::OnTracingStarted( |
| 181 scoped_refptr<DevToolsProtocol::Command> command) { |
| 182 SendAsyncResponse(command->SuccessResponse(NULL)); |
| 175 } | 183 } |
| 176 | 184 |
| 177 void DevToolsTracingHandler::OnBufferUsage(float usage) { | 185 void DevToolsTracingHandler::OnBufferUsage(float usage) { |
| 178 base::DictionaryValue* params = new base::DictionaryValue(); | 186 base::DictionaryValue* params = new base::DictionaryValue(); |
| 179 params->SetDouble(devtools::Tracing::bufferUsage::kParamValue, usage); | 187 params->SetDouble(devtools::Tracing::bufferUsage::kParamValue, usage); |
| 180 SendNotification(devtools::Tracing::bufferUsage::kName, params); | 188 SendNotification(devtools::Tracing::bufferUsage::kName, params); |
| 181 } | 189 } |
| 182 | 190 |
| 183 scoped_refptr<DevToolsProtocol::Response> | 191 scoped_refptr<DevToolsProtocol::Response> |
| 184 DevToolsTracingHandler::OnEnd( | 192 DevToolsTracingHandler::OnEnd( |
| 185 scoped_refptr<DevToolsProtocol::Command> command) { | 193 scoped_refptr<DevToolsProtocol::Command> command) { |
| 186 buffer_usage_poll_timer_.reset(); | 194 buffer_usage_poll_timer_.reset(); |
| 187 TracingController::GetInstance()->DisableRecording( | 195 TracingController::GetInstance()->DisableRecording( |
| 188 base::FilePath(), | 196 base::FilePath(), |
| 189 base::Bind(&DevToolsTracingHandler::BeginReadingRecordingResult, | 197 base::Bind(&DevToolsTracingHandler::BeginReadingRecordingResult, |
| 190 weak_factory_.GetWeakPtr())); | 198 weak_factory_.GetWeakPtr())); |
| 191 return command->SuccessResponse(NULL); | 199 return command->SuccessResponse(NULL); |
| 192 } | 200 } |
| 193 | 201 |
| 194 } // namespace content | 202 } // namespace content |
| OLD | NEW |