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

Unified Diff: trunk/src/net/url_request/url_request_unittest.cc

Issue 12605011: Revert 188912 "Removed static factories for data, ftp, file, and..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 9 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
Index: trunk/src/net/url_request/url_request_unittest.cc
===================================================================
--- trunk/src/net/url_request/url_request_unittest.cc (revision 188924)
+++ trunk/src/net/url_request/url_request_unittest.cc (working copy)
@@ -58,8 +58,6 @@
#include "net/socket/ssl_client_socket.h"
#include "net/ssl/ssl_connection_status_flags.h"
#include "net/test/test_server.h"
-#include "net/url_request/data_protocol_handler.h"
-#include "net/url_request/file_protocol_handler.h"
#include "net/url_request/ftp_protocol_handler.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request.h"
@@ -516,9 +514,6 @@
URLRequestTest() : default_context_(true) {
default_context_.set_network_delegate(&default_network_delegate_);
default_context_.set_net_log(&net_log_);
- job_factory_.SetProtocolHandler("data", new DataProtocolHandler);
- job_factory_.SetProtocolHandler("file", new FileProtocolHandler);
- default_context_.set_job_factory(&job_factory_);
default_context_.Init();
}
virtual ~URLRequestTest() {}
@@ -526,14 +521,16 @@
// Adds the TestJobInterceptor to the default context.
TestJobInterceptor* AddTestInterceptor() {
TestJobInterceptor* protocol_handler_ = new TestJobInterceptor();
- job_factory_.SetProtocolHandler("http", protocol_handler_);
+ job_factory_.reset(new URLRequestJobFactoryImpl);
+ job_factory_->SetProtocolHandler("http", protocol_handler_);
+ default_context_.set_job_factory(job_factory_.get());
return protocol_handler_;
}
protected:
CapturingNetLog net_log_;
TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest.
- URLRequestJobFactoryImpl job_factory_;
+ scoped_ptr<URLRequestJobFactoryImpl> job_factory_;
TestURLRequestContext default_context_;
};
@@ -3467,20 +3464,6 @@
req.Cancel();
}
-TEST_F(URLRequestTestHTTP, ProtocolHandlerAndFactoryRestrictRedirects) {
- // Test URLRequestJobFactory::ProtocolHandler::IsSafeRedirectTarget().
- GURL file_url("file:///foo.txt");
- GURL data_url("data:,foo");
- FileProtocolHandler file_protocol_handler;
- EXPECT_FALSE(file_protocol_handler.IsSafeRedirectTarget(file_url));
- DataProtocolHandler data_protocol_handler;
- EXPECT_TRUE(data_protocol_handler.IsSafeRedirectTarget(data_url));
-
- // Test URLRequestJobFactoryImpl::IsSafeRedirectTarget().
- EXPECT_FALSE(job_factory_.IsSafeRedirectTarget(file_url));
- EXPECT_TRUE(job_factory_.IsSafeRedirectTarget(data_url));
-}
-
TEST_F(URLRequestTestHTTP, RestrictRedirects) {
ASSERT_TRUE(test_server_.Start());
@@ -5000,12 +4983,15 @@
ASSERT_TRUE(test_server_.Start());
URLRequestJobFactoryImpl job_factory;
- FtpNetworkLayer ftp_transaction_factory(default_context_.host_resolver());
GURL url("ftp://127.0.0.1:7");
+ FtpProtocolHandler ftp_protocol_handler(
+ default_context_.ftp_transaction_factory(),
+ default_context_.ftp_auth_cache());
job_factory.SetProtocolHandler(
"ftp",
- new FtpProtocolHandler(&ftp_transaction_factory));
+ new FtpProtocolHandler(default_context_.ftp_transaction_factory(),
+ default_context_.ftp_auth_cache()));
default_context_.set_job_factory(&job_factory);
TestDelegate d;
« no previous file with comments | « trunk/src/net/url_request/url_request_test_util.cc ('k') | trunk/src/webkit/tools/test_shell/test_shell_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698