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

Unified Diff: content/browser/tracing/tracing_ui.cc

Issue 117323008: Return error on JSON request failures (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698