| 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> |
| 8 |
| 7 #include <set> | 9 #include <set> |
| 8 #include <string> | 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/base64.h" | 13 #include "base/base64.h" |
| 12 #include "base/bind.h" | 14 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 15 #include "base/format_macros.h" | 17 #include "base/format_macros.h" |
| 16 #include "base/json/json_reader.h" | 18 #include "base/json/json_reader.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 weak_factory_.GetWeakPtr()); | 371 weak_factory_.GetWeakPtr()); |
| 370 | 372 |
| 371 trace_uploader_ = delegate_->GetTraceUploader( | 373 trace_uploader_ = delegate_->GetTraceUploader( |
| 372 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext()); | 374 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext()); |
| 373 DCHECK(trace_uploader_); | 375 DCHECK(trace_uploader_); |
| 374 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr, | 376 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr, |
| 375 progress_callback, done_callback); | 377 progress_callback, done_callback); |
| 376 // TODO(mmandlis): Add support for stopping the upload in progress. | 378 // TODO(mmandlis): Add support for stopping the upload in progress. |
| 377 } | 379 } |
| 378 | 380 |
| 379 void TracingUI::OnTraceUploadProgress(int64 current, int64 total) { | 381 void TracingUI::OnTraceUploadProgress(int64_t current, int64_t total) { |
| 380 DCHECK(current <= total); | 382 DCHECK(current <= total); |
| 381 int percent = (current / total) * 100; | 383 int percent = (current / total) * 100; |
| 382 web_ui()->CallJavascriptFunction( | 384 web_ui()->CallJavascriptFunction( |
| 383 "onUploadProgress", | 385 "onUploadProgress", |
| 384 base::FundamentalValue(percent), | 386 base::FundamentalValue(percent), |
| 385 base::StringValue(base::StringPrintf("%" PRId64, current)), | 387 base::StringValue(base::StringPrintf("%" PRId64, current)), |
| 386 base::StringValue(base::StringPrintf("%" PRId64, total))); | 388 base::StringValue(base::StringPrintf("%" PRId64, total))); |
| 387 } | 389 } |
| 388 | 390 |
| 389 void TracingUI::OnTraceUploadComplete(bool success, | 391 void TracingUI::OnTraceUploadComplete(bool success, |
| 390 const std::string& feedback) { | 392 const std::string& feedback) { |
| 391 if (success) { | 393 if (success) { |
| 392 web_ui()->CallJavascriptFunction("onUploadComplete", | 394 web_ui()->CallJavascriptFunction("onUploadComplete", |
| 393 base::StringValue(feedback)); | 395 base::StringValue(feedback)); |
| 394 } else { | 396 } else { |
| 395 web_ui()->CallJavascriptFunction("onUploadError", | 397 web_ui()->CallJavascriptFunction("onUploadError", |
| 396 base::StringValue(feedback)); | 398 base::StringValue(feedback)); |
| 397 } | 399 } |
| 398 trace_uploader_.reset(); | 400 trace_uploader_.reset(); |
| 399 } | 401 } |
| 400 | 402 |
| 401 } // namespace content | 403 } // namespace content |
| OLD | NEW |