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

Unified Diff: net/proxy/mock_proxy_script_fetcher.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/mock_proxy_script_fetcher.h ('k') | net/proxy/proxy_script_decider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/mock_proxy_script_fetcher.cc
diff --git a/net/proxy/mock_proxy_script_fetcher.cc b/net/proxy/mock_proxy_script_fetcher.cc
index 9ace8fb15e6a0c2a93bcc28d07556ed40699b50b..8813b84323f7559f940b85cde1c74a36d4836597 100644
--- a/net/proxy/mock_proxy_script_fetcher.cc
+++ b/net/proxy/mock_proxy_script_fetcher.cc
@@ -4,6 +4,7 @@
#include "net/proxy/mock_proxy_script_fetcher.h"
+#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -15,8 +16,8 @@ namespace net {
MockProxyScriptFetcher::MockProxyScriptFetcher()
: pending_request_text_(NULL),
- waiting_for_fetch_(false) {
-}
+ waiting_for_fetch_(false),
+ is_shutdown_(false) {}
MockProxyScriptFetcher::~MockProxyScriptFetcher() {}
@@ -25,14 +26,17 @@ int MockProxyScriptFetcher::Fetch(const GURL& url, base::string16* text,
const CompletionCallback& callback) {
DCHECK(!has_pending_request());
+ if (waiting_for_fetch_)
+ base::MessageLoop::current()->QuitWhenIdle();
+
+ if (is_shutdown_)
+ return ERR_CONTEXT_SHUT_DOWN;
+
// Save the caller's information, and have them wait.
pending_request_url_ = url;
pending_request_callback_ = callback;
pending_request_text_ = text;
- if (waiting_for_fetch_)
- base::MessageLoop::current()->QuitWhenIdle();
-
return ERR_IO_PENDING;
}
@@ -46,6 +50,14 @@ void MockProxyScriptFetcher::NotifyFetchCompletion(
}
void MockProxyScriptFetcher::Cancel() {
+ pending_request_callback_.Reset();
+}
+
+void MockProxyScriptFetcher::OnShutdown() {
+ is_shutdown_ = true;
+ if (pending_request_callback_) {
+ base::ResetAndReturn(&pending_request_callback_).Run(ERR_CONTEXT_SHUT_DOWN);
+ }
}
URLRequestContext* MockProxyScriptFetcher::GetRequestContext() const {
« no previous file with comments | « net/proxy/mock_proxy_script_fetcher.h ('k') | net/proxy/proxy_script_decider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698