Chromium Code Reviews| Index: content/browser/tracing/tracing_ui.cc |
| diff --git a/content/browser/tracing/tracing_ui.cc b/content/browser/tracing/tracing_ui.cc |
| index e59f5667cb423d6aa3e346af0cfb2e8befa9119c..377a0aad9bfb0324ddc2e3f0dfdd4b9ff8d458f4 100644 |
| --- a/content/browser/tracing/tracing_ui.cc |
| +++ b/content/browser/tracing/tracing_ui.cc |
| @@ -120,15 +120,14 @@ void BeginReadingRecordingResult( |
| base::Bind(ReadRecordingResult, callback, path)); |
| } |
| -bool OnBeginRequest(const std::string& path, |
| - const WebUIDataSource::GotDataCallback& callback) { |
| +bool OnBeginJSONRequest(const std::string& path, |
| + const WebUIDataSource::GotDataCallback& callback) { |
| if (path == "json/categories") { |
| - TracingController::GetInstance()->GetCategories( |
| + return TracingController::GetInstance()->GetCategories( |
| base::Bind(OnGotCategories, callback)); |
| - return true; |
| } |
| const char* beginRecordingPath = "json/begin_recording?"; |
| - if (path.find(beginRecordingPath) == 0) { |
| + if (StartsWithASCII(path, beginRecordingPath, true)) { |
| std::string data = path.substr(strlen(beginRecordingPath)); |
| return OnBeginRecording(data, callback); |
| } |
| @@ -140,8 +139,19 @@ bool OnBeginRequest(const std::string& path, |
| return TracingController::GetInstance()->DisableRecording( |
| base::FilePath(), base::Bind(BeginReadingRecordingResult, callback)); |
| } |
| - if (StartsWithASCII(path, "json/", true)) |
| - LOG(ERROR) << "Unhandled request to " << path; |
| + LOG(ERROR) << "Unhandled request to " << path; |
| + return false; |
| +} |
| + |
| +bool OnBeginRequest(const std::string& path, |
| + const WebUIDataSource::GotDataCallback& callback) { |
| + if (StartsWithASCII(path, "json/", true)) { |
| + if (!OnBeginJSONRequest(path, callback)) { |
| + std::string error("##ERROR##"); |
|
dsinclair
2014/01/06 15:20:33
Why not make this valid json? {"error": "invalid p
Xianzhu
2014/01/06 17:11:27
I didn't think of this, just randomly selected the
|
| + callback.Run(base::RefCountedString::TakeString(&error)); |
| + } |
| + return true; |
| + } |
| return false; |
| } |