Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(937)

Unified Diff: content/browser/devtools/devtools_tracing_handler.cc

Issue 12302036: Add a mode flag to the tracing framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9451fe8ed87ec91a3e9142a969b48ac457fcfa9e 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,42 @@ void DevToolsTracingHandler::OnTraceDataCollected(
}
}
+// Note, if you add more options here you also need to update:
+// base/debug/trace_event_impl:TraceOptionsFromString
+base::debug::TraceLog::Options 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) {
+ ret |= base::debug::TraceLog::RECORD_UNTIL_FULL;
+ }
+ }
+ if (ret == 0)
+ ret = base::debug::TraceLog::RECORD_UNTIL_FULL;
+
+ return static_cast<base::debug::TraceLog::Options>(ret);
+}
+
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);
+
+ base::debug::TraceLog::Options 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);
}
« no previous file with comments | « content/browser/devtools/devtools_tracing_handler.h ('k') | content/browser/tracing/trace_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698