Index: chrome/browser/media/webrtc_log_uploader.cc |
diff --git a/chrome/browser/media/webrtc_log_uploader.cc b/chrome/browser/media/webrtc_log_uploader.cc |
index 563cf9d745e35b0af12cd6f7387d321a3698b0d9..772000f27af0d0fe3a6adf841e72ac07f6d834dd 100644 |
--- a/chrome/browser/media/webrtc_log_uploader.cc |
+++ b/chrome/browser/media/webrtc_log_uploader.cc |
@@ -7,25 +7,18 @@ |
#include "base/file_util.h" |
#include "base/files/file_path.h" |
#include "base/logging.h" |
-#include "base/memory/shared_memory.h" |
#include "base/path_service.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_split.h" |
#include "base/strings/stringprintf.h" |
#include "base/time/time.h" |
+#include "chrome/browser/browser_process.h" |
#include "chrome/browser/media/webrtc_log_upload_list.h" |
-#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_version_info.h" |
#include "chrome/common/partial_circular_buffer.h" |
#include "content/public/browser/browser_thread.h" |
#include "net/base/mime_util.h" |
-#include "net/base/network_delegate.h" |
-#include "net/proxy/proxy_config.h" |
-#include "net/proxy/proxy_config_service.h" |
#include "net/url_request/url_fetcher.h" |
-#include "net/url_request/url_request_context.h" |
-#include "net/url_request/url_request_context_builder.h" |
-#include "net/url_request/url_request_context_getter.h" |
#include "third_party/zlib/zlib.h" |
namespace { |
@@ -51,13 +44,6 @@ WebRtcLogUploader::WebRtcLogUploader() |
WebRtcLogUploader::~WebRtcLogUploader() { |
Ami GONE FROM CHROMIUM
2014/03/25 17:53:17
DCHECK the vector is empty.
Henrik Grunell
2014/03/26 06:59:02
Done.
|
DCHECK(create_thread_checker_.CalledOnValidThread()); |
- // Delete all pending URLFetcher and release all references to |
- // WebRtcLoggingHandlerHost. |
- for (UploadDoneDataMap::iterator it = upload_done_data_.begin(); |
- it != upload_done_data_.end(); ++it) { |
- delete it->first; |
- } |
- upload_done_data_.clear(); |
} |
void WebRtcLogUploader::OnURLFetchComplete( |
@@ -77,7 +63,21 @@ void WebRtcLogUploader::OnURLFetchComplete( |
} |
NotifyUploadDone(response_code, report_id, upload_done_data_[source]); |
upload_done_data_.erase(source); |
- delete source; |
+ |
+ bool found_in_vector = false; |
+ for (URLFetcherVector::iterator it = url_fetchers_.begin(); |
+ it != url_fetchers_.end(); |
+ ++it) { |
Ami GONE FROM CHROMIUM
2014/03/25 17:53:17
It's a vector, so you could
for (size_t i = 0; i <
Henrik Grunell
2014/03/26 06:59:02
Done.
|
+ if (*it == source) { |
+ url_fetchers_.erase(it); |
+ found_in_vector = true; |
Ami GONE FROM CHROMIUM
2014/03/25 17:53:17
can drop found_in_vector+break in favor of a retur
Henrik Grunell
2014/03/26 06:59:02
Done.
|
+ break; |
+ } |
+ } |
+ if (!found_in_vector) { |
+ DLOG(WARNING) << "URLFetcher not found in vector."; |
Ami GONE FROM CHROMIUM
2014/03/25 17:53:17
Can this happen if there is a fetch in flight whil
Henrik Grunell
2014/03/26 06:59:02
Right. This should really not happen if cancelled.
|
+ delete source; |
+ } |
} |
void WebRtcLogUploader::OnURLFetchUploadProgress( |
@@ -99,7 +99,6 @@ void WebRtcLogUploader::LoggingStoppedDontUpload() { |
} |
void WebRtcLogUploader::LoggingStoppedDoUpload( |
- net::URLRequestContextGetter* request_context, |
scoped_ptr<unsigned char[]> log_buffer, |
uint32 length, |
const std::map<std::string, std::string>& meta_data, |
@@ -130,7 +129,6 @@ void WebRtcLogUploader::LoggingStoppedDoUpload( |
content::BrowserThread::UI, FROM_HERE, |
base::Bind(&WebRtcLogUploader::CreateAndStartURLFetcher, |
base::Unretained(this), |
- make_scoped_refptr(request_context), |
upload_done_data, |
Passed(&post_data))); |
@@ -138,6 +136,11 @@ void WebRtcLogUploader::LoggingStoppedDoUpload( |
base::Bind(&WebRtcLogUploader::DecreaseLogCount, base::Unretained(this))); |
} |
+void WebRtcLogUploader::CancelURLFetcherOperations() { |
+ DCHECK(create_thread_checker_.CalledOnValidThread()); |
+ url_fetchers_.clear(); |
+} |
+ |
void WebRtcLogUploader::SetupMultipart( |
std::string* post_data, uint8* log_buffer, uint32 log_buffer_length, |
const std::map<std::string, std::string>& meta_data) { |
@@ -249,7 +252,6 @@ void WebRtcLogUploader::ResizeForNextOutput(std::string* post_data, |
} |
void WebRtcLogUploader::CreateAndStartURLFetcher( |
- scoped_refptr<net::URLRequestContextGetter> request_context, |
const WebRtcLogUploadDoneData& upload_done_data, |
scoped_ptr<std::string> post_data) { |
DCHECK(create_thread_checker_.CalledOnValidThread()); |
@@ -257,12 +259,13 @@ void WebRtcLogUploader::CreateAndStartURLFetcher( |
content_type.append("; boundary="); |
content_type.append(kMultipartBoundary); |
- net::URLFetcher* url_fetcher = |
- net::URLFetcher::Create(GURL(kUploadURL), net::URLFetcher::POST, this); |
- url_fetcher->SetRequestContext(request_context); |
+ scoped_ptr<net::URLFetcher> url_fetcher( |
+ net::URLFetcher::Create(GURL(kUploadURL), net::URLFetcher::POST, this)); |
+ url_fetcher->SetRequestContext(g_browser_process->system_request_context()); |
url_fetcher->SetUploadData(content_type, *post_data); |
url_fetcher->Start(); |
- upload_done_data_[url_fetcher] = upload_done_data; |
+ upload_done_data_[url_fetcher.get()] = upload_done_data; |
+ url_fetchers_.push_back(url_fetcher.Pass()); |
} |
void WebRtcLogUploader::DecreaseLogCount() { |