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

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 network_delegate change 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..4552b91d0a12760d4831ead913a706bc3a73c8f7 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -19,10 +19,19 @@
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()),
erikwright (departed) 2012/06/21 20:21:30 pass network_delegate instead of request->context(
shalev 2012/06/29 17:51:27 Done.
read_in_progress_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
+ network_delegate_(network_delegate),
+ ftp_transaction_factory_(ftp_transaction_factory),
+ ftp_auth_cache_(ftp_auth_cache) {
+ DCHECK(ftp_transaction_factory);
+ DCHECK(ftp_auth_cache);
}
// static
@@ -37,7 +46,12 @@ URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
DCHECK(request->context());
erikwright (departed) 2012/06/21 20:21:30 remove this DCHECK now that context is required.
shalev 2012/06/21 20:38:54 Done.
DCHECK(request->context()->ftp_transaction_factory());
- return new URLRequestFtpJob(request);
+ DCHECK(request->context()->ftp_auth_cache());
+
+ 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 +75,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 +115,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);
if (cached_auth) {
// Retry using cached auth data.
SetAuth(cached_auth->credentials);
@@ -204,8 +213,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);
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