| Index: content/browser/devtools/devtools_tracing_handler.cc
|
| diff --git a/content/browser/devtools/devtools_tracing_handler.cc b/content/browser/devtools/devtools_tracing_handler.cc
|
| index 0657b8e48d2a9c83cc2d171630eddcefc77913b4..6d44bfeeb9c450d67d4502f7ecb862ab95925a66 100644
|
| --- a/content/browser/devtools/devtools_tracing_handler.cc
|
| +++ b/content/browser/devtools/devtools_tracing_handler.cc
|
| @@ -14,6 +14,8 @@
|
| #include "content/browser/devtools/devtools_protocol_constants.h"
|
| #include "content/public/browser/trace_controller.h"
|
| #include "content/public/browser/trace_subscriber.h"
|
| +#include "content/public/browser/tracing_controller.h"
|
| +#include "content/public/browser/tracing_synthetic_delay_configuration.h"
|
|
|
| namespace content {
|
|
|
| @@ -33,6 +35,10 @@ DevToolsTracingHandler::DevToolsTracingHandler()
|
| RegisterCommandHandler(devtools::Tracing::end::kName,
|
| base::Bind(&DevToolsTracingHandler::OnEnd,
|
| base::Unretained(this)));
|
| + RegisterCommandHandler(devtools::Tracing::configureSyntheticDelays::kName,
|
| + base::Bind(&DevToolsTracingHandler::
|
| + OnConfigureSyntheticDelays,
|
| + base::Unretained(this)));
|
| }
|
|
|
| DevToolsTracingHandler::~DevToolsTracingHandler() {
|
| @@ -110,4 +116,62 @@ DevToolsTracingHandler::OnEnd(
|
| return command->SuccessResponse(NULL);
|
| }
|
|
|
| +scoped_refptr<DevToolsProtocol::Response>
|
| +DevToolsTracingHandler::OnConfigureSyntheticDelays(
|
| + scoped_refptr<DevToolsProtocol::Command> command) {
|
| + std::string categories;
|
| + base::DictionaryValue* params = command->params();
|
| + const base::DictionaryValue* delay_settings;
|
| + if (params) {
|
| + params->GetDictionary(devtools::Tracing::configureSyntheticDelays::kDelays,
|
| + &delay_settings);
|
| + }
|
| +
|
| + if (!delay_settings) {
|
| + return command->InvalidParamResponse(
|
| + devtools::Tracing::configureSyntheticDelays::kDelays);
|
| + }
|
| +
|
| + std::vector<TracingSyntheticDelayConfiguration> delays;
|
| + base::DictionaryValue::Iterator it(*delay_settings);
|
| + while (!it.IsAtEnd()) {
|
| + TracingSyntheticDelayConfiguration delay;
|
| + const base::DictionaryValue* properties;
|
| + if (it.value().GetAsDictionary(&properties)) {
|
| + double target_duration;
|
| + if (properties->GetDouble("target_duration", &target_duration)) {
|
| + delay.target_duration = base::TimeDelta::FromMicroseconds(
|
| + target_duration * 1e6);
|
| + }
|
| + std::string mode;
|
| + if (properties->GetString("mode", &mode)) {
|
| + if (mode == "static") {
|
| + delay.mode = base::debug::TraceEventSyntheticDelay::STATIC;
|
| + } else if (mode == "oneshot") {
|
| + delay.mode = base::debug::TraceEventSyntheticDelay::ONE_SHOT;
|
| + } else if (mode == "alternating") {
|
| + delay.mode = base::debug::TraceEventSyntheticDelay::ALTERNATING;
|
| + } else {
|
| + return command->InvalidParamResponse(
|
| + devtools::Tracing::configureSyntheticDelays::kDelays);
|
| + }
|
| + }
|
| + }
|
| + delay.name = it.key();
|
| + delays.push_back(delay);
|
| + it.Advance();
|
| + }
|
| +
|
| + TracingController::GetInstance()->ConfigureSyntheticDelays(
|
| + delays,
|
| + base::Bind(&DevToolsTracingHandler::OnConfigureSyntheticDelaysComplete,
|
| + base::Unretained(this)));
|
| + return command->SuccessResponse(NULL);
|
| +}
|
| +
|
| +void DevToolsTracingHandler::OnConfigureSyntheticDelaysComplete() {
|
| + SendNotification(devtools::Tracing::configureSyntheticDelaysComplete::kName,
|
| + NULL);
|
| +}
|
| +
|
| } // namespace content
|
|
|