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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 DCHECK(trace_uploader_); | 298 DCHECK(trace_uploader_); |
299 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr, | 299 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr, |
300 progress_callback, done_callback); | 300 progress_callback, done_callback); |
301 // TODO(mmandlis): Add support for stopping the upload in progress. | 301 // TODO(mmandlis): Add support for stopping the upload in progress. |
302 } | 302 } |
303 | 303 |
304 void TracingUI::OnTraceUploadProgress(int64_t current, int64_t total) { | 304 void TracingUI::OnTraceUploadProgress(int64_t current, int64_t total) { |
305 DCHECK(current <= total); | 305 DCHECK(current <= total); |
306 int percent = (current / total) * 100; | 306 int percent = (current / total) * 100; |
307 web_ui()->CallJavascriptFunctionUnsafe( | 307 web_ui()->CallJavascriptFunctionUnsafe( |
308 "onUploadProgress", base::FundamentalValue(percent), | 308 "onUploadProgress", base::Value(percent), |
309 base::StringValue(base::StringPrintf("%" PRId64, current)), | 309 base::StringValue(base::StringPrintf("%" PRId64, current)), |
310 base::StringValue(base::StringPrintf("%" PRId64, total))); | 310 base::StringValue(base::StringPrintf("%" PRId64, total))); |
311 } | 311 } |
312 | 312 |
313 void TracingUI::OnTraceUploadComplete(bool success, | 313 void TracingUI::OnTraceUploadComplete(bool success, |
314 const std::string& feedback) { | 314 const std::string& feedback) { |
315 if (success) { | 315 if (success) { |
316 web_ui()->CallJavascriptFunctionUnsafe("onUploadComplete", | 316 web_ui()->CallJavascriptFunctionUnsafe("onUploadComplete", |
317 base::StringValue(feedback)); | 317 base::StringValue(feedback)); |
318 } else { | 318 } else { |
319 web_ui()->CallJavascriptFunctionUnsafe("onUploadError", | 319 web_ui()->CallJavascriptFunctionUnsafe("onUploadError", |
320 base::StringValue(feedback)); | 320 base::StringValue(feedback)); |
321 } | 321 } |
322 trace_uploader_.reset(); | 322 trace_uploader_.reset(); |
323 } | 323 } |
324 | 324 |
325 } // namespace content | 325 } // namespace content |
OLD | NEW |