Commit 3e15a0d1 authored by simonhatch's avatar simonhatch Committed by Commit bot

Slow Reports - Allow URL to be set on TraceCrashServiceUploader.

We can use this for both Deep Reports (since those get sent to a different server), and for Slow Reports will need this to route to another endpoint.

BUG=498419

Review URL: https://codereview.chromium.org/1164313006

Cr-Commit-Position: refs/heads/master@{#333736}
parent 0fced85f
......@@ -43,12 +43,27 @@ TraceCrashServiceUploader::TraceCrashServiceUploader(
net::URLRequestContextGetter* request_context)
: request_context_(request_context) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
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);
}
SetUploadURL(upload_url);
}
TraceCrashServiceUploader::~TraceCrashServiceUploader() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
}
void TraceCrashServiceUploader::SetUploadURL(const std::string& url) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
upload_url_ = url;
if (!GURL(upload_url_).is_valid())
upload_url_.clear();
}
void TraceCrashServiceUploader::OnURLFetchComplete(
const net::URLFetcher* source) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
......@@ -89,12 +104,13 @@ void TraceCrashServiceUploader::DoUpload(
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(&TraceCrashServiceUploader::DoUploadOnFileThread,
base::Unretained(this), file_contents, progress_callback,
done_callback));
base::Unretained(this), file_contents, upload_url_,
progress_callback, done_callback));
}
void TraceCrashServiceUploader::DoUploadOnFileThread(
const std::string& file_contents,
const std::string& upload_url,
const UploadProgressCallback& progress_callback,
const UploadDoneCallback& done_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
......@@ -103,15 +119,6 @@ void TraceCrashServiceUploader::DoUploadOnFileThread(
progress_callback_ = progress_callback;
done_callback_ = done_callback;
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()) {
OnUploadError("Upload URL empty or invalid");
return;
......
......@@ -38,6 +38,8 @@ class TraceCrashServiceUploader : public content::TraceUploader,
net::URLRequestContextGetter* request_context);
~TraceCrashServiceUploader() override;
void SetUploadURL(const std::string& url);
// net::URLFetcherDelegate implementation.
void OnURLFetchComplete(const net::URLFetcher* source) override;
void OnURLFetchUploadProgress(const net::URLFetcher* source,
......@@ -51,6 +53,7 @@ class TraceCrashServiceUploader : public content::TraceUploader,
private:
void DoUploadOnFileThread(const std::string& file_contents,
const std::string& upload_url,
const UploadProgressCallback& progress_callback,
const UploadDoneCallback& done_callback);
// Sets up a multipart body to be uploaded. The body is produced according
......@@ -78,6 +81,8 @@ class TraceCrashServiceUploader : public content::TraceUploader,
net::URLRequestContextGetter* request_context_;
std::string upload_url_;
DISALLOW_COPY_AND_ASSIGN(TraceCrashServiceUploader);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment