| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/trace_uploader.h" | 5 #include "content/browser/tracing/trace_uploader.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 9 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 10 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 14 #include "net/base/mime_util.h" | 16 #include "net/base/mime_util.h" |
| 15 #include "net/base/network_delegate.h" | 17 #include "net/base/network_delegate.h" |
| 16 #include "net/proxy/proxy_config.h" | 18 #include "net/proxy/proxy_config.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 46 } | 48 } |
| 47 | 49 |
| 48 TraceUploader::~TraceUploader() { | 50 TraceUploader::~TraceUploader() { |
| 49 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 51 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void TraceUploader::OnURLFetchComplete(const net::URLFetcher* source) { | 54 void TraceUploader::OnURLFetchComplete(const net::URLFetcher* source) { |
| 53 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 55 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 54 DCHECK_EQ(source, url_fetcher_.get()); | 56 DCHECK_EQ(source, url_fetcher_.get()); |
| 55 int response_code = source->GetResponseCode(); | 57 int response_code = source->GetResponseCode(); |
| 56 string report_id; | 58 std::string report_id; |
| 57 string error_message; | 59 std::string error_message; |
| 58 bool success = (response_code == kHttpResponseOk); | 60 bool success = (response_code == kHttpResponseOk); |
| 59 if (success) { | 61 if (success) { |
| 60 source->GetResponseAsString(&report_id); | 62 source->GetResponseAsString(&report_id); |
| 61 } else { | 63 } else { |
| 62 error_message = "Uploading failed, response code: " + | 64 error_message = "Uploading failed, response code: " + |
| 63 base::IntToString(response_code); | 65 base::IntToString(response_code); |
| 64 } | 66 } |
| 65 | 67 |
| 66 BrowserThread::PostTask( | 68 BrowserThread::PostTask( |
| 67 content::BrowserThread::UI, | 69 content::BrowserThread::UI, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 content_type.append(kMultipartBoundary); | 203 content_type.append(kMultipartBoundary); |
| 202 | 204 |
| 203 url_fetcher_.reset( | 205 url_fetcher_.reset( |
| 204 net::URLFetcher::Create(GURL(upload_url_), net::URLFetcher::POST, this)); | 206 net::URLFetcher::Create(GURL(upload_url_), net::URLFetcher::POST, this)); |
| 205 url_fetcher_->SetRequestContext(request_context_); | 207 url_fetcher_->SetRequestContext(request_context_); |
| 206 url_fetcher_->SetUploadData(content_type, post_data); | 208 url_fetcher_->SetUploadData(content_type, post_data); |
| 207 url_fetcher_->Start(); | 209 url_fetcher_->Start(); |
| 208 } | 210 } |
| 209 | 211 |
| 210 } // namespace content | 212 } // namespace content |
| OLD | NEW |