Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: net/proxy/dhcp_proxy_script_fetcher_win.cc

Issue 2845643003: Allow ProxyService to share URLRequestContext with everything else. (Closed)
Patch Set: Fix fetcher shutdown with no active request, add test, add comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/dhcp_proxy_script_fetcher_win.h ('k') | net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/dhcp_proxy_script_fetcher_win.cc
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win.cc b/net/proxy/dhcp_proxy_script_fetcher_win.cc
index 1a28eea5dbf9fe5ccb8b57a7baaf162088def24e..fc72b86c86ce4d84105e27fddb674aa16c4e03ba 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win.cc
@@ -82,6 +82,9 @@ int DhcpProxyScriptFetcherWin::Fetch(base::string16* utf16_text,
return ERR_UNEXPECTED;
}
+ if (!url_request_context_)
+ return ERR_CONTEXT_SHUT_DOWN;
+
state_ = STATE_WAIT_ADAPTERS;
callback_ = callback;
destination_string_ = utf16_text;
@@ -110,6 +113,23 @@ void DhcpProxyScriptFetcherWin::Cancel() {
CancelImpl();
}
+void DhcpProxyScriptFetcherWin::OnShutdown() {
+ DCHECK(CalledOnValidThread());
+
+ // Back up callback, if there is one, as CancelImpl() will destroy it.
+ net::CompletionCallback callback = std::move(callback_);
+
+ // Cancel current request, if there is one.
+ CancelImpl();
+
+ // Prevent future network requests.
+ url_request_context_ = nullptr;
+
+ // Invoke callback with error, if present.
+ if (callback)
+ callback.Run(ERR_CONTEXT_SHUT_DOWN);
+}
+
void DhcpProxyScriptFetcherWin::CancelImpl() {
DCHECK(CalledOnValidThread());
« no previous file with comments | « net/proxy/dhcp_proxy_script_fetcher_win.h ('k') | net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698