| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 TraceUploader::UploadProgressCallback progress_callback = | 320 TraceUploader::UploadProgressCallback progress_callback = |
| 321 base::Bind(&TracingUI::OnTraceUploadProgress, | 321 base::Bind(&TracingUI::OnTraceUploadProgress, |
| 322 weak_factory_.GetWeakPtr()); | 322 weak_factory_.GetWeakPtr()); |
| 323 TraceUploader::UploadDoneCallback done_callback = | 323 TraceUploader::UploadDoneCallback done_callback = |
| 324 base::Bind(&TracingUI::OnTraceUploadComplete, | 324 base::Bind(&TracingUI::OnTraceUploadComplete, |
| 325 weak_factory_.GetWeakPtr()); | 325 weak_factory_.GetWeakPtr()); |
| 326 | 326 |
| 327 trace_uploader_ = delegate_->GetTraceUploader( | 327 trace_uploader_ = delegate_->GetTraceUploader( |
| 328 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext()); | 328 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext()); |
| 329 DCHECK(trace_uploader_); | 329 DCHECK(trace_uploader_); |
| 330 trace_uploader_->DoUpload(file_contents, progress_callback, done_callback); | 330 trace_uploader_->DoUpload(file_contents, nullptr, progress_callback, |
| 331 done_callback); |
| 331 // TODO(mmandlis): Add support for stopping the upload in progress. | 332 // TODO(mmandlis): Add support for stopping the upload in progress. |
| 332 } | 333 } |
| 333 | 334 |
| 334 void TracingUI::OnTraceUploadProgress(int64 current, int64 total) { | 335 void TracingUI::OnTraceUploadProgress(int64 current, int64 total) { |
| 335 DCHECK(current <= total); | 336 DCHECK(current <= total); |
| 336 int percent = (current / total) * 100; | 337 int percent = (current / total) * 100; |
| 337 web_ui()->CallJavascriptFunction( | 338 web_ui()->CallJavascriptFunction( |
| 338 "onUploadProgress", | 339 "onUploadProgress", |
| 339 base::FundamentalValue(percent), | 340 base::FundamentalValue(percent), |
| 340 base::StringValue(base::StringPrintf("%" PRId64, current)), | 341 base::StringValue(base::StringPrintf("%" PRId64, current)), |
| 341 base::StringValue(base::StringPrintf("%" PRId64, total))); | 342 base::StringValue(base::StringPrintf("%" PRId64, total))); |
| 342 } | 343 } |
| 343 | 344 |
| 344 void TracingUI::OnTraceUploadComplete(bool success, | 345 void TracingUI::OnTraceUploadComplete(bool success, |
| 345 const std::string& feedback) { | 346 const std::string& feedback) { |
| 346 if (success) { | 347 if (success) { |
| 347 web_ui()->CallJavascriptFunction("onUploadComplete", | 348 web_ui()->CallJavascriptFunction("onUploadComplete", |
| 348 base::StringValue(feedback)); | 349 base::StringValue(feedback)); |
| 349 } else { | 350 } else { |
| 350 web_ui()->CallJavascriptFunction("onUploadError", | 351 web_ui()->CallJavascriptFunction("onUploadError", |
| 351 base::StringValue(feedback)); | 352 base::StringValue(feedback)); |
| 352 } | 353 } |
| 353 trace_uploader_.reset(); | 354 trace_uploader_.reset(); |
| 354 } | 355 } |
| 355 | 356 |
| 356 } // namespace content | 357 } // namespace content |
| OLD | NEW |