Reland 167337 - Move url_request_test_util into net namespace
This file contains some rather generic names like "TestDelegate". Move it to the net namespace to avoid collisions BUG=none TBR=wtc@chromium.org,darin@chromium.org Original Review URL: https://codereview.chromium.org/11369179 Review URL: https://chromiumcodereview.appspot.com/11365227 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167413 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome
browser
chromeos
component_updater
extensions
api
declarative_webrequest
webrequest_action_unittest.ccwebrequest_condition_attribute_unittest.ccwebrequest_condition_unittest.ccwebrequest_rules_registry_unittest.cc
web_request
intents
net
predictors
printing
service
cloud_print
test
chrome_frame/test
content
jingle
glue
notifier
net
socket_stream
url_request
rlz/lib
sync
internal_api
notifier
tools
webkit
@ -184,7 +184,7 @@ class GViewRequestInterceptorTest : public testing::Test {
|
||||
scoped_refptr<PluginPrefs> plugin_prefs_;
|
||||
net::URLRequestJobFactoryImpl job_factory_;
|
||||
const net::URLRequestJobFactory* old_factory_;
|
||||
TestDelegate test_delegate_;
|
||||
net::TestDelegate test_delegate_;
|
||||
FilePath pdf_path_;
|
||||
content::MockResourceContext resource_context_;
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ class TestConfigurator : public ComponentUpdateService::Configurator {
|
||||
virtual size_t UrlSizeLimit() OVERRIDE { return 256; }
|
||||
|
||||
virtual net::URLRequestContextGetter* RequestContext() OVERRIDE {
|
||||
return new TestURLRequestContextGetter(
|
||||
return new net::TestURLRequestContextGetter(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ TEST(WebRequestActionTest, PerlToRe2Style) {
|
||||
TEST(WebRequestActionTest, TestPermissions) {
|
||||
// Necessary for TestURLRequest.
|
||||
MessageLoop message_loop(MessageLoop::TYPE_IO);
|
||||
TestURLRequestContext context;
|
||||
net::TestURLRequestContext context;
|
||||
|
||||
std::string error;
|
||||
bool bad_message = false;
|
||||
@ -146,7 +146,7 @@ TEST(WebRequestActionTest, TestPermissions) {
|
||||
ASSERT_TRUE(action.get());
|
||||
|
||||
// Check that redirect works on regular URLs but not on protected URLs.
|
||||
TestURLRequest regular_request(GURL("http://test.com"), NULL, &context);
|
||||
net::TestURLRequest regular_request(GURL("http://test.com"), NULL, &context);
|
||||
std::list<LinkedPtrEventResponseDelta> deltas =
|
||||
action_set->CreateDeltas(
|
||||
NULL, "ext1",
|
||||
@ -154,8 +154,8 @@ TEST(WebRequestActionTest, TestPermissions) {
|
||||
false, base::Time());
|
||||
EXPECT_EQ(1u, deltas.size());
|
||||
|
||||
TestURLRequest protected_request(GURL("http://clients1.google.com"),
|
||||
NULL, &context);
|
||||
net::TestURLRequest protected_request(GURL("http://clients1.google.com"),
|
||||
NULL, &context);
|
||||
deltas = action_set->CreateDeltas(
|
||||
NULL, "ext1",
|
||||
WebRequestRule::RequestData(&protected_request, ON_BEFORE_REQUEST),
|
||||
|
@ -84,14 +84,15 @@ TEST(WebRequestConditionAttributeTest, ResourceType) {
|
||||
EXPECT_EQ("", error);
|
||||
ASSERT_TRUE(attribute.get());
|
||||
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest url_request_ok(GURL("http://www.example.com"), NULL, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest url_request_ok(
|
||||
GURL("http://www.example.com"), NULL, &context);
|
||||
content::ResourceRequestInfo::AllocateForTesting(&url_request_ok,
|
||||
ResourceType::MAIN_FRAME, NULL, -1, -1);
|
||||
EXPECT_TRUE(attribute->IsFulfilled(
|
||||
WebRequestRule::RequestData(&url_request_ok, ON_BEFORE_REQUEST)));
|
||||
|
||||
TestURLRequest url_request_fail(
|
||||
net::TestURLRequest url_request_fail(
|
||||
GURL("http://www.example.com"), NULL, &context);
|
||||
content::ResourceRequestInfo::AllocateForTesting(&url_request_ok,
|
||||
ResourceType::SUB_FRAME, NULL, -1, -1);
|
||||
@ -113,10 +114,10 @@ TEST(WebRequestConditionAttributeTest, ContentType) {
|
||||
"chrome/test/data/extensions/api_test/webrequest/declarative")));
|
||||
ASSERT_TRUE(test_server.Start());
|
||||
|
||||
TestURLRequestContext context;
|
||||
TestDelegate delegate;
|
||||
TestURLRequest url_request(test_server.GetURL("files/headers.html"),
|
||||
&delegate, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequest url_request(test_server.GetURL("files/headers.html"),
|
||||
&delegate, &context);
|
||||
url_request.Start();
|
||||
MessageLoop::current()->Run();
|
||||
|
||||
@ -190,9 +191,9 @@ TEST(WebRequestConditionAttributeTest, ThirdParty) {
|
||||
const GURL url_empty;
|
||||
const GURL url_a("http://a.com");
|
||||
const GURL url_b("http://b.com");
|
||||
TestURLRequestContext context;
|
||||
TestDelegate delegate;
|
||||
TestURLRequest url_request(url_a, &delegate, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequest url_request(url_a, &delegate, &context);
|
||||
|
||||
for (unsigned int i = 1; i <= kLastActiveStage; i <<= 1) {
|
||||
if (!(kActiveStages & i))
|
||||
@ -277,9 +278,9 @@ TEST(WebRequestConditionAttributeTest, Stages) {
|
||||
}
|
||||
|
||||
const GURL url_empty;
|
||||
TestURLRequestContext context;
|
||||
TestDelegate delegate;
|
||||
TestURLRequest url_request(url_empty, &delegate, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequest url_request(url_empty, &delegate, &context);
|
||||
|
||||
for (size_t i = 0; i < arraysize(active_stages); ++i) {
|
||||
EXPECT_FALSE(empty_attribute->IsFulfilled(WebRequestRule::RequestData(
|
||||
@ -399,10 +400,10 @@ TEST(WebRequestConditionAttributeTest, RequestHeaders) {
|
||||
// Necessary for TestURLRequest.
|
||||
MessageLoop message_loop(MessageLoop::TYPE_IO);
|
||||
|
||||
TestURLRequestContext context;
|
||||
TestDelegate delegate;
|
||||
TestURLRequest url_request(GURL("http://example.com"), // Dummy URL.
|
||||
&delegate, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequest url_request(GURL("http://example.com"), // Dummy URL.
|
||||
&delegate, &context);
|
||||
url_request.SetExtraRequestHeaderByName(
|
||||
"Custom-header", "custom/value", true /* overwrite */);
|
||||
url_request.Start();
|
||||
@ -484,10 +485,10 @@ TEST(WebRequestConditionAttributeTest, ResponseHeaders) {
|
||||
"chrome/test/data/extensions/api_test/webrequest/declarative")));
|
||||
ASSERT_TRUE(test_server.Start());
|
||||
|
||||
TestURLRequestContext context;
|
||||
TestDelegate delegate;
|
||||
TestURLRequest url_request(test_server.GetURL("files/headers.html"),
|
||||
&delegate, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequest url_request(test_server.GetURL("files/headers.html"),
|
||||
&delegate, &context);
|
||||
url_request.Start();
|
||||
MessageLoop::current()->Run();
|
||||
|
||||
|
@ -69,14 +69,15 @@ TEST(WebRequestConditionTest, CreateCondition) {
|
||||
EXPECT_EQ("", error);
|
||||
ASSERT_TRUE(result.get());
|
||||
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest match_request(GURL("http://www.example.com"), NULL, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest match_request(
|
||||
GURL("http://www.example.com"), NULL, &context);
|
||||
content::ResourceRequestInfo::AllocateForTesting(&match_request,
|
||||
ResourceType::MAIN_FRAME, NULL, -1, -1);
|
||||
EXPECT_TRUE(result->IsFulfilled(
|
||||
WebRequestRule::RequestData(&match_request, ON_BEFORE_REQUEST)));
|
||||
|
||||
TestURLRequest wrong_resource_type(
|
||||
net::TestURLRequest wrong_resource_type(
|
||||
GURL("https://www.example.com"), NULL, &context);
|
||||
content::ResourceRequestInfo::AllocateForTesting(&wrong_resource_type,
|
||||
ResourceType::SUB_FRAME, NULL, -1, -1);
|
||||
@ -140,8 +141,8 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
|
||||
// Test that the result is correct and matches http://www.example.com and
|
||||
// https://www.example.com
|
||||
GURL http_url("http://www.example.com");
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest http_request(http_url, NULL, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest http_request(http_url, NULL, &context);
|
||||
url_match_ids = matcher.MatchURL(http_url);
|
||||
for (std::set<URLMatcherConditionSet::ID>::iterator i = url_match_ids.begin();
|
||||
i != url_match_ids.end(); ++i) {
|
||||
@ -153,7 +154,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
|
||||
|
||||
GURL https_url("https://www.example.com");
|
||||
url_match_ids = matcher.MatchURL(https_url);
|
||||
TestURLRequest https_request(https_url, NULL, &context);
|
||||
net::TestURLRequest https_request(https_url, NULL, &context);
|
||||
number_matches = 0;
|
||||
for (std::set<URLMatcherConditionSet::ID>::iterator i = url_match_ids.begin();
|
||||
i != url_match_ids.end(); ++i) {
|
||||
@ -166,7 +167,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
|
||||
// Check that both, hostPrefix and hostSuffix are evaluated.
|
||||
GURL https_foo_url("https://foo.example.com");
|
||||
url_match_ids = matcher.MatchURL(https_foo_url);
|
||||
TestURLRequest https_foo_request(https_foo_url, NULL, &context);
|
||||
net::TestURLRequest https_foo_request(https_foo_url, NULL, &context);
|
||||
number_matches = 0;
|
||||
for (std::set<URLMatcherConditionSet::ID>::iterator i = url_match_ids.begin();
|
||||
i != url_match_ids.end(); ++i) {
|
||||
@ -223,23 +224,23 @@ TEST(WebRequestConditionTest, TestPortFilter) {
|
||||
|
||||
// Test various URLs.
|
||||
GURL http_url("http://www.example.com");
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest http_request(http_url, NULL, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest http_request(http_url, NULL, &context);
|
||||
url_match_ids = matcher.MatchURL(http_url);
|
||||
ASSERT_EQ(1u, url_match_ids.size());
|
||||
|
||||
GURL http_url_80("http://www.example.com:80");
|
||||
TestURLRequest http_request_80(http_url_80, NULL, &context);
|
||||
net::TestURLRequest http_request_80(http_url_80, NULL, &context);
|
||||
url_match_ids = matcher.MatchURL(http_url_80);
|
||||
ASSERT_EQ(1u, url_match_ids.size());
|
||||
|
||||
GURL http_url_1000("http://www.example.com:1000");
|
||||
TestURLRequest http_request_1000(http_url_1000, NULL, &context);
|
||||
net::TestURLRequest http_request_1000(http_url_1000, NULL, &context);
|
||||
url_match_ids = matcher.MatchURL(http_url_1000);
|
||||
ASSERT_EQ(1u, url_match_ids.size());
|
||||
|
||||
GURL http_url_2000("http://www.example.com:2000");
|
||||
TestURLRequest http_request_2000(http_url_2000, NULL, &context);
|
||||
net::TestURLRequest http_request_2000(http_url_2000, NULL, &context);
|
||||
url_match_ids = matcher.MatchURL(http_url_2000);
|
||||
ASSERT_EQ(0u, url_match_ids.size());
|
||||
}
|
||||
|
@ -227,8 +227,8 @@ TEST_F(WebRequestRulesRegistryTest, AddRulesImpl) {
|
||||
std::set<WebRequestRule::GlobalRuleId> matches;
|
||||
|
||||
GURL http_url("http://www.example.com");
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest http_request(http_url, NULL, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest http_request(http_url, NULL, &context);
|
||||
matches = registry->GetMatches(
|
||||
WebRequestRule::RequestData(&http_request, ON_BEFORE_REQUEST));
|
||||
EXPECT_EQ(2u, matches.size());
|
||||
@ -238,7 +238,7 @@ TEST_F(WebRequestRulesRegistryTest, AddRulesImpl) {
|
||||
matches.end());
|
||||
|
||||
GURL foobar_url("http://www.foobar.com");
|
||||
TestURLRequest foobar_request(foobar_url, NULL, &context);
|
||||
net::TestURLRequest foobar_request(foobar_url, NULL, &context);
|
||||
matches = registry->GetMatches(
|
||||
WebRequestRule::RequestData(&foobar_request, ON_BEFORE_REQUEST));
|
||||
EXPECT_EQ(1u, matches.size());
|
||||
@ -359,8 +359,8 @@ TEST_F(WebRequestRulesRegistryTest, Precedences) {
|
||||
EXPECT_EQ("", error);
|
||||
|
||||
GURL url("http://www.google.com");
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest request(url, NULL, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest request(url, NULL, &context);
|
||||
std::list<LinkedPtrEventResponseDelta> deltas =
|
||||
registry->CreateDeltas(
|
||||
NULL,
|
||||
@ -409,8 +409,8 @@ TEST_F(WebRequestRulesRegistryTest, Priorities) {
|
||||
EXPECT_EQ("", error);
|
||||
|
||||
GURL url("http://www.google.com/index.html");
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest request(url, NULL, &context);
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest request(url, NULL, &context);
|
||||
std::list<LinkedPtrEventResponseDelta> deltas =
|
||||
registry->CreateDeltas(
|
||||
NULL,
|
||||
|
@ -164,7 +164,7 @@ class ExtensionWebRequestTest : public testing::Test {
|
||||
event_router_.get(), NULL, NULL, NULL, &profile_,
|
||||
CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_,
|
||||
NULL, NULL, NULL));
|
||||
context_.reset(new TestURLRequestContext(true));
|
||||
context_.reset(new net::TestURLRequestContext(true));
|
||||
context_->set_network_delegate(network_delegate_.get());
|
||||
context_->Init();
|
||||
}
|
||||
@ -180,13 +180,13 @@ class ExtensionWebRequestTest : public testing::Test {
|
||||
content::TestBrowserThread ui_thread_;
|
||||
content::TestBrowserThread io_thread_;
|
||||
TestingProfile profile_;
|
||||
TestDelegate delegate_;
|
||||
net::TestDelegate delegate_;
|
||||
BooleanPrefMember enable_referrers_;
|
||||
TestIPCSender ipc_sender_;
|
||||
scoped_refptr<extensions::EventRouterForwarder> event_router_;
|
||||
scoped_refptr<ExtensionInfoMap> extension_info_map_;
|
||||
scoped_ptr<ChromeNetworkDelegate> network_delegate_;
|
||||
scoped_ptr<TestURLRequestContext> context_;
|
||||
scoped_ptr<net::TestURLRequestContext> context_;
|
||||
};
|
||||
|
||||
// Tests that we handle disagreements among extensions about responses to
|
||||
@ -707,7 +707,7 @@ class ExtensionWebRequestHeaderModificationTest :
|
||||
event_router_.get(), NULL, NULL, NULL, &profile_,
|
||||
CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_,
|
||||
NULL, NULL, NULL));
|
||||
context_.reset(new TestURLRequestContext(true));
|
||||
context_.reset(new net::TestURLRequestContext(true));
|
||||
host_resolver_.reset(new net::MockHostResolver());
|
||||
host_resolver_->rules()->AddSimulatedFailure("doesnotexist");
|
||||
context_->set_host_resolver(host_resolver_.get());
|
||||
@ -719,14 +719,14 @@ class ExtensionWebRequestHeaderModificationTest :
|
||||
content::TestBrowserThread ui_thread_;
|
||||
content::TestBrowserThread io_thread_;
|
||||
TestingProfile profile_;
|
||||
TestDelegate delegate_;
|
||||
net::TestDelegate delegate_;
|
||||
BooleanPrefMember enable_referrers_;
|
||||
TestIPCSender ipc_sender_;
|
||||
scoped_refptr<extensions::EventRouterForwarder> event_router_;
|
||||
scoped_refptr<ExtensionInfoMap> extension_info_map_;
|
||||
scoped_ptr<ChromeNetworkDelegate> network_delegate_;
|
||||
scoped_ptr<net::MockHostResolver> host_resolver_;
|
||||
scoped_ptr<TestURLRequestContext> context_;
|
||||
scoped_ptr<net::TestURLRequestContext> context_;
|
||||
};
|
||||
|
||||
TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) {
|
||||
|
@ -16,7 +16,7 @@ using content::ResourceRequestInfo;
|
||||
|
||||
TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) {
|
||||
MessageLoopForIO message_loop;
|
||||
TestURLRequestContext context;
|
||||
net::TestURLRequestContext context;
|
||||
scoped_refptr<ExtensionInfoMap> extension_info_map(new ExtensionInfoMap);
|
||||
const char* sensitive_urls[] = {
|
||||
"http://clients2.google.com",
|
||||
@ -36,7 +36,7 @@ TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) {
|
||||
// Check that requests are rejected based on the destination
|
||||
for (size_t i = 0; i < arraysize(sensitive_urls); ++i) {
|
||||
GURL sensitive_url(sensitive_urls[i]);
|
||||
TestURLRequest request(sensitive_url, NULL, &context);
|
||||
net::TestURLRequest request(sensitive_url, NULL, &context);
|
||||
EXPECT_TRUE(
|
||||
WebRequestPermissions::HideRequest(extension_info_map.get(), &request))
|
||||
<< sensitive_urls[i];
|
||||
@ -44,7 +44,7 @@ TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) {
|
||||
// Check that requests are accepted if they don't touch sensitive urls.
|
||||
for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) {
|
||||
GURL non_sensitive_url(non_sensitive_urls[i]);
|
||||
TestURLRequest request(non_sensitive_url, NULL, &context);
|
||||
net::TestURLRequest request(non_sensitive_url, NULL, &context);
|
||||
EXPECT_FALSE(
|
||||
WebRequestPermissions::HideRequest(extension_info_map.get(), &request))
|
||||
<< non_sensitive_urls[i];
|
||||
@ -54,14 +54,14 @@ TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) {
|
||||
// WebStore.
|
||||
// Normally this request is not protected:
|
||||
GURL non_sensitive_url("http://www.google.com/test.js");
|
||||
TestURLRequest non_sensitive_request(non_sensitive_url, NULL, &context);
|
||||
net::TestURLRequest non_sensitive_request(non_sensitive_url, NULL, &context);
|
||||
EXPECT_FALSE(WebRequestPermissions::HideRequest(extension_info_map.get(),
|
||||
&non_sensitive_request));
|
||||
// If the origin is labeled by the WebStoreAppId, it becomes protected.
|
||||
int process_id = 42;
|
||||
int site_instance_id = 23;
|
||||
int frame_id = 17;
|
||||
TestURLRequest sensitive_request(non_sensitive_url, NULL, &context);
|
||||
net::TestURLRequest sensitive_request(non_sensitive_url, NULL, &context);
|
||||
ResourceRequestInfo::AllocateForTesting(&sensitive_request,
|
||||
ResourceType::SCRIPT, NULL, process_id, frame_id);
|
||||
extension_info_map->RegisterExtensionProcess(extension_misc::kWebStoreAppId,
|
||||
|
@ -85,7 +85,7 @@ class ExtensionProtocolTest : public testing::Test {
|
||||
scoped_refptr<ExtensionInfoMap> extension_info_map_;
|
||||
net::URLRequestJobFactoryImpl job_factory_;
|
||||
const net::URLRequestJobFactory* old_factory_;
|
||||
TestDelegate test_delegate_;
|
||||
net::TestDelegate test_delegate_;
|
||||
content::MockResourceContext resource_context_;
|
||||
};
|
||||
|
||||
|
@ -133,11 +133,12 @@ class UserScriptListenerTest
|
||||
}
|
||||
|
||||
protected:
|
||||
TestURLRequest* StartTestRequest(net::URLRequest::Delegate* delegate,
|
||||
const std::string& url_string,
|
||||
TestURLRequestContext* context) {
|
||||
net::TestURLRequest* StartTestRequest(net::URLRequest::Delegate* delegate,
|
||||
const std::string& url_string,
|
||||
net::TestURLRequestContext* context) {
|
||||
GURL url(url_string);
|
||||
TestURLRequest* request = new TestURLRequest(url, delegate, context);
|
||||
net::TestURLRequest* request =
|
||||
new net::TestURLRequest(url, delegate, context);
|
||||
|
||||
ResourceThrottle* throttle =
|
||||
listener_->CreateResourceThrottle(url, ResourceType::MAIN_FRAME);
|
||||
@ -182,9 +183,9 @@ TEST_F(UserScriptListenerTest, DelayAndUpdate) {
|
||||
LoadTestExtension();
|
||||
MessageLoop::current()->RunAllPending();
|
||||
|
||||
TestDelegate delegate;
|
||||
TestURLRequestContext context;
|
||||
scoped_ptr<TestURLRequest> request(
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequestContext context;
|
||||
scoped_ptr<net::TestURLRequest> request(
|
||||
StartTestRequest(&delegate, kMatchingUrl, &context));
|
||||
ASSERT_FALSE(request->is_pending());
|
||||
|
||||
@ -200,9 +201,9 @@ TEST_F(UserScriptListenerTest, DelayAndUnload) {
|
||||
LoadTestExtension();
|
||||
MessageLoop::current()->RunAllPending();
|
||||
|
||||
TestDelegate delegate;
|
||||
TestURLRequestContext context;
|
||||
scoped_ptr<TestURLRequest> request(
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequestContext context;
|
||||
scoped_ptr<net::TestURLRequest> request(
|
||||
StartTestRequest(&delegate, kMatchingUrl, &context));
|
||||
ASSERT_FALSE(request->is_pending());
|
||||
|
||||
@ -222,9 +223,9 @@ TEST_F(UserScriptListenerTest, DelayAndUnload) {
|
||||
}
|
||||
|
||||
TEST_F(UserScriptListenerTest, NoDelayNoExtension) {
|
||||
TestDelegate delegate;
|
||||
TestURLRequestContext context;
|
||||
scoped_ptr<TestURLRequest> request(
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequestContext context;
|
||||
scoped_ptr<net::TestURLRequest> request(
|
||||
StartTestRequest(&delegate, kMatchingUrl, &context));
|
||||
|
||||
// The request should be started immediately.
|
||||
@ -238,11 +239,11 @@ TEST_F(UserScriptListenerTest, NoDelayNotMatching) {
|
||||
LoadTestExtension();
|
||||
MessageLoop::current()->RunAllPending();
|
||||
|
||||
TestDelegate delegate;
|
||||
TestURLRequestContext context;
|
||||
scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate,
|
||||
kNotMatchingUrl,
|
||||
&context));
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequestContext context;
|
||||
scoped_ptr<net::TestURLRequest> request(StartTestRequest(&delegate,
|
||||
kNotMatchingUrl,
|
||||
&context));
|
||||
|
||||
// The request should be started immediately.
|
||||
ASSERT_TRUE(request->is_pending());
|
||||
@ -268,9 +269,9 @@ TEST_F(UserScriptListenerTest, MultiProfile) {
|
||||
content::Source<Profile>(&profile2),
|
||||
content::Details<Extension>(extension.get()));
|
||||
|
||||
TestDelegate delegate;
|
||||
TestURLRequestContext context;
|
||||
scoped_ptr<TestURLRequest> request(
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequestContext context;
|
||||
scoped_ptr<net::TestURLRequest> request(
|
||||
StartTestRequest(&delegate, kMatchingUrl, &context));
|
||||
ASSERT_FALSE(request->is_pending());
|
||||
|
||||
@ -299,11 +300,11 @@ TEST_F(UserScriptListenerTest, MultiProfile) {
|
||||
TEST_F(UserScriptListenerTest, ResumeBeforeStart) {
|
||||
LoadTestExtension();
|
||||
MessageLoop::current()->RunAllPending();
|
||||
TestDelegate delegate;
|
||||
TestURLRequestContext context;
|
||||
net::TestDelegate delegate;
|
||||
net::TestURLRequestContext context;
|
||||
GURL url(kMatchingUrl);
|
||||
scoped_ptr<TestURLRequest> request(
|
||||
new TestURLRequest(url, &delegate, &context));
|
||||
scoped_ptr<net::TestURLRequest> request(
|
||||
new net::TestURLRequest(url, &delegate, &context));
|
||||
|
||||
ResourceThrottle* throttle =
|
||||
listener_->CreateResourceThrottle(url, ResourceType::MAIN_FRAME);
|
||||
|
@ -154,8 +154,8 @@ const char kImagePngType[] = "image/png";
|
||||
class CWSIntentsRegistryTest : public testing::Test {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
scoped_refptr<TestURLRequestContextGetter> context_getter(
|
||||
new TestURLRequestContextGetter(ui_loop_.message_loop_proxy()));
|
||||
scoped_refptr<net::TestURLRequestContextGetter> context_getter(
|
||||
new net::TestURLRequestContextGetter(ui_loop_.message_loop_proxy()));
|
||||
registry_.reset(context_getter);
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ class ChromeNetworkDelegateTest : public testing::Test {
|
||||
void NeverThrottleLogicImpl() {
|
||||
scoped_ptr<ChromeNetworkDelegate> delegate(CreateNetworkDelegate());
|
||||
|
||||
TestURLRequestContext context;
|
||||
TestURLRequest extension_request(
|
||||
net::TestURLRequestContext context;
|
||||
net::TestURLRequest extension_request(
|
||||
GURL("http://example.com/"), NULL, &context);
|
||||
extension_request.set_first_party_for_cookies(
|
||||
GURL("chrome-extension://abcdef/bingo.html"));
|
||||
TestURLRequest web_page_request(
|
||||
net::TestURLRequest web_page_request(
|
||||
GURL("http://example.com/"), NULL, &context);
|
||||
web_page_request.set_first_party_for_cookies(
|
||||
GURL("http://example.com/helloworld.html"));
|
||||
@ -130,7 +130,7 @@ class ChromeNetworkDelegateSafeSearchTest : public testing::Test {
|
||||
// Show the URL in the trace so we know where we failed.
|
||||
SCOPED_TRACE(url_string);
|
||||
|
||||
TestURLRequest request(GURL(url_string), &delegate_, &context_);
|
||||
net::TestURLRequest request(GURL(url_string), &delegate_, &context_);
|
||||
|
||||
request.Start();
|
||||
MessageLoop::current()->RunUntilIdle();
|
||||
@ -145,8 +145,8 @@ class ChromeNetworkDelegateSafeSearchTest : public testing::Test {
|
||||
BooleanPrefMember enable_referrers_;
|
||||
BooleanPrefMember force_google_safe_search_;
|
||||
scoped_ptr<net::URLRequest> request_;
|
||||
TestURLRequestContext context_;
|
||||
TestDelegate delegate_;
|
||||
net::TestURLRequestContext context_;
|
||||
net::TestDelegate delegate_;
|
||||
MessageLoopForIO message_loop_;
|
||||
scoped_ptr<content::TestBrowserThread> io_thread_;
|
||||
};
|
||||
|
@ -94,7 +94,7 @@ class HttpPipeliningCompatibilityClientTest : public testing::Test {
|
||||
// TODO(rtenneti): Leaks StatisticsRecorder and will update suppressions.
|
||||
base::StatisticsRecorder::Initialize();
|
||||
ASSERT_TRUE(test_server_.Start());
|
||||
context_ = new TestURLRequestContextGetter(
|
||||
context_ = new net::TestURLRequestContextGetter(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
|
||||
context_->AddRef();
|
||||
|
||||
@ -204,7 +204,7 @@ class HttpPipeliningCompatibilityClientTest : public testing::Test {
|
||||
|
||||
MessageLoopForIO message_loop_;
|
||||
net::TestServer test_server_;
|
||||
TestURLRequestContextGetter* context_;
|
||||
net::TestURLRequestContextGetter* context_;
|
||||
content::TestBrowserThread io_thread_;
|
||||
|
||||
private:
|
||||
|
@ -46,7 +46,7 @@ class TestResourcePrefetcher : public ResourcePrefetcher {
|
||||
class TestResourcePrefetcherDelegate : public ResourcePrefetcher::Delegate {
|
||||
public:
|
||||
explicit TestResourcePrefetcherDelegate(MessageLoop* loop)
|
||||
: request_context_getter_(new TestURLRequestContextGetter(
|
||||
: request_context_getter_(new net::TestURLRequestContextGetter(
|
||||
loop->message_loop_proxy())) { }
|
||||
~TestResourcePrefetcherDelegate() { }
|
||||
|
||||
@ -59,7 +59,7 @@ class TestResourcePrefetcherDelegate : public ResourcePrefetcher::Delegate {
|
||||
ResourcePrefetcher::RequestVector* requests));
|
||||
|
||||
private:
|
||||
scoped_refptr<TestURLRequestContextGetter> request_context_getter_;
|
||||
scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TestResourcePrefetcherDelegate);
|
||||
};
|
||||
|
@ -119,10 +119,10 @@ class TestController {
|
||||
const GURL expected_url() {
|
||||
return expected_url_;
|
||||
}
|
||||
void set_delegate(TestDelegate* delegate) {
|
||||
void set_delegate(net::TestDelegate* delegate) {
|
||||
delegate_ = delegate;
|
||||
}
|
||||
TestDelegate* delegate() {
|
||||
net::TestDelegate* delegate() {
|
||||
return delegate_;
|
||||
}
|
||||
void set_use_delegate(bool value) {
|
||||
@ -140,7 +140,7 @@ class TestController {
|
||||
bool result_;
|
||||
bool use_delegate_;
|
||||
GURL expected_url_;
|
||||
TestDelegate* delegate_;
|
||||
net::TestDelegate* delegate_;
|
||||
|
||||
friend struct DefaultSingletonTraits<TestController>;
|
||||
};
|
||||
@ -156,7 +156,7 @@ class PrintDialogCloudTest : public InProcessBrowserTest {
|
||||
// Must be static for handing into AddHostnameHandler.
|
||||
static net::URLRequest::ProtocolFactory Factory;
|
||||
|
||||
class AutoQuitDelegate : public TestDelegate {
|
||||
class AutoQuitDelegate : public net::TestDelegate {
|
||||
public:
|
||||
AutoQuitDelegate() {}
|
||||
|
||||
|
@ -27,7 +27,7 @@ const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
|
||||
|
||||
int g_request_context_getter_instances = 0;
|
||||
class TrackingTestURLRequestContextGetter
|
||||
: public TestURLRequestContextGetter {
|
||||
: public net::TestURLRequestContextGetter {
|
||||
public:
|
||||
explicit TrackingTestURLRequestContextGetter(
|
||||
base::MessageLoopProxy* io_message_loop_proxy,
|
||||
@ -38,9 +38,9 @@ class TrackingTestURLRequestContextGetter
|
||||
g_request_context_getter_instances++;
|
||||
}
|
||||
|
||||
virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE {
|
||||
virtual net::TestURLRequestContext* GetURLRequestContext() OVERRIDE {
|
||||
if (!context_.get()) {
|
||||
context_.reset(new TestURLRequestContext(true));
|
||||
context_.reset(new net::TestURLRequestContext(true));
|
||||
context_->set_throttler_manager(throttler_manager_);
|
||||
context_->Init();
|
||||
}
|
||||
@ -55,7 +55,7 @@ class TrackingTestURLRequestContextGetter
|
||||
private:
|
||||
// Not owned here.
|
||||
net::URLRequestThrottlerManager* throttler_manager_;
|
||||
scoped_ptr<TestURLRequestContext> context_;
|
||||
scoped_ptr<net::TestURLRequestContext> context_;
|
||||
};
|
||||
|
||||
class TestCloudPrintURLFetcher : public CloudPrintURLFetcher {
|
||||
|
@ -618,7 +618,7 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
|
||||
void TestingProfile::CreateRequestContext() {
|
||||
if (!request_context_)
|
||||
request_context_ =
|
||||
new TestURLRequestContextGetter(
|
||||
new net::TestURLRequestContextGetter(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,7 @@ void CFUrlRequestUnittestRunner::OnInitializationTimeout() {
|
||||
|
||||
void CFUrlRequestUnittestRunner::OverrideHttpHost() {
|
||||
override_http_host_.reset(
|
||||
new ScopedCustomUrlRequestTestHttpHost(
|
||||
new net::ScopedCustomUrlRequestTestHttpHost(
|
||||
chrome_frame_test::GetLocalIPv4Address()));
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,10 @@
|
||||
class CommandLine;
|
||||
class FakeBrowserProcessImpl;
|
||||
class ProcessSingleton;
|
||||
|
||||
namespace net {
|
||||
class ScopedCustomUrlRequestTestHttpHost;
|
||||
} // namespace net
|
||||
|
||||
namespace content {
|
||||
class NotificationService;
|
||||
@ -122,7 +125,7 @@ class CFUrlRequestUnittestRunner
|
||||
base::ProcessHandle crash_service_;
|
||||
DWORD test_thread_id_;
|
||||
|
||||
scoped_ptr<ScopedCustomUrlRequestTestHttpHost> override_http_host_;
|
||||
scoped_ptr<net::ScopedCustomUrlRequestTestHttpHost> override_http_host_;
|
||||
|
||||
scoped_ptr<test_server::SimpleWebServer> test_http_server_;
|
||||
test_server::SimpleResponse chrome_frame_html_;
|
||||
|
@ -65,7 +65,7 @@ class TestURLRequest : public net::URLRequest {
|
||||
public:
|
||||
TestURLRequest(const GURL& url,
|
||||
Delegate* delegate,
|
||||
TestURLRequestContext* context)
|
||||
net::TestURLRequestContext* context)
|
||||
: net::URLRequest(url, delegate, context) {
|
||||
}
|
||||
};
|
||||
@ -81,7 +81,7 @@ class UrlTaskChain {
|
||||
|
||||
MessageLoopForIO loop;
|
||||
|
||||
TestURLRequestContext context;
|
||||
net::TestURLRequestContext context;
|
||||
TestURLRequest r(GURL(url_), &delegate_, &context);
|
||||
r.Start();
|
||||
EXPECT_TRUE(r.is_pending());
|
||||
@ -103,7 +103,7 @@ class UrlTaskChain {
|
||||
|
||||
protected:
|
||||
std::string url_;
|
||||
TestDelegate delegate_;
|
||||
net::TestDelegate delegate_;
|
||||
UrlTaskChain* next_;
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace content {
|
||||
|
||||
MockResourceContext::MockResourceContext()
|
||||
: test_request_context_(new TestURLRequestContext) {
|
||||
: test_request_context_(new net::TestURLRequestContext) {
|
||||
}
|
||||
|
||||
MockResourceContext::~MockResourceContext() {}
|
||||
|
@ -205,7 +205,7 @@ void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) {
|
||||
MessageLoop::current()));
|
||||
|
||||
// Populate our resource context.
|
||||
test_request_context_.reset(new TestURLRequestContext());
|
||||
test_request_context_.reset(new net::TestURLRequestContext());
|
||||
MockRTCResourceContext* resource_context =
|
||||
static_cast<MockRTCResourceContext*>(resource_context_.get());
|
||||
resource_context->set_request_context(test_request_context_.get());
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
class MyTestURLRequestContext : public TestURLRequestContext {
|
||||
class MyTestURLRequestContext : public net::TestURLRequestContext {
|
||||
public:
|
||||
MyTestURLRequestContext() : TestURLRequestContext(true) {
|
||||
context_storage_.set_proxy_service(
|
||||
@ -35,9 +35,10 @@ namespace jingle_glue {
|
||||
class ProxyResolvingClientSocketTest : public testing::Test {
|
||||
protected:
|
||||
ProxyResolvingClientSocketTest()
|
||||
: url_request_context_getter_(new TestURLRequestContextGetter(
|
||||
: url_request_context_getter_(new net::TestURLRequestContextGetter(
|
||||
base::MessageLoopProxy::current(),
|
||||
scoped_ptr<TestURLRequestContext>(new MyTestURLRequestContext))) {}
|
||||
scoped_ptr<net::TestURLRequestContext>(
|
||||
new MyTestURLRequestContext))) {}
|
||||
|
||||
virtual ~ProxyResolvingClientSocketTest() {}
|
||||
|
||||
@ -48,7 +49,7 @@ class ProxyResolvingClientSocketTest : public testing::Test {
|
||||
}
|
||||
|
||||
MessageLoop message_loop_;
|
||||
scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_;
|
||||
scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_;
|
||||
};
|
||||
|
||||
// TODO(sanjeevr): Fix this test on Linux.
|
||||
|
@ -75,7 +75,7 @@ class XmppConnectionTest : public testing::Test {
|
||||
protected:
|
||||
XmppConnectionTest()
|
||||
: mock_pre_xmpp_auth_(new MockPreXmppAuth()),
|
||||
url_request_context_getter_(new TestURLRequestContextGetter(
|
||||
url_request_context_getter_(new net::TestURLRequestContextGetter(
|
||||
message_loop_.message_loop_proxy())) {}
|
||||
|
||||
virtual ~XmppConnectionTest() {}
|
||||
@ -89,7 +89,7 @@ class XmppConnectionTest : public testing::Test {
|
||||
MessageLoop message_loop_;
|
||||
MockXmppConnectionDelegate mock_xmpp_connection_delegate_;
|
||||
scoped_ptr<MockPreXmppAuth> mock_pre_xmpp_auth_;
|
||||
scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_;
|
||||
scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_;
|
||||
};
|
||||
|
||||
TEST_F(XmppConnectionTest, CreateDestroy) {
|
||||
|
@ -70,7 +70,7 @@ class FakeDelegate : public SingleLoginAttempt::Delegate {
|
||||
ServerInformation redirect_server_;
|
||||
};
|
||||
|
||||
class MyTestURLRequestContext : public TestURLRequestContext {
|
||||
class MyTestURLRequestContext : public net::TestURLRequestContext {
|
||||
public:
|
||||
MyTestURLRequestContext() : TestURLRequestContext(true) {
|
||||
context_storage_.set_host_resolver(
|
||||
@ -85,9 +85,10 @@ class SingleLoginAttemptTest : public ::testing::Test {
|
||||
SingleLoginAttemptTest()
|
||||
: login_settings_(
|
||||
buzz::XmppClientSettings(),
|
||||
new TestURLRequestContextGetter(
|
||||
new net::TestURLRequestContextGetter(
|
||||
base::MessageLoopProxy::current(),
|
||||
scoped_ptr<TestURLRequestContext>(new MyTestURLRequestContext())),
|
||||
scoped_ptr<net::TestURLRequestContext>(
|
||||
new MyTestURLRequestContext())),
|
||||
ServerList(
|
||||
1,
|
||||
ServerInformation(
|
||||
|
@ -22,7 +22,8 @@ class PushClientTest : public testing::Test {
|
||||
protected:
|
||||
PushClientTest() {
|
||||
notifier_options_.request_context_getter =
|
||||
new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
|
||||
new net::TestURLRequestContextGetter(
|
||||
message_loop_.message_loop_proxy());
|
||||
}
|
||||
|
||||
virtual ~PushClientTest() {}
|
||||
|
@ -34,7 +34,8 @@ class XmppPushClientTest : public testing::Test {
|
||||
protected:
|
||||
XmppPushClientTest() {
|
||||
notifier_options_.request_context_getter =
|
||||
new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
|
||||
new net::TestURLRequestContextGetter(
|
||||
message_loop_.message_loop_proxy());
|
||||
}
|
||||
|
||||
virtual ~XmppPushClientTest() {}
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "testing/platform_test.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
struct SocketStreamEvent {
|
||||
@ -32,25 +34,25 @@ struct SocketStreamEvent {
|
||||
};
|
||||
|
||||
SocketStreamEvent(EventType type,
|
||||
net::SocketStream* socket_stream,
|
||||
SocketStream* socket_stream,
|
||||
int num,
|
||||
const std::string& str,
|
||||
net::AuthChallengeInfo* auth_challenge_info,
|
||||
AuthChallengeInfo* auth_challenge_info,
|
||||
int error)
|
||||
: event_type(type), socket(socket_stream), number(num), data(str),
|
||||
auth_info(auth_challenge_info), error_code(error) {}
|
||||
|
||||
EventType event_type;
|
||||
net::SocketStream* socket;
|
||||
SocketStream* socket;
|
||||
int number;
|
||||
std::string data;
|
||||
scoped_refptr<net::AuthChallengeInfo> auth_info;
|
||||
scoped_refptr<AuthChallengeInfo> auth_info;
|
||||
int error_code;
|
||||
};
|
||||
|
||||
class SocketStreamEventRecorder : public net::SocketStream::Delegate {
|
||||
class SocketStreamEventRecorder : public SocketStream::Delegate {
|
||||
public:
|
||||
explicit SocketStreamEventRecorder(const net::CompletionCallback& callback)
|
||||
explicit SocketStreamEventRecorder(const CompletionCallback& callback)
|
||||
: callback_(callback) {}
|
||||
virtual ~SocketStreamEventRecorder() {}
|
||||
|
||||
@ -82,59 +84,59 @@ class SocketStreamEventRecorder : public net::SocketStream::Delegate {
|
||||
}
|
||||
|
||||
virtual int OnStartOpenConnection(
|
||||
net::SocketStream* socket,
|
||||
const net::CompletionCallback& callback) OVERRIDE {
|
||||
SocketStream* socket,
|
||||
const CompletionCallback& callback) OVERRIDE {
|
||||
connection_callback_ = callback;
|
||||
events_.push_back(
|
||||
SocketStreamEvent(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
|
||||
socket, 0, std::string(), NULL, net::OK));
|
||||
socket, 0, std::string(), NULL, OK));
|
||||
if (!on_start_open_connection_.is_null())
|
||||
return on_start_open_connection_.Run(&events_.back());
|
||||
return net::OK;
|
||||
return OK;
|
||||
}
|
||||
virtual void OnConnected(net::SocketStream* socket,
|
||||
virtual void OnConnected(SocketStream* socket,
|
||||
int num_pending_send_allowed) OVERRIDE {
|
||||
events_.push_back(
|
||||
SocketStreamEvent(SocketStreamEvent::EVENT_CONNECTED,
|
||||
socket, num_pending_send_allowed, std::string(),
|
||||
NULL, net::OK));
|
||||
NULL, OK));
|
||||
if (!on_connected_.is_null())
|
||||
on_connected_.Run(&events_.back());
|
||||
}
|
||||
virtual void OnSentData(net::SocketStream* socket,
|
||||
virtual void OnSentData(SocketStream* socket,
|
||||
int amount_sent) OVERRIDE {
|
||||
events_.push_back(
|
||||
SocketStreamEvent(SocketStreamEvent::EVENT_SENT_DATA, socket,
|
||||
amount_sent, std::string(), NULL, net::OK));
|
||||
amount_sent, std::string(), NULL, OK));
|
||||
if (!on_sent_data_.is_null())
|
||||
on_sent_data_.Run(&events_.back());
|
||||
}
|
||||
virtual void OnReceivedData(net::SocketStream* socket,
|
||||
virtual void OnReceivedData(SocketStream* socket,
|
||||
const char* data, int len) OVERRIDE {
|
||||
events_.push_back(
|
||||
SocketStreamEvent(SocketStreamEvent::EVENT_RECEIVED_DATA, socket, len,
|
||||
std::string(data, len), NULL, net::OK));
|
||||
std::string(data, len), NULL, OK));
|
||||
if (!on_received_data_.is_null())
|
||||
on_received_data_.Run(&events_.back());
|
||||
}
|
||||
virtual void OnClose(net::SocketStream* socket) OVERRIDE {
|
||||
virtual void OnClose(SocketStream* socket) OVERRIDE {
|
||||
events_.push_back(
|
||||
SocketStreamEvent(SocketStreamEvent::EVENT_CLOSE, socket, 0,
|
||||
std::string(), NULL, net::OK));
|
||||
std::string(), NULL, OK));
|
||||
if (!on_close_.is_null())
|
||||
on_close_.Run(&events_.back());
|
||||
if (!callback_.is_null())
|
||||
callback_.Run(net::OK);
|
||||
callback_.Run(OK);
|
||||
}
|
||||
virtual void OnAuthRequired(net::SocketStream* socket,
|
||||
net::AuthChallengeInfo* auth_info) OVERRIDE {
|
||||
virtual void OnAuthRequired(SocketStream* socket,
|
||||
AuthChallengeInfo* auth_info) OVERRIDE {
|
||||
events_.push_back(
|
||||
SocketStreamEvent(SocketStreamEvent::EVENT_AUTH_REQUIRED, socket, 0,
|
||||
std::string(), auth_info, net::OK));
|
||||
std::string(), auth_info, OK));
|
||||
if (!on_auth_required_.is_null())
|
||||
on_auth_required_.Run(&events_.back());
|
||||
}
|
||||
virtual void OnError(const net::SocketStream* socket, int error) OVERRIDE {
|
||||
virtual void OnError(const SocketStream* socket, int error) OVERRIDE {
|
||||
events_.push_back(
|
||||
SocketStreamEvent(SocketStreamEvent::EVENT_ERROR, NULL, 0,
|
||||
std::string(), NULL, error));
|
||||
@ -152,7 +154,7 @@ class SocketStreamEventRecorder : public net::SocketStream::Delegate {
|
||||
<< " password=" << credentials_.password();
|
||||
event->socket->RestartWithAuth(credentials_);
|
||||
}
|
||||
void SetAuthInfo(const net::AuthCredentials& credentials) {
|
||||
void SetAuthInfo(const AuthCredentials& credentials) {
|
||||
credentials_ = credentials;
|
||||
}
|
||||
void CompleteConnection(int result) {
|
||||
@ -172,9 +174,9 @@ class SocketStreamEventRecorder : public net::SocketStream::Delegate {
|
||||
base::Callback<void(SocketStreamEvent*)> on_close_;
|
||||
base::Callback<void(SocketStreamEvent*)> on_auth_required_;
|
||||
base::Callback<void(SocketStreamEvent*)> on_error_;
|
||||
const net::CompletionCallback callback_;
|
||||
net::CompletionCallback connection_callback_;
|
||||
net::AuthCredentials credentials_;
|
||||
const CompletionCallback callback_;
|
||||
CompletionCallback connection_callback_;
|
||||
AuthCredentials credentials_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SocketStreamEventRecorder);
|
||||
};
|
||||
@ -183,7 +185,7 @@ class TestURLRequestContextWithProxy : public TestURLRequestContext {
|
||||
public:
|
||||
explicit TestURLRequestContextWithProxy(const std::string& proxy)
|
||||
: TestURLRequestContext(true) {
|
||||
context_storage_.set_proxy_service(net::ProxyService::CreateFixed(proxy));
|
||||
context_storage_.set_proxy_service(ProxyService::CreateFixed(proxy));
|
||||
Init();
|
||||
}
|
||||
virtual ~TestURLRequestContextWithProxy() {}
|
||||
@ -192,12 +194,12 @@ class TestURLRequestContextWithProxy : public TestURLRequestContext {
|
||||
class TestSocketStreamNetworkDelegate : public TestNetworkDelegate {
|
||||
public:
|
||||
TestSocketStreamNetworkDelegate()
|
||||
: before_connect_result_(net::OK) {}
|
||||
: before_connect_result_(OK) {}
|
||||
virtual ~TestSocketStreamNetworkDelegate() {}
|
||||
|
||||
virtual int OnBeforeSocketStreamConnect(
|
||||
net::SocketStream* stream,
|
||||
const net::CompletionCallback& callback) OVERRIDE {
|
||||
SocketStream* stream,
|
||||
const CompletionCallback& callback) OVERRIDE {
|
||||
return before_connect_result_;
|
||||
}
|
||||
|
||||
@ -211,8 +213,6 @@ class TestSocketStreamNetworkDelegate : public TestNetworkDelegate {
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace net {
|
||||
|
||||
class SocketStreamTest : public PlatformTest {
|
||||
public:
|
||||
virtual ~SocketStreamTest() {}
|
||||
@ -259,12 +259,12 @@ class SocketStreamTest : public PlatformTest {
|
||||
}
|
||||
|
||||
virtual int DoSwitchToSpdyTest(SocketStreamEvent* event) {
|
||||
return net::ERR_PROTOCOL_SWITCHED;
|
||||
return ERR_PROTOCOL_SWITCHED;
|
||||
}
|
||||
|
||||
virtual int DoIOPending(SocketStreamEvent* event) {
|
||||
io_test_callback_.callback().Run(net::OK);
|
||||
return net::ERR_IO_PENDING;
|
||||
io_test_callback_.callback().Run(OK);
|
||||
return ERR_IO_PENDING;
|
||||
}
|
||||
|
||||
static const char kWebSocketHandshakeRequest[];
|
||||
@ -359,7 +359,7 @@ TEST_F(SocketStreamTest, CloseFlushPendingWrite) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[4].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[5].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[6].event_type);
|
||||
EXPECT_EQ(net::ERR_CONNECTION_CLOSED, events[6].error_code);
|
||||
EXPECT_EQ(ERR_CONNECTION_CLOSED, events[6].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[7].event_type);
|
||||
}
|
||||
|
||||
@ -404,8 +404,8 @@ TEST_F(SocketStreamTest, BasicAuthProxy) {
|
||||
new SocketStreamEventRecorder(test_callback.callback()));
|
||||
delegate->SetOnConnected(base::Bind(&SocketStreamEventRecorder::DoClose,
|
||||
base::Unretained(delegate.get())));
|
||||
delegate->SetAuthInfo(net::AuthCredentials(ASCIIToUTF16("foo"),
|
||||
ASCIIToUTF16("bar")));
|
||||
delegate->SetAuthInfo(AuthCredentials(ASCIIToUTF16("foo"),
|
||||
ASCIIToUTF16("bar")));
|
||||
delegate->SetOnAuthRequired(base::Bind(
|
||||
&SocketStreamEventRecorder::DoRestartWithAuth,
|
||||
base::Unretained(delegate.get())));
|
||||
@ -430,7 +430,7 @@ TEST_F(SocketStreamTest, BasicAuthProxy) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_AUTH_REQUIRED, events[1].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[2].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[3].event_type);
|
||||
EXPECT_EQ(net::ERR_ABORTED, events[3].error_code);
|
||||
EXPECT_EQ(ERR_ABORTED, events[3].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[4].event_type);
|
||||
|
||||
// TODO(eroman): Add back NetLogTest here...
|
||||
@ -488,7 +488,7 @@ TEST_F(SocketStreamTest, BasicAuthProxyWithAuthCache) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
|
||||
events[0].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type);
|
||||
EXPECT_EQ(net::ERR_ABORTED, events[2].error_code);
|
||||
EXPECT_EQ(ERR_ABORTED, events[2].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[3].event_type);
|
||||
}
|
||||
|
||||
@ -545,7 +545,7 @@ TEST_F(SocketStreamTest, WSSBasicAuthProxyWithAuthCache) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
|
||||
events[0].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type);
|
||||
EXPECT_EQ(net::ERR_ABORTED, events[2].error_code);
|
||||
EXPECT_EQ(ERR_ABORTED, events[2].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[3].event_type);
|
||||
}
|
||||
|
||||
@ -594,11 +594,11 @@ TEST_F(SocketStreamTest, IOPending) {
|
||||
|
||||
socket_stream->Connect();
|
||||
io_test_callback_.WaitForResult();
|
||||
EXPECT_EQ(net::SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
|
||||
EXPECT_EQ(SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
|
||||
socket_stream->next_state_);
|
||||
delegate->CompleteConnection(net::OK);
|
||||
delegate->CompleteConnection(OK);
|
||||
|
||||
EXPECT_EQ(net::OK, test_callback.WaitForResult());
|
||||
EXPECT_EQ(OK, test_callback.WaitForResult());
|
||||
|
||||
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
|
||||
ASSERT_EQ(8U, events.size());
|
||||
@ -611,7 +611,7 @@ TEST_F(SocketStreamTest, IOPending) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[4].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[5].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[6].event_type);
|
||||
EXPECT_EQ(net::ERR_CONNECTION_CLOSED, events[6].error_code);
|
||||
EXPECT_EQ(ERR_CONNECTION_CLOSED, events[6].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[7].event_type);
|
||||
}
|
||||
|
||||
@ -632,7 +632,7 @@ TEST_F(SocketStreamTest, SwitchToSpdy) {
|
||||
|
||||
socket_stream->Connect();
|
||||
|
||||
EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
|
||||
EXPECT_EQ(ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
|
||||
|
||||
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
|
||||
ASSERT_EQ(2U, events.size());
|
||||
@ -640,7 +640,7 @@ TEST_F(SocketStreamTest, SwitchToSpdy) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
|
||||
events[0].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[1].event_type);
|
||||
EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, events[1].error_code);
|
||||
EXPECT_EQ(ERR_PROTOCOL_SWITCHED, events[1].error_code);
|
||||
}
|
||||
|
||||
TEST_F(SocketStreamTest, SwitchAfterPending) {
|
||||
@ -660,11 +660,11 @@ TEST_F(SocketStreamTest, SwitchAfterPending) {
|
||||
|
||||
socket_stream->Connect();
|
||||
io_test_callback_.WaitForResult();
|
||||
EXPECT_EQ(net::SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
|
||||
EXPECT_EQ(SocketStream::STATE_RESOLVE_PROTOCOL_COMPLETE,
|
||||
socket_stream->next_state_);
|
||||
delegate->CompleteConnection(net::ERR_PROTOCOL_SWITCHED);
|
||||
delegate->CompleteConnection(ERR_PROTOCOL_SWITCHED);
|
||||
|
||||
EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
|
||||
EXPECT_EQ(ERR_PROTOCOL_SWITCHED, test_callback.WaitForResult());
|
||||
|
||||
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
|
||||
ASSERT_EQ(2U, events.size());
|
||||
@ -672,7 +672,7 @@ TEST_F(SocketStreamTest, SwitchAfterPending) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
|
||||
events[0].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[1].event_type);
|
||||
EXPECT_EQ(net::ERR_PROTOCOL_SWITCHED, events[1].error_code);
|
||||
EXPECT_EQ(ERR_PROTOCOL_SWITCHED, events[1].error_code);
|
||||
}
|
||||
|
||||
// Test a connection though a secure proxy.
|
||||
@ -722,7 +722,7 @@ TEST_F(SocketStreamTest, SecureProxyConnectError) {
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
|
||||
events[0].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[1].event_type);
|
||||
EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, events[1].error_code);
|
||||
EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, events[1].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[2].event_type);
|
||||
}
|
||||
|
||||
@ -774,7 +774,7 @@ TEST_F(SocketStreamTest, SecureProxyConnect) {
|
||||
events[0].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[2].event_type);
|
||||
EXPECT_EQ(net::ERR_ABORTED, events[2].error_code);
|
||||
EXPECT_EQ(ERR_ABORTED, events[2].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[3].event_type);
|
||||
}
|
||||
|
||||
@ -802,7 +802,7 @@ TEST_F(SocketStreamTest, BeforeConnectFailed) {
|
||||
ASSERT_EQ(2U, events.size());
|
||||
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[0].event_type);
|
||||
EXPECT_EQ(net::ERR_ACCESS_DENIED, events[0].error_code);
|
||||
EXPECT_EQ(ERR_ACCESS_DENIED, events[0].error_code);
|
||||
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[1].event_type);
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,11 @@ const MockTransaction kGZip_Transaction = {
|
||||
|
||||
TEST(URLRequestJob, TransactionNotifiedWhenDone) {
|
||||
MockNetworkLayer network_layer;
|
||||
TestURLRequestContext context;
|
||||
net::TestURLRequestContext context;
|
||||
context.set_http_transaction_factory(&network_layer);
|
||||
|
||||
TestDelegate d;
|
||||
TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
|
||||
net::TestDelegate d;
|
||||
net::TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
|
||||
AddMockTransaction(&kGZip_Transaction);
|
||||
|
||||
req.set_method("GET");
|
||||
@ -59,11 +59,11 @@ TEST(URLRequestJob, TransactionNotifiedWhenDone) {
|
||||
|
||||
TEST(URLRequestJob, SyncTransactionNotifiedWhenDone) {
|
||||
MockNetworkLayer network_layer;
|
||||
TestURLRequestContext context;
|
||||
net::TestURLRequestContext context;
|
||||
context.set_http_transaction_factory(&network_layer);
|
||||
|
||||
TestDelegate d;
|
||||
TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
|
||||
net::TestDelegate d;
|
||||
net::TestURLRequest req(GURL(kGZip_Transaction.url), &d, &context);
|
||||
MockTransaction transaction(kGZip_Transaction);
|
||||
transaction.test_mode = TEST_MODE_SYNC_ALL;
|
||||
AddMockTransaction(&transaction);
|
||||
|
@ -20,9 +20,11 @@
|
||||
#include "net/url_request/url_request_job_factory_impl.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
// These constants put the net::NetworkDelegate events of TestNetworkDelegate
|
||||
// These constants put the NetworkDelegate events of TestNetworkDelegate
|
||||
// into an order. They are used in conjunction with
|
||||
// |TestNetworkDelegate::next_states_| to check that we do not send
|
||||
// events in the wrong order.
|
||||
@ -63,34 +65,34 @@ void TestURLRequestContext::Init() {
|
||||
|
||||
if (!host_resolver())
|
||||
context_storage_.set_host_resolver(
|
||||
scoped_ptr<net::HostResolver>(new net::MockCachingHostResolver()));
|
||||
scoped_ptr<HostResolver>(new MockCachingHostResolver()));
|
||||
if (!proxy_service())
|
||||
context_storage_.set_proxy_service(net::ProxyService::CreateDirect());
|
||||
context_storage_.set_proxy_service(ProxyService::CreateDirect());
|
||||
if (!cert_verifier())
|
||||
context_storage_.set_cert_verifier(net::CertVerifier::CreateDefault());
|
||||
context_storage_.set_cert_verifier(CertVerifier::CreateDefault());
|
||||
if (!ftp_transaction_factory()) {
|
||||
#if !defined(DISABLE_FTP_SUPPORT)
|
||||
context_storage_.set_ftp_transaction_factory(
|
||||
new net::FtpNetworkLayer(host_resolver()));
|
||||
new FtpNetworkLayer(host_resolver()));
|
||||
#else
|
||||
context_storage_.set_ftp_transaction_factory(NULL);
|
||||
#endif // !defined(DISABLE_FTP_SUPPORT)
|
||||
}
|
||||
if (!ssl_config_service())
|
||||
context_storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults);
|
||||
context_storage_.set_ssl_config_service(new SSLConfigServiceDefaults);
|
||||
if (!http_auth_handler_factory()) {
|
||||
context_storage_.set_http_auth_handler_factory(
|
||||
net::HttpAuthHandlerFactory::CreateDefault(host_resolver()));
|
||||
HttpAuthHandlerFactory::CreateDefault(host_resolver()));
|
||||
}
|
||||
if (!http_server_properties()) {
|
||||
context_storage_.set_http_server_properties(
|
||||
new net::HttpServerPropertiesImpl);
|
||||
new HttpServerPropertiesImpl);
|
||||
}
|
||||
if (!transport_security_state()) {
|
||||
context_storage_.set_transport_security_state(
|
||||
new net::TransportSecurityState());
|
||||
new TransportSecurityState());
|
||||
}
|
||||
net::HttpNetworkSession::Params params;
|
||||
HttpNetworkSession::Params params;
|
||||
params.host_resolver = host_resolver();
|
||||
params.cert_verifier = cert_verifier();
|
||||
params.proxy_service = proxy_service();
|
||||
@ -100,33 +102,33 @@ void TestURLRequestContext::Init() {
|
||||
params.http_server_properties = http_server_properties();
|
||||
|
||||
if (!http_transaction_factory()) {
|
||||
context_storage_.set_http_transaction_factory(new net::HttpCache(
|
||||
new net::HttpNetworkSession(params),
|
||||
net::HttpCache::DefaultBackend::InMemory(0)));
|
||||
context_storage_.set_http_transaction_factory(new HttpCache(
|
||||
new HttpNetworkSession(params),
|
||||
HttpCache::DefaultBackend::InMemory(0)));
|
||||
}
|
||||
// In-memory cookie store.
|
||||
if (!cookie_store())
|
||||
context_storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
|
||||
context_storage_.set_cookie_store(new CookieMonster(NULL, NULL));
|
||||
// In-memory origin bound cert service.
|
||||
if (!server_bound_cert_service()) {
|
||||
context_storage_.set_server_bound_cert_service(
|
||||
new net::ServerBoundCertService(
|
||||
new net::DefaultServerBoundCertStore(NULL),
|
||||
new ServerBoundCertService(
|
||||
new DefaultServerBoundCertStore(NULL),
|
||||
base::WorkerPool::GetTaskRunner(true)));
|
||||
}
|
||||
if (!http_user_agent_settings()) {
|
||||
context_storage_.set_http_user_agent_settings(
|
||||
new net::StaticHttpUserAgentSettings(
|
||||
new StaticHttpUserAgentSettings(
|
||||
"en-us,fr", "iso-8859-1,*,utf-8", EmptyString()));
|
||||
}
|
||||
if (!job_factory())
|
||||
context_storage_.set_job_factory(new net::URLRequestJobFactoryImpl);
|
||||
context_storage_.set_job_factory(new URLRequestJobFactoryImpl);
|
||||
}
|
||||
|
||||
TestURLRequest::TestURLRequest(const GURL& url,
|
||||
Delegate* delegate,
|
||||
TestURLRequestContext* context)
|
||||
: net::URLRequest(url, delegate, context) {
|
||||
: URLRequest(url, delegate, context) {
|
||||
}
|
||||
|
||||
TestURLRequest::~TestURLRequest() {
|
||||
@ -174,12 +176,12 @@ TestDelegate::TestDelegate()
|
||||
have_certificate_errors_(false),
|
||||
certificate_errors_are_fatal_(false),
|
||||
auth_required_(false),
|
||||
buf_(new net::IOBuffer(kBufferSize)) {
|
||||
buf_(new IOBuffer(kBufferSize)) {
|
||||
}
|
||||
|
||||
TestDelegate::~TestDelegate() {}
|
||||
|
||||
void TestDelegate::OnReceivedRedirect(net::URLRequest* request,
|
||||
void TestDelegate::OnReceivedRedirect(URLRequest* request,
|
||||
const GURL& new_url,
|
||||
bool* defer_redirect) {
|
||||
EXPECT_TRUE(request->is_redirecting());
|
||||
@ -192,8 +194,8 @@ void TestDelegate::OnReceivedRedirect(net::URLRequest* request,
|
||||
}
|
||||
}
|
||||
|
||||
void TestDelegate::OnAuthRequired(net::URLRequest* request,
|
||||
net::AuthChallengeInfo* auth_info) {
|
||||
void TestDelegate::OnAuthRequired(URLRequest* request,
|
||||
AuthChallengeInfo* auth_info) {
|
||||
auth_required_ = true;
|
||||
if (!credentials_.Empty()) {
|
||||
request->SetAuth(credentials_);
|
||||
@ -202,8 +204,8 @@ void TestDelegate::OnAuthRequired(net::URLRequest* request,
|
||||
}
|
||||
}
|
||||
|
||||
void TestDelegate::OnSSLCertificateError(net::URLRequest* request,
|
||||
const net::SSLInfo& ssl_info,
|
||||
void TestDelegate::OnSSLCertificateError(URLRequest* request,
|
||||
const SSLInfo& ssl_info,
|
||||
bool fatal) {
|
||||
// The caller can control whether it needs all SSL requests to go through,
|
||||
// independent of any possible errors, or whether it wants SSL errors to
|
||||
@ -216,7 +218,7 @@ void TestDelegate::OnSSLCertificateError(net::URLRequest* request,
|
||||
request->Cancel();
|
||||
}
|
||||
|
||||
void TestDelegate::OnResponseStarted(net::URLRequest* request) {
|
||||
void TestDelegate::OnResponseStarted(URLRequest* request) {
|
||||
// It doesn't make sense for the request to have IO pending at this point.
|
||||
DCHECK(!request->status().is_io_pending());
|
||||
EXPECT_FALSE(request->is_redirecting());
|
||||
@ -226,8 +228,8 @@ void TestDelegate::OnResponseStarted(net::URLRequest* request) {
|
||||
request->Cancel();
|
||||
OnResponseCompleted(request);
|
||||
} else if (!request->status().is_success()) {
|
||||
DCHECK(request->status().status() == net::URLRequestStatus::FAILED ||
|
||||
request->status().status() == net::URLRequestStatus::CANCELED);
|
||||
DCHECK(request->status().status() == URLRequestStatus::FAILED ||
|
||||
request->status().status() == URLRequestStatus::CANCELED);
|
||||
request_failed_ = true;
|
||||
OnResponseCompleted(request);
|
||||
} else {
|
||||
@ -240,7 +242,7 @@ void TestDelegate::OnResponseStarted(net::URLRequest* request) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestDelegate::OnReadCompleted(net::URLRequest* request, int bytes_read) {
|
||||
void TestDelegate::OnReadCompleted(URLRequest* request, int bytes_read) {
|
||||
// It doesn't make sense for the request to have IO pending at this point.
|
||||
DCHECK(!request->status().is_io_pending());
|
||||
|
||||
@ -276,7 +278,7 @@ void TestDelegate::OnReadCompleted(net::URLRequest* request, int bytes_read) {
|
||||
request->Cancel();
|
||||
}
|
||||
|
||||
void TestDelegate::OnResponseCompleted(net::URLRequest* request) {
|
||||
void TestDelegate::OnResponseCompleted(URLRequest* request) {
|
||||
if (quit_on_complete_)
|
||||
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
|
||||
}
|
||||
@ -309,8 +311,8 @@ void TestNetworkDelegate::InitRequestStatesIfNew(int request_id) {
|
||||
}
|
||||
|
||||
int TestNetworkDelegate::OnBeforeURLRequest(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
URLRequest* request,
|
||||
const CompletionCallback& callback,
|
||||
GURL* new_url ) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
@ -324,13 +326,13 @@ int TestNetworkDelegate::OnBeforeURLRequest(
|
||||
kStageCompletedError | // request canceled by delegate
|
||||
kStageAuthRequired; // Auth can come next for FTP requests
|
||||
created_requests_++;
|
||||
return net::OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int TestNetworkDelegate::OnBeforeSendHeaders(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
net::HttpRequestHeaders* headers) {
|
||||
URLRequest* request,
|
||||
const CompletionCallback& callback,
|
||||
HttpRequestHeaders* headers) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
event_order_[req_id] += "OnBeforeSendHeaders\n";
|
||||
@ -340,12 +342,12 @@ int TestNetworkDelegate::OnBeforeSendHeaders(
|
||||
kStageSendHeaders |
|
||||
kStageCompletedError; // request canceled by delegate
|
||||
|
||||
return net::OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void TestNetworkDelegate::OnSendHeaders(
|
||||
net::URLRequest* request,
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
URLRequest* request,
|
||||
const HttpRequestHeaders& headers) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
event_order_[req_id] += "OnSendHeaders\n";
|
||||
@ -357,10 +359,10 @@ void TestNetworkDelegate::OnSendHeaders(
|
||||
}
|
||||
|
||||
int TestNetworkDelegate::OnHeadersReceived(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
const net::HttpResponseHeaders* original_response_headers,
|
||||
scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
|
||||
URLRequest* request,
|
||||
const CompletionCallback& callback,
|
||||
const HttpResponseHeaders* original_response_headers,
|
||||
scoped_refptr<HttpResponseHeaders>* override_response_headers) {
|
||||
int req_id = request->identifier();
|
||||
event_order_[req_id] += "OnHeadersReceived\n";
|
||||
InitRequestStatesIfNew(req_id);
|
||||
@ -376,10 +378,10 @@ int TestNetworkDelegate::OnHeadersReceived(
|
||||
// layer before the URLRequest reports that a response has started.
|
||||
next_states_[req_id] |= kStageBeforeSendHeaders;
|
||||
|
||||
return net::OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void TestNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
|
||||
void TestNetworkDelegate::OnBeforeRedirect(URLRequest* request,
|
||||
const GURL& new_location) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
@ -397,24 +399,24 @@ void TestNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
|
||||
next_states_[req_id] |= kStageResponseStarted;
|
||||
}
|
||||
|
||||
void TestNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
|
||||
void TestNetworkDelegate::OnResponseStarted(URLRequest* request) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
event_order_[req_id] += "OnResponseStarted\n";
|
||||
EXPECT_TRUE(next_states_[req_id] & kStageResponseStarted) <<
|
||||
event_order_[req_id];
|
||||
next_states_[req_id] = kStageCompletedSuccess | kStageCompletedError;
|
||||
if (request->status().status() == net::URLRequestStatus::FAILED) {
|
||||
if (request->status().status() == URLRequestStatus::FAILED) {
|
||||
error_count_++;
|
||||
last_error_ = request->status().error();
|
||||
}
|
||||
}
|
||||
|
||||
void TestNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
|
||||
void TestNetworkDelegate::OnRawBytesRead(const URLRequest& request,
|
||||
int bytes_read) {
|
||||
}
|
||||
|
||||
void TestNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
|
||||
void TestNetworkDelegate::OnCompleted(URLRequest* request, bool started) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
event_order_[req_id] += "OnCompleted\n";
|
||||
@ -429,14 +431,13 @@ void TestNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
|
||||
event_order_[req_id];
|
||||
next_states_[req_id] = kStageURLRequestDestroyed;
|
||||
completed_requests_++;
|
||||
if (request->status().status() == net::URLRequestStatus::FAILED) {
|
||||
if (request->status().status() == URLRequestStatus::FAILED) {
|
||||
error_count_++;
|
||||
last_error_ = request->status().error();
|
||||
}
|
||||
}
|
||||
|
||||
void TestNetworkDelegate::OnURLRequestDestroyed(
|
||||
net::URLRequest* request) {
|
||||
void TestNetworkDelegate::OnURLRequestDestroyed(URLRequest* request) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
event_order_[req_id] += "OnURLRequestDestroyed\n";
|
||||
@ -450,11 +451,11 @@ void TestNetworkDelegate::OnPACScriptError(int line_number,
|
||||
const string16& error) {
|
||||
}
|
||||
|
||||
net::NetworkDelegate::AuthRequiredResponse TestNetworkDelegate::OnAuthRequired(
|
||||
net::URLRequest* request,
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
NetworkDelegate::AuthRequiredResponse TestNetworkDelegate::OnAuthRequired(
|
||||
URLRequest* request,
|
||||
const AuthChallengeInfo& auth_info,
|
||||
const AuthCallback& callback,
|
||||
net::AuthCredentials* credentials) {
|
||||
AuthCredentials* credentials) {
|
||||
int req_id = request->identifier();
|
||||
InitRequestStatesIfNew(req_id);
|
||||
event_order_[req_id] += "OnAuthRequired\n";
|
||||
@ -466,11 +467,11 @@ net::NetworkDelegate::AuthRequiredResponse TestNetworkDelegate::OnAuthRequired(
|
||||
kStageResponseStarted | // data: URLs do not trigger sending headers
|
||||
kStageBeforeRedirect | // a delegate can trigger a redirection
|
||||
kStageCompletedError; // request cancelled before callback
|
||||
return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
|
||||
return NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
|
||||
}
|
||||
|
||||
bool TestNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
|
||||
const net::CookieList& cookie_list) {
|
||||
bool TestNetworkDelegate::OnCanGetCookies(const URLRequest& request,
|
||||
const CookieList& cookie_list) {
|
||||
bool allow = true;
|
||||
if (cookie_options_bit_mask_ & NO_GET_COOKIES)
|
||||
allow = false;
|
||||
@ -482,9 +483,9 @@ bool TestNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
|
||||
return allow;
|
||||
}
|
||||
|
||||
bool TestNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
|
||||
bool TestNetworkDelegate::OnCanSetCookie(const URLRequest& request,
|
||||
const std::string& cookie_line,
|
||||
net::CookieOptions* options) {
|
||||
CookieOptions* options) {
|
||||
bool allow = true;
|
||||
if (cookie_options_bit_mask_ & NO_SET_COOKIE)
|
||||
allow = false;
|
||||
@ -498,24 +499,24 @@ bool TestNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
|
||||
return allow;
|
||||
}
|
||||
|
||||
bool TestNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
|
||||
bool TestNetworkDelegate::OnCanAccessFile(const URLRequest& request,
|
||||
const FilePath& path) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TestNetworkDelegate::OnCanThrottleRequest(
|
||||
const net::URLRequest& request) const {
|
||||
const URLRequest& request) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int TestNetworkDelegate::OnBeforeSocketStreamConnect(
|
||||
net::SocketStream* socket,
|
||||
const net::CompletionCallback& callback) {
|
||||
return net::OK;
|
||||
SocketStream* socket,
|
||||
const CompletionCallback& callback) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void TestNetworkDelegate::OnRequestWaitStateChange(
|
||||
const net::URLRequest& request,
|
||||
const URLRequest& request,
|
||||
RequestWaitState state) {
|
||||
}
|
||||
|
||||
@ -542,27 +543,29 @@ const std::string& ScopedCustomUrlRequestTestHttpHost::value() {
|
||||
TestJobInterceptor::TestJobInterceptor() : main_intercept_job_(NULL) {
|
||||
}
|
||||
|
||||
net::URLRequestJob* TestJobInterceptor::MaybeIntercept(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const {
|
||||
net::URLRequestJob* job = main_intercept_job_;
|
||||
URLRequestJob* TestJobInterceptor::MaybeIntercept(
|
||||
URLRequest* request,
|
||||
NetworkDelegate* network_delegate) const {
|
||||
URLRequestJob* job = main_intercept_job_;
|
||||
main_intercept_job_ = NULL;
|
||||
return job;
|
||||
}
|
||||
|
||||
net::URLRequestJob* TestJobInterceptor::MaybeInterceptRedirect(
|
||||
URLRequestJob* TestJobInterceptor::MaybeInterceptRedirect(
|
||||
const GURL& location,
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const {
|
||||
URLRequest* request,
|
||||
NetworkDelegate* network_delegate) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
net::URLRequestJob* TestJobInterceptor::MaybeInterceptResponse(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const {
|
||||
URLRequestJob* TestJobInterceptor::MaybeInterceptResponse(
|
||||
URLRequest* request,
|
||||
NetworkDelegate* network_delegate) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TestJobInterceptor::set_main_intercept_job(net::URLRequestJob* job) {
|
||||
void TestJobInterceptor::set_main_intercept_job(URLRequestJob* job) {
|
||||
main_intercept_job_ = job;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
@ -41,9 +41,11 @@
|
||||
|
||||
using base::TimeDelta;
|
||||
|
||||
namespace net {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class TestURLRequestContext : public net::URLRequestContext {
|
||||
class TestURLRequestContext : public URLRequestContext {
|
||||
public:
|
||||
TestURLRequestContext();
|
||||
// Default constructor like TestURLRequestContext() but does not call
|
||||
@ -59,14 +61,14 @@ class TestURLRequestContext : public net::URLRequestContext {
|
||||
bool initialized_;
|
||||
|
||||
protected:
|
||||
net::URLRequestContextStorage context_storage_;
|
||||
URLRequestContextStorage context_storage_;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Used to return a dummy context, which lives on the message loop
|
||||
// given in the constructor.
|
||||
class TestURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
class TestURLRequestContextGetter : public URLRequestContextGetter {
|
||||
public:
|
||||
// |network_task_runner| must not be NULL.
|
||||
explicit TestURLRequestContextGetter(
|
||||
@ -77,7 +79,7 @@ class TestURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner,
|
||||
scoped_ptr<TestURLRequestContext> context);
|
||||
|
||||
// net::URLRequestContextGetter implementation.
|
||||
// URLRequestContextGetter implementation.
|
||||
virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE;
|
||||
virtual scoped_refptr<base::SingleThreadTaskRunner>
|
||||
GetNetworkTaskRunner() const OVERRIDE;
|
||||
@ -92,7 +94,7 @@ class TestURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class TestURLRequest : public net::URLRequest {
|
||||
class TestURLRequest : public URLRequest {
|
||||
public:
|
||||
TestURLRequest(
|
||||
const GURL& url, Delegate* delegate, TestURLRequestContext* context);
|
||||
@ -101,7 +103,7 @@ class TestURLRequest : public net::URLRequest {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class TestDelegate : public net::URLRequest::Delegate {
|
||||
class TestDelegate : public URLRequest::Delegate {
|
||||
public:
|
||||
TestDelegate();
|
||||
virtual ~TestDelegate();
|
||||
@ -117,7 +119,7 @@ class TestDelegate : public net::URLRequest::Delegate {
|
||||
void set_allow_certificate_errors(bool val) {
|
||||
allow_certificate_errors_ = val;
|
||||
}
|
||||
void set_credentials(const net::AuthCredentials& credentials) {
|
||||
void set_credentials(const AuthCredentials& credentials) {
|
||||
credentials_ = credentials;
|
||||
}
|
||||
|
||||
@ -136,25 +138,25 @@ class TestDelegate : public net::URLRequest::Delegate {
|
||||
}
|
||||
bool auth_required_called() const { return auth_required_; }
|
||||
|
||||
// net::URLRequest::Delegate:
|
||||
virtual void OnReceivedRedirect(net::URLRequest* request, const GURL& new_url,
|
||||
// URLRequest::Delegate:
|
||||
virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url,
|
||||
bool* defer_redirect) OVERRIDE;
|
||||
virtual void OnAuthRequired(net::URLRequest* request,
|
||||
net::AuthChallengeInfo* auth_info) OVERRIDE;
|
||||
virtual void OnAuthRequired(URLRequest* request,
|
||||
AuthChallengeInfo* auth_info) OVERRIDE;
|
||||
// NOTE: |fatal| causes |certificate_errors_are_fatal_| to be set to true.
|
||||
// (Unit tests use this as a post-condition.) But for policy, this method
|
||||
// consults |allow_certificate_errors_|.
|
||||
virtual void OnSSLCertificateError(net::URLRequest* request,
|
||||
const net::SSLInfo& ssl_info,
|
||||
virtual void OnSSLCertificateError(URLRequest* request,
|
||||
const SSLInfo& ssl_info,
|
||||
bool fatal) OVERRIDE;
|
||||
virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
|
||||
virtual void OnReadCompleted(net::URLRequest* request,
|
||||
virtual void OnResponseStarted(URLRequest* request) OVERRIDE;
|
||||
virtual void OnReadCompleted(URLRequest* request,
|
||||
int bytes_read) OVERRIDE;
|
||||
|
||||
private:
|
||||
static const int kBufferSize = 4096;
|
||||
|
||||
virtual void OnResponseCompleted(net::URLRequest* request);
|
||||
virtual void OnResponseCompleted(URLRequest* request);
|
||||
|
||||
// options for controlling behavior
|
||||
bool cancel_in_rr_;
|
||||
@ -164,7 +166,7 @@ class TestDelegate : public net::URLRequest::Delegate {
|
||||
bool quit_on_complete_;
|
||||
bool quit_on_redirect_;
|
||||
bool allow_certificate_errors_;
|
||||
net::AuthCredentials credentials_;
|
||||
AuthCredentials credentials_;
|
||||
|
||||
// tracks status of callbacks
|
||||
int response_started_count_;
|
||||
@ -178,12 +180,12 @@ class TestDelegate : public net::URLRequest::Delegate {
|
||||
std::string data_received_;
|
||||
|
||||
// our read buffer
|
||||
scoped_refptr<net::IOBuffer> buf_;
|
||||
scoped_refptr<IOBuffer> buf_;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class TestNetworkDelegate : public net::NetworkDelegate {
|
||||
class TestNetworkDelegate : public NetworkDelegate {
|
||||
public:
|
||||
enum Options {
|
||||
NO_GET_COOKIES = 1 << 0,
|
||||
@ -205,48 +207,47 @@ class TestNetworkDelegate : public net::NetworkDelegate {
|
||||
int set_cookie_count() const { return set_cookie_count_; }
|
||||
|
||||
protected:
|
||||
// net::NetworkDelegate:
|
||||
virtual int OnBeforeURLRequest(net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
// NetworkDelegate:
|
||||
virtual int OnBeforeURLRequest(URLRequest* request,
|
||||
const CompletionCallback& callback,
|
||||
GURL* new_url) OVERRIDE;
|
||||
virtual int OnBeforeSendHeaders(net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
net::HttpRequestHeaders* headers) OVERRIDE;
|
||||
virtual void OnSendHeaders(net::URLRequest* request,
|
||||
const net::HttpRequestHeaders& headers) OVERRIDE;
|
||||
virtual int OnBeforeSendHeaders(URLRequest* request,
|
||||
const CompletionCallback& callback,
|
||||
HttpRequestHeaders* headers) OVERRIDE;
|
||||
virtual void OnSendHeaders(URLRequest* request,
|
||||
const HttpRequestHeaders& headers) OVERRIDE;
|
||||
virtual int OnHeadersReceived(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
const net::HttpResponseHeaders* original_response_headers,
|
||||
scoped_refptr<net::HttpResponseHeaders>* override_response_headers)
|
||||
OVERRIDE;
|
||||
virtual void OnBeforeRedirect(net::URLRequest* request,
|
||||
URLRequest* request,
|
||||
const CompletionCallback& callback,
|
||||
const HttpResponseHeaders* original_response_headers,
|
||||
scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE;
|
||||
virtual void OnBeforeRedirect(URLRequest* request,
|
||||
const GURL& new_location) OVERRIDE;
|
||||
virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
|
||||
virtual void OnRawBytesRead(const net::URLRequest& request,
|
||||
virtual void OnResponseStarted(URLRequest* request) OVERRIDE;
|
||||
virtual void OnRawBytesRead(const URLRequest& request,
|
||||
int bytes_read) OVERRIDE;
|
||||
virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE;
|
||||
virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
|
||||
virtual void OnCompleted(URLRequest* request, bool started) OVERRIDE;
|
||||
virtual void OnURLRequestDestroyed(URLRequest* request) OVERRIDE;
|
||||
virtual void OnPACScriptError(int line_number,
|
||||
const string16& error) OVERRIDE;
|
||||
virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
|
||||
net::URLRequest* request,
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired(
|
||||
URLRequest* request,
|
||||
const AuthChallengeInfo& auth_info,
|
||||
const AuthCallback& callback,
|
||||
net::AuthCredentials* credentials) OVERRIDE;
|
||||
virtual bool OnCanGetCookies(const net::URLRequest& request,
|
||||
const net::CookieList& cookie_list) OVERRIDE;
|
||||
virtual bool OnCanSetCookie(const net::URLRequest& request,
|
||||
AuthCredentials* credentials) OVERRIDE;
|
||||
virtual bool OnCanGetCookies(const URLRequest& request,
|
||||
const CookieList& cookie_list) OVERRIDE;
|
||||
virtual bool OnCanSetCookie(const URLRequest& request,
|
||||
const std::string& cookie_line,
|
||||
net::CookieOptions* options) OVERRIDE;
|
||||
virtual bool OnCanAccessFile(const net::URLRequest& request,
|
||||
CookieOptions* options) OVERRIDE;
|
||||
virtual bool OnCanAccessFile(const URLRequest& request,
|
||||
const FilePath& path) const OVERRIDE;
|
||||
virtual bool OnCanThrottleRequest(
|
||||
const net::URLRequest& request) const OVERRIDE;
|
||||
const URLRequest& request) const OVERRIDE;
|
||||
virtual int OnBeforeSocketStreamConnect(
|
||||
net::SocketStream* stream,
|
||||
const net::CompletionCallback& callback) OVERRIDE;
|
||||
virtual void OnRequestWaitStateChange(const net::URLRequest& request,
|
||||
SocketStream* stream,
|
||||
const CompletionCallback& callback) OVERRIDE;
|
||||
virtual void OnRequestWaitStateChange(const URLRequest& request,
|
||||
RequestWaitState state) OVERRIDE;
|
||||
|
||||
void InitRequestStatesIfNew(int request_id);
|
||||
@ -261,7 +262,7 @@ class TestNetworkDelegate : public net::NetworkDelegate {
|
||||
int blocked_set_cookie_count_;
|
||||
int set_cookie_count_;
|
||||
|
||||
// net::NetworkDelegate callbacks happen in a particular order (e.g.
|
||||
// NetworkDelegate callbacks happen in a particular order (e.g.
|
||||
// OnBeforeURLRequest is always called before OnBeforeSendHeaders).
|
||||
// This bit-set indicates for each request id (key) what events may be sent
|
||||
// next.
|
||||
@ -300,24 +301,26 @@ class ScopedCustomUrlRequestTestHttpHost {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// A simple Interceptor that returns a pre-built URLRequestJob only once.
|
||||
class TestJobInterceptor : public net::URLRequestJobFactory::Interceptor {
|
||||
class TestJobInterceptor : public URLRequestJobFactory::Interceptor {
|
||||
public:
|
||||
TestJobInterceptor();
|
||||
|
||||
virtual net::URLRequestJob* MaybeIntercept(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const OVERRIDE;
|
||||
virtual net::URLRequestJob* MaybeInterceptRedirect(
|
||||
virtual URLRequestJob* MaybeIntercept(
|
||||
URLRequest* request,
|
||||
NetworkDelegate* network_delegate) const OVERRIDE;
|
||||
virtual URLRequestJob* MaybeInterceptRedirect(
|
||||
const GURL& location,
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const OVERRIDE;
|
||||
virtual net::URLRequestJob* MaybeInterceptResponse(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const OVERRIDE;
|
||||
void set_main_intercept_job(net::URLRequestJob* job);
|
||||
URLRequest* request,
|
||||
NetworkDelegate* network_delegate) const OVERRIDE;
|
||||
virtual URLRequestJob* MaybeInterceptResponse(
|
||||
URLRequest* request,
|
||||
NetworkDelegate* network_delegate) const OVERRIDE;
|
||||
void set_main_intercept_job(URLRequestJob* job);
|
||||
|
||||
private:
|
||||
mutable net::URLRequestJob* main_intercept_job_;
|
||||
mutable URLRequestJob* main_intercept_job_;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
||||
#endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
|
||||
|
@ -432,8 +432,8 @@ TEST_F(RlzLibTest, SendFinancialPing) {
|
||||
base::Thread io_thread("rlz_unittest_io_thread");
|
||||
ASSERT_TRUE(io_thread.StartWithOptions(options));
|
||||
|
||||
scoped_refptr<TestURLRequestContextGetter> context =
|
||||
new TestURLRequestContextGetter(
|
||||
scoped_refptr<net::TestURLRequestContextGetter> context =
|
||||
new net::TestURLRequestContextGetter(
|
||||
io_thread.message_loop()->message_loop_proxy());
|
||||
rlz_lib::SetURLRequestContext(context.get());
|
||||
|
||||
|
@ -48,7 +48,7 @@ class SyncHttpBridgeTest : public testing::Test {
|
||||
HttpBridge* BuildBridge() {
|
||||
if (!fake_default_request_context_getter_) {
|
||||
fake_default_request_context_getter_ =
|
||||
new TestURLRequestContextGetter(io_thread_.message_loop_proxy());
|
||||
new net::TestURLRequestContextGetter(io_thread_.message_loop_proxy());
|
||||
fake_default_request_context_getter_->AddRef();
|
||||
}
|
||||
HttpBridge* bridge = new HttpBridge(
|
||||
@ -86,7 +86,7 @@ class SyncHttpBridgeTest : public testing::Test {
|
||||
}
|
||||
|
||||
// Note this is lazy created, so don't call this before your bridge.
|
||||
TestURLRequestContextGetter* GetTestRequestContextGetter() {
|
||||
net::TestURLRequestContextGetter* GetTestRequestContextGetter() {
|
||||
return fake_default_request_context_getter_;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ class SyncHttpBridgeTest : public testing::Test {
|
||||
private:
|
||||
// A make-believe "default" request context, as would be returned by
|
||||
// Profile::GetDefaultRequestContext(). Created lazily by BuildBridge.
|
||||
TestURLRequestContextGetter* fake_default_request_context_getter_;
|
||||
net::TestURLRequestContextGetter* fake_default_request_context_getter_;
|
||||
|
||||
HttpBridge* bridge_for_race_test_;
|
||||
|
||||
@ -157,7 +157,7 @@ void SyncHttpBridgeTest::RunSyncThreadBridgeUseTest(
|
||||
base::WaitableEvent* signal_when_created,
|
||||
base::WaitableEvent* signal_when_released) {
|
||||
scoped_refptr<net::URLRequestContextGetter> ctx_getter(
|
||||
new TestURLRequestContextGetter(io_thread_.message_loop_proxy()));
|
||||
new net::TestURLRequestContextGetter(io_thread_.message_loop_proxy()));
|
||||
{
|
||||
scoped_refptr<ShuntedHttpBridge> bridge(new ShuntedHttpBridge(
|
||||
ctx_getter, this, true));
|
||||
@ -187,7 +187,7 @@ TEST_F(SyncHttpBridgeTest, TestUsesSameHttpNetworkSession) {
|
||||
// Test the HttpBridge without actually making any network requests.
|
||||
TEST_F(SyncHttpBridgeTest, TestMakeSynchronousPostShunted) {
|
||||
scoped_refptr<net::URLRequestContextGetter> ctx_getter(
|
||||
new TestURLRequestContextGetter(io_thread()->message_loop_proxy()));
|
||||
new net::TestURLRequestContextGetter(io_thread()->message_loop_proxy()));
|
||||
scoped_refptr<HttpBridge> http_bridge(new ShuntedHttpBridge(
|
||||
ctx_getter, this, false));
|
||||
http_bridge->SetURL("http://www.google.com", 9999);
|
||||
@ -309,7 +309,7 @@ TEST_F(SyncHttpBridgeTest, TestResponseHeader) {
|
||||
|
||||
TEST_F(SyncHttpBridgeTest, Abort) {
|
||||
scoped_refptr<net::URLRequestContextGetter> ctx_getter(
|
||||
new TestURLRequestContextGetter(io_thread()->message_loop_proxy()));
|
||||
new net::TestURLRequestContextGetter(io_thread()->message_loop_proxy()));
|
||||
scoped_refptr<ShuntedHttpBridge> http_bridge(new ShuntedHttpBridge(
|
||||
ctx_getter, this, true));
|
||||
http_bridge->SetURL("http://www.google.com", 9999);
|
||||
@ -328,7 +328,7 @@ TEST_F(SyncHttpBridgeTest, Abort) {
|
||||
|
||||
TEST_F(SyncHttpBridgeTest, AbortLate) {
|
||||
scoped_refptr<net::URLRequestContextGetter> ctx_getter(
|
||||
new TestURLRequestContextGetter(io_thread()->message_loop_proxy()));
|
||||
new net::TestURLRequestContextGetter(io_thread()->message_loop_proxy()));
|
||||
scoped_refptr<ShuntedHttpBridge> http_bridge(new ShuntedHttpBridge(
|
||||
ctx_getter, this, false));
|
||||
http_bridge->SetURL("http://www.google.com", 9999);
|
||||
|
@ -28,7 +28,8 @@ class InvalidatorFactoryTest : public testing::Test {
|
||||
|
||||
virtual void SetUp() OVERRIDE {
|
||||
notifier_options_.request_context_getter =
|
||||
new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
|
||||
new net::TestURLRequestContextGetter(
|
||||
message_loop_.message_loop_proxy());
|
||||
}
|
||||
|
||||
virtual void TearDown() OVERRIDE {
|
||||
|
@ -43,7 +43,7 @@ class NonBlockingInvalidatorTestDelegate {
|
||||
options.message_loop_type = MessageLoop::TYPE_IO;
|
||||
io_thread_.StartWithOptions(options);
|
||||
request_context_getter_ =
|
||||
new TestURLRequestContextGetter(io_thread_.message_loop_proxy());
|
||||
new net::TestURLRequestContextGetter(io_thread_.message_loop_proxy());
|
||||
notifier::NotifierOptions invalidator_options;
|
||||
invalidator_options.request_context_getter = request_context_getter_;
|
||||
invalidator_.reset(
|
||||
|
@ -101,7 +101,7 @@ class NullInvalidationStateTracker
|
||||
};
|
||||
|
||||
// Needed to use a real host resolver.
|
||||
class MyTestURLRequestContext : public TestURLRequestContext {
|
||||
class MyTestURLRequestContext : public net::TestURLRequestContext {
|
||||
public:
|
||||
MyTestURLRequestContext() : TestURLRequestContext(true) {
|
||||
context_storage_.set_host_resolver(
|
||||
@ -114,13 +114,13 @@ class MyTestURLRequestContext : public TestURLRequestContext {
|
||||
virtual ~MyTestURLRequestContext() {}
|
||||
};
|
||||
|
||||
class MyTestURLRequestContextGetter : public TestURLRequestContextGetter {
|
||||
class MyTestURLRequestContextGetter : public net::TestURLRequestContextGetter {
|
||||
public:
|
||||
explicit MyTestURLRequestContextGetter(
|
||||
const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy)
|
||||
: TestURLRequestContextGetter(io_message_loop_proxy) {}
|
||||
|
||||
virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE {
|
||||
virtual net::TestURLRequestContext* GetURLRequestContext() OVERRIDE {
|
||||
// Construct |context_| lazily so it gets constructed on the right
|
||||
// thread (the IO thread).
|
||||
if (!context_.get())
|
||||
|
@ -114,7 +114,7 @@ class NullInvalidationStateTracker
|
||||
};
|
||||
|
||||
// Needed to use a real host resolver.
|
||||
class MyTestURLRequestContext : public TestURLRequestContext {
|
||||
class MyTestURLRequestContext : public net::TestURLRequestContext {
|
||||
public:
|
||||
MyTestURLRequestContext() : TestURLRequestContext(true) {
|
||||
context_storage_.set_host_resolver(
|
||||
@ -127,13 +127,13 @@ class MyTestURLRequestContext : public TestURLRequestContext {
|
||||
virtual ~MyTestURLRequestContext() {}
|
||||
};
|
||||
|
||||
class MyTestURLRequestContextGetter : public TestURLRequestContextGetter {
|
||||
class MyTestURLRequestContextGetter : public net::TestURLRequestContextGetter {
|
||||
public:
|
||||
explicit MyTestURLRequestContextGetter(
|
||||
const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy)
|
||||
: TestURLRequestContextGetter(io_message_loop_proxy) {}
|
||||
|
||||
virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE {
|
||||
virtual net::TestURLRequestContext* GetURLRequestContext() OVERRIDE {
|
||||
// Construct |context_| lazily so it gets constructed on the right
|
||||
// thread (the IO thread).
|
||||
if (!context_.get())
|
||||
|
@ -564,7 +564,7 @@ class IOThread : public base::Thread {
|
||||
job_factory_.reset(new net::URLRequestJobFactoryImpl);
|
||||
job_factory_->SetProtocolHandler("http", new MockHttpServerJobFactory);
|
||||
job_factory_->SetProtocolHandler("https", new MockHttpServerJobFactory);
|
||||
request_context_.reset(new TestURLRequestContext());
|
||||
request_context_.reset(new net::TestURLRequestContext());
|
||||
request_context_->set_job_factory(job_factory_.get());
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test {
|
||||
}
|
||||
|
||||
void TestRequestHelper(const GURL& url, bool run_to_completion) {
|
||||
delegate_.reset(new TestDelegate());
|
||||
delegate_.reset(new net::TestDelegate());
|
||||
delegate_->set_quit_on_redirect(true);
|
||||
request_.reset(empty_context_.CreateRequest(url, delegate_.get()));
|
||||
job_ = new FileSystemDirURLRequestJob(
|
||||
@ -214,7 +214,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test {
|
||||
|
||||
ScopedTempDir temp_dir_;
|
||||
net::URLRequestContext empty_context_;
|
||||
scoped_ptr<TestDelegate> delegate_;
|
||||
scoped_ptr<net::TestDelegate> delegate_;
|
||||
scoped_ptr<net::URLRequest> request_;
|
||||
scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
|
||||
scoped_refptr<FileSystemContext> file_system_context_;
|
||||
|
@ -97,7 +97,7 @@ class FileSystemURLRequestJobTest : public testing::Test {
|
||||
void TestRequestHelper(const GURL& url,
|
||||
const net::HttpRequestHeaders* headers,
|
||||
bool run_to_completion) {
|
||||
delegate_.reset(new TestDelegate());
|
||||
delegate_.reset(new net::TestDelegate());
|
||||
// Make delegate_ exit the MessageLoop when the request is done.
|
||||
delegate_->set_quit_on_complete(true);
|
||||
delegate_->set_quit_on_redirect(true);
|
||||
@ -205,7 +205,7 @@ class FileSystemURLRequestJobTest : public testing::Test {
|
||||
net::URLRequestContext empty_context_;
|
||||
|
||||
// NOTE: order matters, request must die before delegate
|
||||
scoped_ptr<TestDelegate> delegate_;
|
||||
scoped_ptr<net::TestDelegate> delegate_;
|
||||
scoped_ptr<net::URLRequest> request_;
|
||||
|
||||
scoped_refptr<net::URLRequestJob> pending_job_;
|
||||
|
Reference in New Issue
Block a user