Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 callback.Run(data_base64); | 168 callback.Run(data_base64); |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool OnBeginJSONRequest(const std::string& path, | 171 bool OnBeginJSONRequest(const std::string& path, |
| 172 const WebUIDataSource::GotDataCallback& callback) { | 172 const WebUIDataSource::GotDataCallback& callback) { |
| 173 if (path == "json/categories") { | 173 if (path == "json/categories") { |
| 174 return TracingController::GetInstance()->GetCategories( | 174 return TracingController::GetInstance()->GetCategories( |
| 175 base::Bind(OnGotCategories, callback)); | 175 base::Bind(OnGotCategories, callback)); |
| 176 } | 176 } |
| 177 | 177 |
| 178 const char kBeginRecordingPath[] = "json/begin_recording?"; | 178 const char kBeginRecordingPath[] = "json/begin_recording?"; |
|
sullivan
2017/06/09 19:08:42
What is this and how is it used? I see it called f
sullivan
2017/06/09 21:22:29
I ended up adding "json/begin_recording" to the gz
| |
| 179 if (base::StartsWith(path, kBeginRecordingPath, | 179 if (base::StartsWith(path, kBeginRecordingPath, |
| 180 base::CompareCase::SENSITIVE)) { | 180 base::CompareCase::SENSITIVE)) { |
| 181 std::string data = path.substr(strlen(kBeginRecordingPath)); | 181 std::string data = path.substr(strlen(kBeginRecordingPath)); |
| 182 return BeginRecording(data, callback); | 182 return BeginRecording(data, callback); |
| 183 } | 183 } |
| 184 if (path == "json/get_buffer_percent_full") { | 184 if (path == "json/get_buffer_percent_full") { |
| 185 return TracingController::GetInstance()->GetTraceBufferUsage( | 185 return TracingController::GetInstance()->GetTraceBufferUsage( |
| 186 base::Bind(OnTraceBufferUsageResult, callback)); | 186 base::Bind(OnTraceBufferUsageResult, callback)); |
| 187 } | 187 } |
| 188 if (path == "json/get_buffer_status") { | 188 if (path == "json/get_buffer_status") { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 base::Bind(&TracingUI::DoUpload, base::Unretained(this))); | 233 base::Bind(&TracingUI::DoUpload, base::Unretained(this))); |
| 234 web_ui->RegisterMessageCallback( | 234 web_ui->RegisterMessageCallback( |
| 235 "doUploadBase64", | 235 "doUploadBase64", |
| 236 base::Bind(&TracingUI::DoUploadBase64Encoded, base::Unretained(this))); | 236 base::Bind(&TracingUI::DoUploadBase64Encoded, base::Unretained(this))); |
| 237 | 237 |
| 238 // Set up the chrome://tracing/ source. | 238 // Set up the chrome://tracing/ source. |
| 239 BrowserContext* browser_context = | 239 BrowserContext* browser_context = |
| 240 web_ui->GetWebContents()->GetBrowserContext(); | 240 web_ui->GetWebContents()->GetBrowserContext(); |
| 241 | 241 |
| 242 WebUIDataSource* source = WebUIDataSource::Create(kChromeUITracingHost); | 242 WebUIDataSource* source = WebUIDataSource::Create(kChromeUITracingHost); |
| 243 std::unordered_set<std::string> exclusions; | |
| 244 exclusions.insert("json/categories"); | |
| 245 exclusions.insert("json/get_buffer_percent_full"); | |
| 246 exclusions.insert("json/get_buffer_status"); | |
| 247 exclusions.insert("json/end_recording_compressed"); | |
| 248 source->UseGzip(exclusions); | |
| 243 source->SetJsonPath("strings.js"); | 249 source->SetJsonPath("strings.js"); |
| 244 source->SetDefaultResource(IDR_TRACING_HTML); | 250 source->SetDefaultResource(IDR_TRACING_HTML); |
| 245 source->AddResourcePath("tracing.js", IDR_TRACING_JS); | 251 source->AddResourcePath("tracing.js", IDR_TRACING_JS); |
| 246 source->SetRequestFilter(base::Bind(OnTracingRequest)); | 252 source->SetRequestFilter(base::Bind(OnTracingRequest)); |
| 247 WebUIDataSource::Add(browser_context, source); | 253 WebUIDataSource::Add(browser_context, source); |
| 248 TracingControllerImpl::GetInstance()->RegisterTracingUI(this); | 254 TracingControllerImpl::GetInstance()->RegisterTracingUI(this); |
| 249 } | 255 } |
| 250 | 256 |
| 251 TracingUI::~TracingUI() { | 257 TracingUI::~TracingUI() { |
| 252 TracingControllerImpl::GetInstance()->UnregisterTracingUI(this); | 258 TracingControllerImpl::GetInstance()->UnregisterTracingUI(this); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 web_ui()->CallJavascriptFunctionUnsafe("onUploadComplete", | 331 web_ui()->CallJavascriptFunctionUnsafe("onUploadComplete", |
| 326 base::Value(feedback)); | 332 base::Value(feedback)); |
| 327 } else { | 333 } else { |
| 328 web_ui()->CallJavascriptFunctionUnsafe("onUploadError", | 334 web_ui()->CallJavascriptFunctionUnsafe("onUploadError", |
| 329 base::Value(feedback)); | 335 base::Value(feedback)); |
| 330 } | 336 } |
| 331 trace_uploader_.reset(); | 337 trace_uploader_.reset(); |
| 332 } | 338 } |
| 333 | 339 |
| 334 } // namespace content | 340 } // namespace content |
| OLD | NEW |