| 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/tracing/tracing_ui.h" | 5 #include "content/browser/tracing/tracing_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 category_filter, | 122 category_filter, |
| 123 tracing_options, | 123 tracing_options, |
| 124 base::Bind(&OnRecordingEnabledAck, callback)); | 124 base::Bind(&OnRecordingEnabledAck, callback)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void OnRecordingEnabledAck(const WebUIDataSource::GotDataCallback& callback) { | 127 void OnRecordingEnabledAck(const WebUIDataSource::GotDataCallback& callback) { |
| 128 base::RefCountedString* res = new base::RefCountedString(); | 128 base::RefCountedString* res = new base::RefCountedString(); |
| 129 callback.Run(res); | 129 callback.Run(res); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void OnTraceBufferPercentFullResult( | 132 void OnTraceBufferUsageResult(const WebUIDataSource::GotDataCallback& callback, |
| 133 const WebUIDataSource::GotDataCallback& callback, float result) { | 133 float percent_full, |
| 134 std::string str = base::DoubleToString(result); | 134 size_t approximate_event_count) { |
| 135 std::string str = base::DoubleToString(percent_full); |
| 135 callback.Run(base::RefCountedString::TakeString(&str)); | 136 callback.Run(base::RefCountedString::TakeString(&str)); |
| 136 } | 137 } |
| 137 | 138 |
| 138 void OnMonitoringEnabledAck(const WebUIDataSource::GotDataCallback& callback); | 139 void OnMonitoringEnabledAck(const WebUIDataSource::GotDataCallback& callback); |
| 139 | 140 |
| 140 bool EnableMonitoring(const std::string& data64, | 141 bool EnableMonitoring(const std::string& data64, |
| 141 const WebUIDataSource::GotDataCallback& callback) { | 142 const WebUIDataSource::GotDataCallback& callback) { |
| 142 base::debug::TraceOptions tracing_options; | 143 base::debug::TraceOptions tracing_options; |
| 143 base::debug::CategoryFilter category_filter(""); | 144 base::debug::CategoryFilter category_filter(""); |
| 144 if (!GetTracingOptions(data64, &category_filter, &tracing_options)) | 145 if (!GetTracingOptions(data64, &category_filter, &tracing_options)) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 base::Bind(OnGotCategories, callback)); | 200 base::Bind(OnGotCategories, callback)); |
| 200 } | 201 } |
| 201 | 202 |
| 202 const char* beginRecordingPath = "json/begin_recording?"; | 203 const char* beginRecordingPath = "json/begin_recording?"; |
| 203 if (StartsWithASCII(path, beginRecordingPath, true)) { | 204 if (StartsWithASCII(path, beginRecordingPath, true)) { |
| 204 std::string data = path.substr(strlen(beginRecordingPath)); | 205 std::string data = path.substr(strlen(beginRecordingPath)); |
| 205 return BeginRecording(data, callback); | 206 return BeginRecording(data, callback); |
| 206 } | 207 } |
| 207 if (path == "json/get_buffer_percent_full") { | 208 if (path == "json/get_buffer_percent_full") { |
| 208 return TracingController::GetInstance()->GetTraceBufferPercentFull( | 209 return TracingController::GetInstance()->GetTraceBufferPercentFull( |
| 209 base::Bind(OnTraceBufferPercentFullResult, callback)); | 210 base::Bind(OnTraceBufferUsageResult, callback)); |
| 210 } | 211 } |
| 211 if (path == "json/end_recording") { | 212 if (path == "json/end_recording") { |
| 212 return TracingController::GetInstance()->DisableRecording( | 213 return TracingController::GetInstance()->DisableRecording( |
| 213 TracingControllerImpl::CreateStringSink( | 214 TracingControllerImpl::CreateStringSink( |
| 214 base::Bind(TracingCallbackWrapper, callback))); | 215 base::Bind(TracingCallbackWrapper, callback))); |
| 215 } | 216 } |
| 216 | 217 |
| 217 const char* enableMonitoringPath = "json/begin_monitoring?"; | 218 const char* enableMonitoringPath = "json/begin_monitoring?"; |
| 218 if (path.find(enableMonitoringPath) == 0) { | 219 if (path.find(enableMonitoringPath) == 0) { |
| 219 std::string data = path.substr(strlen(enableMonitoringPath)); | 220 std::string data = path.substr(strlen(enableMonitoringPath)); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 if (success) { | 378 if (success) { |
| 378 web_ui()->CallJavascriptFunction("onUploadComplete", | 379 web_ui()->CallJavascriptFunction("onUploadComplete", |
| 379 base::StringValue(report_id)); | 380 base::StringValue(report_id)); |
| 380 } else { | 381 } else { |
| 381 web_ui()->CallJavascriptFunction("onUploadError", | 382 web_ui()->CallJavascriptFunction("onUploadError", |
| 382 base::StringValue(error_message)); | 383 base::StringValue(error_message)); |
| 383 } | 384 } |
| 384 } | 385 } |
| 385 | 386 |
| 386 } // namespace content | 387 } // namespace content |
| OLD | NEW |