Move destruction of WebRtcLogUploader to post threads teardown.

Needs to outlive the file thread. Fixes rare crash.

Previous attempt (https://codereview.chromium.org/174493003) caused an inconsistent leak (https://code.google.com/p/chromium/issues/detail?id=348928).

This CL makes sure pending URLFetchers are deleted before threads teardown and removes the reference to system request context in WebRtcLoggingHandlerHost.

NOTRY=true

BUG=344892

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260167 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index e87427b..a67eb35 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -286,7 +286,9 @@
   platform_part()->StartTearDown();
 
 #if defined(ENABLE_WEBRTC)
-  webrtc_log_uploader_.reset();
+  // Cancel any uploads to release the system url request context references.
+  if (webrtc_log_uploader_)
+    webrtc_log_uploader_->StartShutdown();
 #endif
 
   if (local_state())
@@ -297,6 +299,11 @@
   // With the file_thread_ flushed, we can release any icon resources.
   icon_manager_.reset();
 
+#if defined(ENABLE_WEBRTC)
+  // Must outlive the file thread.
+  webrtc_log_uploader_.reset();
+#endif
+
   // Reset associated state right after actual thread is stopped,
   // as io_thread_.global_ cleanup happens in CleanUp on the IO
   // thread, i.e. as the thread exits its message loop.