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

Unified Diff: net/proxy/proxy_script_decider_unittest.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/proxy_script_decider.cc ('k') | net/proxy/proxy_script_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_script_decider_unittest.cc
diff --git a/net/proxy/proxy_script_decider_unittest.cc b/net/proxy/proxy_script_decider_unittest.cc
index dfcfeda300a26d6c72c8c69880eedf2759327118..1a2a368b8ea274c9681499429b56a7795fefba5c 100644
--- a/net/proxy/proxy_script_decider_unittest.cc
+++ b/net/proxy/proxy_script_decider_unittest.cc
@@ -128,6 +128,8 @@ class RuleBasedProxyScriptFetcher : public ProxyScriptFetcher {
void Cancel() override {}
+ void OnShutdown() override { request_context_ = nullptr; }
+
URLRequestContext* GetRequestContext() const override {
return request_context_;
}
@@ -146,6 +148,7 @@ class MockDhcpProxyScriptFetcher : public DhcpProxyScriptFetcher {
int Fetch(base::string16* utf16_text,
const CompletionCallback& callback) override;
void Cancel() override;
+ void OnShutdown() override;
const GURL& GetPacURL() const override;
virtual void SetPacURL(const GURL& url);
@@ -172,6 +175,8 @@ int MockDhcpProxyScriptFetcher::Fetch(base::string16* utf16_text,
void MockDhcpProxyScriptFetcher::Cancel() { }
+void MockDhcpProxyScriptFetcher::OnShutdown() {}
+
const GURL& MockDhcpProxyScriptFetcher::GetPacURL() const {
return gurl_;
}
@@ -333,7 +338,6 @@ class ProxyScriptDeciderQuickCheckTest : public ::testing::Test {
}
protected:
- std::unique_ptr<ProxyScriptDecider> decider_;
MockHostResolver resolver_;
Rules rules_;
Rules::Rule rule_;
@@ -341,6 +345,7 @@ class ProxyScriptDeciderQuickCheckTest : public ::testing::Test {
RuleBasedProxyScriptFetcher fetcher_;
ProxyConfig config_;
DoNothingDhcpProxyScriptFetcher dhcp_fetcher_;
+ std::unique_ptr<ProxyScriptDecider> decider_;
private:
URLRequestContext request_context_;
@@ -438,6 +443,17 @@ TEST_F(ProxyScriptDeciderQuickCheckTest, ExplicitPacUrl) {
EXPECT_EQ(rule.url, decider_->effective_config().pac_url());
}
+TEST_F(ProxyScriptDeciderQuickCheckTest, ShutdownDuringResolve) {
+ resolver_.set_ondemand_mode(true);
+
+ EXPECT_THAT(StartDecider(), IsError(ERR_IO_PENDING));
+ EXPECT_TRUE(resolver_.has_pending_requests());
+
+ decider_->OnShutdown();
+ EXPECT_FALSE(resolver_.has_pending_requests());
+ EXPECT_EQ(ERR_CONTEXT_SHUT_DOWN, callback_.WaitForResult());
+}
+
// Regression test for http://crbug.com/409698.
// This test lets the state machine get into state QUICK_CHECK_COMPLETE, then
// destroys the decider, causing a cancel.
@@ -670,6 +686,8 @@ class SynchronousSuccessDhcpFetcher : public DhcpProxyScriptFetcher {
void Cancel() override {}
+ void OnShutdown() override {}
+
const GURL& GetPacURL() const override { return gurl_; }
const base::string16& expected_text() const {
@@ -752,6 +770,8 @@ class AsyncFailDhcpFetcher
void Cancel() override { callback_.Reset(); }
+ void OnShutdown() override {}
+
const GURL& GetPacURL() const override { return dummy_gurl_; }
void CallbackWithFailure() {
« no previous file with comments | « net/proxy/proxy_script_decider.cc ('k') | net/proxy/proxy_script_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698