Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: content/browser/tracing/tracing_ui.cc

Issue 1878153002: Revert of Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/trace_event/trace_event.h" 25 #include "base/trace_event/trace_event.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 #include "content/browser/tracing/grit/tracing_resources.h" 27 #include "content/browser/tracing/grit/tracing_resources.h"
28 #include "content/browser/tracing/tracing_controller_impl.h" 28 #include "content/browser/tracing/tracing_controller_impl.h"
29 #include "content/public/browser/browser_context.h" 29 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/content_browser_client.h" 31 #include "content/public/browser/content_browser_client.h"
32 #include "content/public/browser/storage_partition.h"
33 #include "content/public/browser/trace_uploader.h" 32 #include "content/public/browser/trace_uploader.h"
34 #include "content/public/browser/tracing_controller.h" 33 #include "content/public/browser/tracing_controller.h"
35 #include "content/public/browser/tracing_delegate.h" 34 #include "content/public/browser/tracing_delegate.h"
36 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_ui.h" 36 #include "content/public/browser/web_ui.h"
38 #include "content/public/browser/web_ui_data_source.h" 37 #include "content/public/browser/web_ui_data_source.h"
39 #include "content/public/common/content_client.h" 38 #include "content/public/common/content_client.h"
40 #include "content/public/common/url_constants.h" 39 #include "content/public/common/url_constants.h"
41 40
42 namespace content { 41 namespace content {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 287 }
289 288
290 TraceUploader::UploadProgressCallback progress_callback = 289 TraceUploader::UploadProgressCallback progress_callback =
291 base::Bind(&TracingUI::OnTraceUploadProgress, 290 base::Bind(&TracingUI::OnTraceUploadProgress,
292 weak_factory_.GetWeakPtr()); 291 weak_factory_.GetWeakPtr());
293 TraceUploader::UploadDoneCallback done_callback = 292 TraceUploader::UploadDoneCallback done_callback =
294 base::Bind(&TracingUI::OnTraceUploadComplete, 293 base::Bind(&TracingUI::OnTraceUploadComplete,
295 weak_factory_.GetWeakPtr()); 294 weak_factory_.GetWeakPtr());
296 295
297 trace_uploader_ = delegate_->GetTraceUploader( 296 trace_uploader_ = delegate_->GetTraceUploader(
298 BrowserContext::GetDefaultStoragePartition( 297 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext());
299 web_ui()->GetWebContents()->GetBrowserContext())->
300 GetURLRequestContext());
301 DCHECK(trace_uploader_); 298 DCHECK(trace_uploader_);
302 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr, 299 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr,
303 progress_callback, done_callback); 300 progress_callback, done_callback);
304 // TODO(mmandlis): Add support for stopping the upload in progress. 301 // TODO(mmandlis): Add support for stopping the upload in progress.
305 } 302 }
306 303
307 void TracingUI::OnTraceUploadProgress(int64_t current, int64_t total) { 304 void TracingUI::OnTraceUploadProgress(int64_t current, int64_t total) {
308 DCHECK(current <= total); 305 DCHECK(current <= total);
309 int percent = (current / total) * 100; 306 int percent = (current / total) * 100;
310 web_ui()->CallJavascriptFunction( 307 web_ui()->CallJavascriptFunction(
311 "onUploadProgress", 308 "onUploadProgress",
312 base::FundamentalValue(percent), 309 base::FundamentalValue(percent),
313 base::StringValue(base::StringPrintf("%" PRId64, current)), 310 base::StringValue(base::StringPrintf("%" PRId64, current)),
314 base::StringValue(base::StringPrintf("%" PRId64, total))); 311 base::StringValue(base::StringPrintf("%" PRId64, total)));
315 } 312 }
316 313
317 void TracingUI::OnTraceUploadComplete(bool success, 314 void TracingUI::OnTraceUploadComplete(bool success,
318 const std::string& feedback) { 315 const std::string& feedback) {
319 if (success) { 316 if (success) {
320 web_ui()->CallJavascriptFunction("onUploadComplete", 317 web_ui()->CallJavascriptFunction("onUploadComplete",
321 base::StringValue(feedback)); 318 base::StringValue(feedback));
322 } else { 319 } else {
323 web_ui()->CallJavascriptFunction("onUploadError", 320 web_ui()->CallJavascriptFunction("onUploadError",
324 base::StringValue(feedback)); 321 base::StringValue(feedback));
325 } 322 }
326 trace_uploader_.reset(); 323 trace_uploader_.reset();
327 } 324 }
328 325
329 } // namespace content 326 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698