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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 bool OnBeginJSONRequest(const std::string& path, | 199 bool OnBeginJSONRequest(const std::string& path, |
200 const WebUIDataSource::GotDataCallback& callback) { | 200 const WebUIDataSource::GotDataCallback& callback) { |
201 if (path == "json/categories") { | 201 if (path == "json/categories") { |
202 return TracingController::GetInstance()->GetCategories( | 202 return TracingController::GetInstance()->GetCategories( |
203 base::Bind(OnGotCategories, callback)); | 203 base::Bind(OnGotCategories, callback)); |
204 } | 204 } |
205 | 205 |
206 const char* beginRecordingPath = "json/begin_recording?"; | 206 const char* beginRecordingPath = "json/begin_recording?"; |
207 if (StartsWithASCII(path, beginRecordingPath, true)) { | 207 if (base::StartsWithASCII(path, beginRecordingPath, true)) { |
208 std::string data = path.substr(strlen(beginRecordingPath)); | 208 std::string data = path.substr(strlen(beginRecordingPath)); |
209 return BeginRecording(data, callback); | 209 return BeginRecording(data, callback); |
210 } | 210 } |
211 if (path == "json/get_buffer_percent_full") { | 211 if (path == "json/get_buffer_percent_full") { |
212 return TracingController::GetInstance()->GetTraceBufferUsage( | 212 return TracingController::GetInstance()->GetTraceBufferUsage( |
213 base::Bind(OnTraceBufferUsageResult, callback)); | 213 base::Bind(OnTraceBufferUsageResult, callback)); |
214 } | 214 } |
215 if (path == "json/get_buffer_status") { | 215 if (path == "json/get_buffer_status") { |
216 return TracingController::GetInstance()->GetTraceBufferUsage( | 216 return TracingController::GetInstance()->GetTraceBufferUsage( |
217 base::Bind(OnTraceBufferStatusResult, callback)); | 217 base::Bind(OnTraceBufferStatusResult, callback)); |
(...skipping 23 matching lines...) Expand all Loading... |
241 GetMonitoringStatus(callback); | 241 GetMonitoringStatus(callback); |
242 return true; | 242 return true; |
243 } | 243 } |
244 | 244 |
245 LOG(ERROR) << "Unhandled request to " << path; | 245 LOG(ERROR) << "Unhandled request to " << path; |
246 return false; | 246 return false; |
247 } | 247 } |
248 | 248 |
249 bool OnTracingRequest(const std::string& path, | 249 bool OnTracingRequest(const std::string& path, |
250 const WebUIDataSource::GotDataCallback& callback) { | 250 const WebUIDataSource::GotDataCallback& callback) { |
251 if (StartsWithASCII(path, "json/", true)) { | 251 if (base::StartsWithASCII(path, "json/", true)) { |
252 if (!OnBeginJSONRequest(path, callback)) { | 252 if (!OnBeginJSONRequest(path, callback)) { |
253 std::string error("##ERROR##"); | 253 std::string error("##ERROR##"); |
254 callback.Run(base::RefCountedString::TakeString(&error)); | 254 callback.Run(base::RefCountedString::TakeString(&error)); |
255 } | 255 } |
256 return true; | 256 return true; |
257 } | 257 } |
258 return false; | 258 return false; |
259 } | 259 } |
260 | 260 |
261 } // namespace | 261 } // namespace |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 web_ui()->CallJavascriptFunction("onUploadComplete", | 347 web_ui()->CallJavascriptFunction("onUploadComplete", |
348 base::StringValue(feedback)); | 348 base::StringValue(feedback)); |
349 } else { | 349 } else { |
350 web_ui()->CallJavascriptFunction("onUploadError", | 350 web_ui()->CallJavascriptFunction("onUploadError", |
351 base::StringValue(feedback)); | 351 base::StringValue(feedback)); |
352 } | 352 } |
353 trace_uploader_.reset(); | 353 trace_uploader_.reset(); |
354 } | 354 } |
355 | 355 |
356 } // namespace content | 356 } // namespace content |
OLD | NEW |