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

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

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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"
32 #include "content/public/browser/trace_uploader.h" 33 #include "content/public/browser/trace_uploader.h"
33 #include "content/public/browser/tracing_controller.h" 34 #include "content/public/browser/tracing_controller.h"
34 #include "content/public/browser/tracing_delegate.h" 35 #include "content/public/browser/tracing_delegate.h"
35 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/web_ui.h" 37 #include "content/public/browser/web_ui.h"
37 #include "content/public/browser/web_ui_data_source.h" 38 #include "content/public/browser/web_ui_data_source.h"
38 #include "content/public/common/content_client.h" 39 #include "content/public/common/content_client.h"
39 #include "content/public/common/url_constants.h" 40 #include "content/public/common/url_constants.h"
40 41
41 namespace content { 42 namespace content {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 288 }
288 289
289 TraceUploader::UploadProgressCallback progress_callback = 290 TraceUploader::UploadProgressCallback progress_callback =
290 base::Bind(&TracingUI::OnTraceUploadProgress, 291 base::Bind(&TracingUI::OnTraceUploadProgress,
291 weak_factory_.GetWeakPtr()); 292 weak_factory_.GetWeakPtr());
292 TraceUploader::UploadDoneCallback done_callback = 293 TraceUploader::UploadDoneCallback done_callback =
293 base::Bind(&TracingUI::OnTraceUploadComplete, 294 base::Bind(&TracingUI::OnTraceUploadComplete,
294 weak_factory_.GetWeakPtr()); 295 weak_factory_.GetWeakPtr());
295 296
296 trace_uploader_ = delegate_->GetTraceUploader( 297 trace_uploader_ = delegate_->GetTraceUploader(
297 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext()); 298 BrowserContext::GetDefaultStoragePartition(
299 web_ui()->GetWebContents()->GetBrowserContext())->
300 GetURLRequestContext());
298 DCHECK(trace_uploader_); 301 DCHECK(trace_uploader_);
299 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr, 302 trace_uploader_->DoUpload(file_contents, upload_mode, nullptr,
300 progress_callback, done_callback); 303 progress_callback, done_callback);
301 // TODO(mmandlis): Add support for stopping the upload in progress. 304 // TODO(mmandlis): Add support for stopping the upload in progress.
302 } 305 }
303 306
304 void TracingUI::OnTraceUploadProgress(int64_t current, int64_t total) { 307 void TracingUI::OnTraceUploadProgress(int64_t current, int64_t total) {
305 DCHECK(current <= total); 308 DCHECK(current <= total);
306 int percent = (current / total) * 100; 309 int percent = (current / total) * 100;
307 web_ui()->CallJavascriptFunction( 310 web_ui()->CallJavascriptFunction(
308 "onUploadProgress", 311 "onUploadProgress",
309 base::FundamentalValue(percent), 312 base::FundamentalValue(percent),
310 base::StringValue(base::StringPrintf("%" PRId64, current)), 313 base::StringValue(base::StringPrintf("%" PRId64, current)),
311 base::StringValue(base::StringPrintf("%" PRId64, total))); 314 base::StringValue(base::StringPrintf("%" PRId64, total)));
312 } 315 }
313 316
314 void TracingUI::OnTraceUploadComplete(bool success, 317 void TracingUI::OnTraceUploadComplete(bool success,
315 const std::string& feedback) { 318 const std::string& feedback) {
316 if (success) { 319 if (success) {
317 web_ui()->CallJavascriptFunction("onUploadComplete", 320 web_ui()->CallJavascriptFunction("onUploadComplete",
318 base::StringValue(feedback)); 321 base::StringValue(feedback));
319 } else { 322 } else {
320 web_ui()->CallJavascriptFunction("onUploadError", 323 web_ui()->CallJavascriptFunction("onUploadError",
321 base::StringValue(feedback)); 324 base::StringValue(feedback));
322 } 325 }
323 trace_uploader_.reset(); 326 trace_uploader_.reset();
324 } 327 }
325 328
326 } // namespace content 329 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698