Fix terminating a transfer while resolving proxies.

Calling TerminateTransfer() on an HttpFetcher should cancel the current
transfer regardless of where it is sitting. If TerminateTransfer() was
called right after BeginTransfer(), the fetcher would be waiting for
the proxy resolution callback which will kick the download. This patch
fixes this case by releasing the proxy callback when terminating a
transfer.

Bug: 34178297
Test: Added a unittest to trigger this case.
Change-Id: I282d04995bd0d03f9a469c80c1e263f9902e4be2
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index 30ee1f3..ee31c8d 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -58,6 +58,7 @@
 LibcurlHttpFetcher::~LibcurlHttpFetcher() {
   LOG_IF(ERROR, transfer_in_progress_)
       << "Destroying the fetcher while a transfer is in progress.";
+  CancelProxyResolution();
   CleanUp();
 }
 
@@ -313,6 +314,7 @@
 }
 
 void LibcurlHttpFetcher::ForceTransferTermination() {
+  CancelProxyResolution();
   CleanUp();
   if (delegate_) {
     // Note that after the callback returns this object may be destroyed.