| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 void TracingMessageHandler::OnBeginRequestBufferPercentFull( | 219 void TracingMessageHandler::OnBeginRequestBufferPercentFull( |
| 220 const base::ListValue* list) { | 220 const base::ListValue* list) { |
| 221 TraceController::GetInstance()->GetTraceBufferPercentFullAsync(this); | 221 TraceController::GetInstance()->GetTraceBufferPercentFullAsync(this); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // A callback used for asynchronously reading a file to a string. Calls the | 224 // A callback used for asynchronously reading a file to a string. Calls the |
| 225 // TaskProxy callback when reading is complete. | 225 // TaskProxy callback when reading is complete. |
| 226 void ReadTraceFileCallback(TaskProxy* proxy, const base::FilePath& path) { | 226 void ReadTraceFileCallback(TaskProxy* proxy, const base::FilePath& path) { |
| 227 std::string file_contents; | 227 std::string file_contents; |
| 228 if (!file_util::ReadFileToString(path, &file_contents)) | 228 if (!base::ReadFileToString(path, &file_contents)) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 // We need to escape the file contents, because it will go into a javascript | 231 // We need to escape the file contents, because it will go into a javascript |
| 232 // quoted string in TracingMessageHandler::LoadTraceFileComplete. We need to | 232 // quoted string in TracingMessageHandler::LoadTraceFileComplete. We need to |
| 233 // escape control characters (to have well-formed javascript statements), as | 233 // escape control characters (to have well-formed javascript statements), as |
| 234 // well as \ and ' (the only special characters in a ''-quoted string). | 234 // well as \ and ' (the only special characters in a ''-quoted string). |
| 235 // Do the escaping on this thread, it may take a little while for big files | 235 // Do the escaping on this thread, it may take a little while for big files |
| 236 // and we don't want to block the UI during that time. Also do the UTF-16 | 236 // and we don't want to block the UI during that time. Also do the UTF-16 |
| 237 // conversion here. | 237 // conversion here. |
| 238 // Note: we're using UTF-16 because we'll need to cut the string into slices | 238 // Note: we're using UTF-16 because we'll need to cut the string into slices |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { | 552 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { |
| 553 web_ui->AddMessageHandler(new TracingMessageHandler()); | 553 web_ui->AddMessageHandler(new TracingMessageHandler()); |
| 554 | 554 |
| 555 // Set up the chrome://tracing/ source. | 555 // Set up the chrome://tracing/ source. |
| 556 BrowserContext* browser_context = | 556 BrowserContext* browser_context = |
| 557 web_ui->GetWebContents()->GetBrowserContext(); | 557 web_ui->GetWebContents()->GetBrowserContext(); |
| 558 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); | 558 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); |
| 559 } | 559 } |
| 560 | 560 |
| 561 } // namespace content | 561 } // namespace content |
| OLD | NEW |