Chromium Code Reviews| 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 87ae55232c3e10610f7f2f0d75740151c7ac5632..665c356916c24ec231d274c159d952b7cdfad7e9 100644 |
| --- a/content/browser/devtools/devtools_tracing_handler.cc |
| +++ b/content/browser/devtools/devtools_tracing_handler.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/callback.h" |
| #include "base/json/json_writer.h" |
| #include "base/location.h" |
| +#include "base/string_split.h" |
| #include "base/values.h" |
| #include "content/browser/devtools/devtools_http_handler_impl.h" |
| #include "content/public/browser/trace_controller.h" |
| @@ -25,6 +26,9 @@ const char kTracingDataCollected[] = "Tracing.dataCollected"; |
| const char kCategoriesParam[] = "categories"; |
| +const char kTraceOptionsParam[] = "trace-options"; |
| +const char kRecordUntilFull[] = "record-until-full"; |
| + |
| } // namespace |
| const char DevToolsTracingHandler::kDomain[] = "Tracing"; |
| @@ -56,13 +60,40 @@ void DevToolsTracingHandler::OnTraceDataCollected( |
| } |
| } |
| +// Note, if you add more options here you also need to update: |
| +// base/debug/trace_event_impl:TraceOptionsFromString |
| +int DevToolsTracingHandler::TraceOptionsFromString(const std::string& options) { |
| + std::vector<std::string> split; |
| + std::vector<std::string>::iterator iter; |
| + int ret = 0; |
| + |
| + base::SplitString(options, ',', &split); |
| + for (iter = split.begin(); iter != split.end(); ++iter) { |
| + if (*iter == kRecordUntilFull) { |
|
pfeldman
2013/02/21 16:33:05
Do you need to trim it before comparison?
dsinclair
2013/02/21 16:35:59
SplitString will trim leading and trailing whitesp
|
| + ret |= base::debug::TraceLog::RECORD_UNTIL_FULL; |
| + } |
| + } |
| + if (ret == 0) |
| + ret = base::debug::TraceLog::RECORD_UNTIL_FULL; |
| + |
| + return ret; |
|
pfeldman
2013/02/21 16:33:05
Not sure I follow, but it sounds like it always re
dsinclair
2013/02/21 16:35:59
It does at the moment. I have another patch in the
|
| +} |
| + |
| scoped_ptr<DevToolsProtocol::Response> |
| DevToolsTracingHandler::OnStart(DevToolsProtocol::Command* command) { |
| std::string categories; |
| base::DictionaryValue* params = command->params(); |
| if (params && params->HasKey(kCategoriesParam)) |
| params->GetString(kCategoriesParam, &categories); |
| - TraceController::GetInstance()->BeginTracing(this, categories); |
| + |
| + int options = base::debug::TraceLog::RECORD_UNTIL_FULL; |
| + if (params && params->HasKey(kTraceOptionsParam)) { |
| + std::string options_param; |
| + params->GetString(kTraceOptionsParam, &options_param); |
| + options = TraceOptionsFromString(options_param); |
| + } |
| + |
| + TraceController::GetInstance()->BeginTracing(this, categories, options); |
| is_running_ = true; |
| return command->SuccessResponse(NULL); |
| } |