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

Unified Diff: net/url_request/url_request_ftp_job.cc

Issue 10537056: Replaced static URLRequestFtpJob factory with non-static protocol handler for FTP jobs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merged with latest sync Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_ftp_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_ftp_job.cc
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc
index aca1b484d93cd7a914019d9d4d3a53310f463f55..b0a3b43c4245f1cf033a430b3b9266ec1fe22cc5 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -19,10 +19,18 @@
namespace net {
-URLRequestFtpJob::URLRequestFtpJob(URLRequest* request)
- : URLRequestJob(request, request->context()->network_delegate()),
+URLRequestFtpJob::URLRequestFtpJob(
+ URLRequest* request,
+ NetworkDelegate* network_delegate,
+ FtpTransactionFactory* ftp_transaction_factory,
+ FtpAuthCache* ftp_auth_cache)
+ : URLRequestJob(request, network_delegate),
read_in_progress_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
+ ftp_transaction_factory_(ftp_transaction_factory),
+ ftp_auth_cache_(ftp_auth_cache) {
+ DCHECK(ftp_transaction_factory);
+ DCHECK(ftp_auth_cache);
}
// static
@@ -32,12 +40,14 @@ URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
int port = request->url().IntPort();
if (request->url().has_port() &&
- !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port))
+ !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) {
return new URLRequestErrorJob(request, ERR_UNSAFE_PORT);
+ }
- DCHECK(request->context());
- DCHECK(request->context()->ftp_transaction_factory());
- return new URLRequestFtpJob(request);
+ return new URLRequestFtpJob(request,
+ request->context()->network_delegate(),
+ request->context()->ftp_transaction_factory(),
+ request->context()->ftp_auth_cache());
}
bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const {
@@ -61,11 +71,8 @@ URLRequestFtpJob::~URLRequestFtpJob() {
void URLRequestFtpJob::StartTransaction() {
// Create a transaction.
DCHECK(!transaction_.get());
- DCHECK(request_->context());
- DCHECK(request_->context()->ftp_transaction_factory());
- transaction_.reset(
- request_->context()->ftp_transaction_factory()->CreateTransaction());
+ transaction_.reset(ftp_transaction_factory_->CreateTransaction());
// No matter what, we want to report our status as IO pending since we will
// be notifying our consumer asynchronously via OnStartCompleted.
@@ -104,16 +111,13 @@ void URLRequestFtpJob::OnStartCompleted(int result) {
} else if (transaction_->GetResponseInfo()->needs_auth) {
GURL origin = request_->url().GetOrigin();
if (server_auth_ && server_auth_->state == AUTH_STATE_HAVE_AUTH) {
- request_->context()->ftp_auth_cache()->Remove(
- origin, server_auth_->credentials);
+ ftp_auth_cache_->Remove(origin, server_auth_->credentials);
} else if (!server_auth_) {
server_auth_ = new AuthData();
}
server_auth_->state = AUTH_STATE_NEED_AUTH;
- FtpAuthCache::Entry* cached_auth =
- request_->context()->ftp_auth_cache()->Lookup(origin);
-
+ FtpAuthCache::Entry* cached_auth = ftp_auth_cache_->Lookup(origin);
if (cached_auth) {
// Retry using cached auth data.
SetAuth(cached_auth->credentials);
@@ -204,8 +208,7 @@ void URLRequestFtpJob::SetAuth(const AuthCredentials& credentials) {
server_auth_->state = AUTH_STATE_HAVE_AUTH;
server_auth_->credentials = credentials;
- request_->context()->ftp_auth_cache()->Add(request_->url().GetOrigin(),
- server_auth_->credentials);
+ ftp_auth_cache_->Add(request_->url().GetOrigin(), server_auth_->credentials);
RestartTransactionWithAuth();
}
« no previous file with comments | « net/url_request/url_request_ftp_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698