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

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: Removed whitespace Created 8 years, 6 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: 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..3f8c0ad5d16876ebff7301095306b41d0b68a5e1 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)
+URLRequestFtpJob::URLRequestFtpJob(
+ URLRequest* request,
+ NetworkDelegate* network_delegate,
+ FtpTransactionFactory* ftp_transaction_factory,
+ FtpAuthCache* ftp_auth_cache)
: URLRequestJob(request, request->context()->network_delegate()),
mmenke 2012/06/26 18:36:10 Second argument should now be network_delegate.
shalev 2012/06/26 19:05:01 Done.
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
@@ -35,9 +43,13 @@ URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
!IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port))
return new URLRequestErrorJob(request, ERR_UNSAFE_PORT);
mmenke 2012/06/26 18:36:10 While you're here, could you fix the formatting of
shalev 2012/06/26 19:05:01 Done.
- DCHECK(request->context());
DCHECK(request->context()->ftp_transaction_factory());
- return new URLRequestFtpJob(request);
+ DCHECK(request->context()->ftp_auth_cache());
mmenke 2012/06/26 18:36:10 These two DCHECKs are now in URLRequestFtpJob's co
shalev 2012/06/26 19:05:01 Done.
+
+ 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 +73,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 +113,14 @@ 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);
-
+ ftp_auth_cache_->Lookup(origin);
mmenke 2012/06/26 18:36:10 nit: Think this will fit on one line.
shalev 2012/06/26 19:05:01 Done.
if (cached_auth) {
// Retry using cached auth data.
SetAuth(cached_auth->credentials);
@@ -204,8 +211,8 @@ 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);
mmenke 2012/06/26 18:36:10 nit: Think this will just barely fit on one line
shalev 2012/06/26 19:05:01 Done.
RestartTransactionWithAuth();
}
« net/url_request/url_request_ftp_job.h ('K') | « 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