| Index: trunk/src/content/browser/tracing/tracing_ui.cc
|
| ===================================================================
|
| --- trunk/src/content/browser/tracing/tracing_ui.cc (revision 242678)
|
| +++ trunk/src/content/browser/tracing/tracing_ui.cc (working copy)
|
| @@ -41,10 +41,10 @@
|
| callback.Run(res);
|
| }
|
|
|
| -bool GetTracingOptions(const std::string& data64,
|
| - std::string* category_filter_string,
|
| - int* tracing_options)
|
| -{
|
| +void OnRecordingEnabledAck(const WebUIDataSource::GotDataCallback& callback);
|
| +
|
| +bool OnBeginRecording(const std::string& data64,
|
| + const WebUIDataSource::GotDataCallback& callback) {
|
| std::string data;
|
| if (!base::Base64Decode(data64, &data)) {
|
| LOG(ERROR) << "Options were not base64 encoded.";
|
| @@ -62,12 +62,13 @@
|
| return false;
|
| }
|
|
|
| + std::string category_filter_string;
|
| bool use_system_tracing;
|
| bool use_continuous_tracing;
|
| bool use_sampling;
|
|
|
| bool options_ok = true;
|
| - options_ok &= options->GetString("categoryFilter", category_filter_string);
|
| + options_ok &= options->GetString("categoryFilter", &category_filter_string);
|
| options_ok &= options->GetBoolean("useSystemTracing", &use_system_tracing);
|
| options_ok &= options->GetBoolean("useContinuousTracing",
|
| &use_continuous_tracing);
|
| @@ -77,25 +78,14 @@
|
| return false;
|
| }
|
|
|
| - *tracing_options = 0;
|
| + int tracing_options = 0;
|
| if (use_system_tracing)
|
| - *tracing_options |= TracingController::ENABLE_SYSTRACE;
|
| + tracing_options |= TracingController::ENABLE_SYSTRACE;
|
| if (use_sampling)
|
| - *tracing_options |= TracingController::ENABLE_SAMPLING;
|
| + tracing_options |= TracingController::ENABLE_SAMPLING;
|
| if (use_continuous_tracing)
|
| - *tracing_options |= TracingController::RECORD_CONTINUOUSLY;
|
| - return true;
|
| -}
|
| + tracing_options |= TracingController::RECORD_CONTINUOUSLY;
|
|
|
| -void OnRecordingEnabledAck(const WebUIDataSource::GotDataCallback& callback);
|
| -
|
| -bool OnBeginRecording(const std::string& data64,
|
| - const WebUIDataSource::GotDataCallback& callback) {
|
| - std::string category_filter_string;
|
| - int tracing_options = 0;
|
| - if (!GetTracingOptions(data64, &category_filter_string, &tracing_options))
|
| - return false;
|
| -
|
| return TracingController::GetInstance()->EnableRecording(
|
| category_filter_string,
|
| static_cast<TracingController::Options>(tracing_options),
|
| @@ -130,56 +120,13 @@
|
| base::Bind(ReadRecordingResult, callback, path));
|
| }
|
|
|
| -void OnMonitoringEnabledAck(const WebUIDataSource::GotDataCallback& callback);
|
| -
|
| -bool OnEnableMonitoring(const std::string& data64,
|
| - const WebUIDataSource::GotDataCallback& callback) {
|
| - std::string category_filter_string;
|
| - int tracing_options = 0;
|
| - if (!GetTracingOptions(data64, &category_filter_string, &tracing_options))
|
| - return false;
|
| -
|
| - return TracingController::GetInstance()->EnableMonitoring(
|
| - category_filter_string,
|
| - static_cast<TracingController::Options>(tracing_options),
|
| - base::Bind(OnMonitoringEnabledAck, callback));
|
| -}
|
| -
|
| -void OnMonitoringEnabledAck(const WebUIDataSource::GotDataCallback& callback) {
|
| - base::RefCountedString* res = new base::RefCountedString();
|
| - callback.Run(res);
|
| -}
|
| -
|
| -void OnMonitoringDisabled(const WebUIDataSource::GotDataCallback& callback) {
|
| - base::RefCountedString* res = new base::RefCountedString();
|
| - callback.Run(res);
|
| -}
|
| -
|
| -void ReadMonitoringSnapshot(const WebUIDataSource::GotDataCallback& callback,
|
| - const base::FilePath& path) {
|
| - std::string tmp;
|
| - if (!base::ReadFileToString(path, &tmp))
|
| - LOG(ERROR) << "Failed to read file " << path.value();
|
| - base::DeleteFile(path, false);
|
| - callback.Run(base::RefCountedString::TakeString(&tmp));
|
| -}
|
| -
|
| -void OnMonitoringSnapshotCaptured(
|
| - const WebUIDataSource::GotDataCallback& callback,
|
| - const base::FilePath& path) {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(ReadMonitoringSnapshot, callback, path));
|
| -}
|
| -
|
| -bool OnTracingRequest(const std::string& path,
|
| +bool OnBeginRequest(const std::string& path,
|
| const WebUIDataSource::GotDataCallback& callback) {
|
| if (path == "json/categories") {
|
| TracingController::GetInstance()->GetCategories(
|
| base::Bind(OnGotCategories, callback));
|
| return true;
|
| }
|
| -
|
| const char* beginRecordingPath = "json/begin_recording?";
|
| if (path.find(beginRecordingPath) == 0) {
|
| std::string data = path.substr(strlen(beginRecordingPath));
|
| @@ -193,22 +140,6 @@
|
| return TracingController::GetInstance()->DisableRecording(
|
| base::FilePath(), base::Bind(BeginReadingRecordingResult, callback));
|
| }
|
| -
|
| - const char* enableMonitoringPath = "json/begin_monitoring?";
|
| - if (path.find(enableMonitoringPath) == 0) {
|
| - std::string data = path.substr(strlen(enableMonitoringPath));
|
| - return OnEnableMonitoring(data, callback);
|
| - }
|
| - if (path == "json/end_monitoring") {
|
| - return TracingController::GetInstance()->DisableMonitoring(
|
| - base::Bind(OnMonitoringDisabled, callback));
|
| - }
|
| - if (path == "json/capture_monitoring") {
|
| - TracingController::GetInstance()->CaptureMonitoringSnapshot(
|
| - base::FilePath(), base::Bind(OnMonitoringSnapshotCaptured, callback));
|
| - return true;
|
| - }
|
| -
|
| if (StartsWithASCII(path, "json/", true))
|
| LOG(ERROR) << "Unhandled request to " << path;
|
| return false;
|
| @@ -232,7 +163,7 @@
|
| source->SetJsonPath("strings.js");
|
| source->SetDefaultResource(IDR_TRACING_HTML);
|
| source->AddResourcePath("tracing.js", IDR_TRACING_JS);
|
| - source->SetRequestFilter(base::Bind(OnTracingRequest));
|
| + source->SetRequestFilter(base::Bind(OnBeginRequest));
|
| WebUIDataSource::Add(browser_context, source);
|
| }
|
|
|
|
|