| Index: content/browser/tracing/tracing_ui.cc
|
| diff --git a/content/browser/tracing/tracing_ui.cc b/content/browser/tracing/tracing_ui.cc
|
| index a219c3d360d2a8bb913cc682456a7bc9256945d0..3ae1347c5197496fe1fb136386ca3e71d2c7028a 100644
|
| --- a/content/browser/tracing/tracing_ui.cc
|
| +++ b/content/browser/tracing/tracing_ui.cc
|
| @@ -11,7 +11,6 @@
|
| #include "base/base64.h"
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| -#include "base/command_line.h"
|
| #include "base/format_macros.h"
|
| #include "base/json/json_reader.h"
|
| #include "base/json/json_writer.h"
|
| @@ -23,23 +22,22 @@
|
| #include "base/trace_event/trace_event.h"
|
| #include "base/values.h"
|
| #include "content/browser/tracing/grit/tracing_resources.h"
|
| -#include "content/browser/tracing/trace_uploader.h"
|
| #include "content/browser/tracing/tracing_controller_impl.h"
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/content_browser_client.h"
|
| +#include "content/public/browser/trace_uploader.h"
|
| #include "content/public/browser/tracing_controller.h"
|
| +#include "content/public/browser/tracing_delegate.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/browser/web_ui.h"
|
| #include "content/public/browser/web_ui_data_source.h"
|
| #include "content/public/common/content_client.h"
|
| -#include "content/public/common/content_switches.h"
|
| #include "content/public/common/url_constants.h"
|
|
|
| namespace content {
|
| namespace {
|
|
|
| -const char kUploadURL[] = "https://clients2.google.com/cr/staging_report";
|
| -
|
| void OnGotCategories(const WebUIDataSource::GotDataCallback& callback,
|
| const std::set<std::string>& categorySet) {
|
| scoped_ptr<base::ListValue> category_list(new base::ListValue());
|
| @@ -281,6 +279,7 @@ bool OnTracingRequest(const std::string& path,
|
|
|
| TracingUI::TracingUI(WebUI* web_ui)
|
| : WebUIController(web_ui),
|
| + delegate_(GetContentClient()->browser()->GetTracingDelegate()),
|
| weak_factory_(this) {
|
| web_ui->RegisterMessageCallback(
|
| "doUpload",
|
| @@ -309,27 +308,16 @@ void TracingUI::OnMonitoringStateChanged(bool is_monitoring) {
|
| }
|
|
|
| void TracingUI::DoUpload(const base::ListValue* args) {
|
| - const base::CommandLine& command_line =
|
| - *base::CommandLine::ForCurrentProcess();
|
| - std::string upload_url = kUploadURL;
|
| - if (command_line.HasSwitch(switches::kTraceUploadURL)) {
|
| - upload_url =
|
| - command_line.GetSwitchValueASCII(switches::kTraceUploadURL);
|
| - }
|
| - if (!GURL(upload_url).is_valid()) {
|
| - upload_url.clear();
|
| - }
|
| -
|
| - if (upload_url.empty()) {
|
| + std::string file_contents;
|
| + if (!args || args->empty() || !args->GetString(0, &file_contents)) {
|
| web_ui()->CallJavascriptFunction("onUploadError",
|
| - base::StringValue("Upload URL empty or invalid"));
|
| + base::StringValue("Missing data"));
|
| return;
|
| }
|
|
|
| - std::string file_contents;
|
| - if (!args || args->empty() || !args->GetString(0, &file_contents)) {
|
| + if (!delegate_) {
|
| web_ui()->CallJavascriptFunction("onUploadError",
|
| - base::StringValue("Missing data"));
|
| + base::StringValue("Not implemented"));
|
| return;
|
| }
|
|
|
| @@ -340,44 +328,10 @@ void TracingUI::DoUpload(const base::ListValue* args) {
|
| base::Bind(&TracingUI::OnTraceUploadComplete,
|
| weak_factory_.GetWeakPtr());
|
|
|
| -#if defined(OS_WIN)
|
| - const char product[] = "Chrome";
|
| -#elif defined(OS_MACOSX)
|
| - const char product[] = "Chrome_Mac";
|
| -#elif defined(OS_LINUX)
|
| - const char product[] = "Chrome_Linux";
|
| -#elif defined(OS_ANDROID)
|
| - const char product[] = "Chrome_Android";
|
| -#elif defined(OS_CHROMEOS)
|
| - const char product[] = "Chrome_ChromeOS";
|
| -#else
|
| -#error Platform not supported.
|
| -#endif
|
| -
|
| - // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
|
| - // the part before the "/".
|
| - std::vector<std::string> product_components;
|
| - base::SplitString(content::GetContentClient()->GetProduct(), '/',
|
| - &product_components);
|
| - DCHECK_EQ(2U, product_components.size());
|
| - std::string version;
|
| - if (product_components.size() == 2U) {
|
| - version = product_components[1];
|
| - } else {
|
| - version = "unknown";
|
| - }
|
| + TraceUploader* uploader = delegate_->GetTraceUploader(
|
| + web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext());
|
|
|
| - BrowserContext* browser_context =
|
| - web_ui()->GetWebContents()->GetBrowserContext();
|
| - TraceUploader* uploader = new TraceUploader(
|
| - product, version, upload_url, browser_context->GetRequestContext());
|
| -
|
| - BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(
|
| - &TraceUploader::DoUpload,
|
| - base::Unretained(uploader),
|
| - file_contents,
|
| - progress_callback,
|
| - done_callback));
|
| + uploader->DoUpload(file_contents, progress_callback, done_callback);
|
| // TODO(mmandlis): Add support for stopping the upload in progress.
|
| }
|
|
|
|
|