summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 20:13:33 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 20:13:33 +0000
commitb65ce0948709317aadc38e18c1a16f23a72bb5eb (patch)
treef4f9f816e60a18afb214dbd0d1a5ea8108ad3863 /net
parent0f9d542be7a415150b3002e3a0c642f9f2e252a4 (diff)
downloadchromium_src-b65ce0948709317aadc38e18c1a16f23a72bb5eb.zip
chromium_src-b65ce0948709317aadc38e18c1a16f23a72bb5eb.tar.gz
chromium_src-b65ce0948709317aadc38e18c1a16f23a72bb5eb.tar.bz2
Add command line switch "--new-ftp" for new portable FTP
implementation. Add the (empty) URLRequestNewFtpJob class. Contributed by Ibrar Ahmed <ibrar.ahmad@gmail.com>. BUG=4965 R=darin,wtc Review URL: http://codereview.chromium.org/42197 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/build/net.vcproj14
-rw-r--r--net/ftp/ftp_network_transaction.h2
-rw-r--r--net/net.gyp2
-rw-r--r--net/net_lib.scons2
-rw-r--r--net/url_request/url_request_context.h10
-rw-r--r--net/url_request/url_request_ftp_job.cc7
-rw-r--r--net/url_request/url_request_new_ftp_job.cc90
-rw-r--r--net/url_request/url_request_new_ftp_job.h60
8 files changed, 181 insertions, 6 deletions
diff --git a/net/build/net.vcproj b/net/build/net.vcproj
index ffe5699..07d47a6 100644
--- a/net/build/net.vcproj
+++ b/net/build/net.vcproj
@@ -662,6 +662,14 @@
>
</File>
<File
+ RelativePath="..\url_request\url_request_new_ftp_job.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\url_request\url_request_new_ftp_job.h"
+ >
+ </File>
+ <File
RelativePath="..\url_request\url_request_simple_job.cc"
>
</File>
@@ -1054,15 +1062,15 @@
>
</File>
<File
- RelativePath="..\proxy\proxy_resolver_v8.cc"
+ RelativePath="..\proxy\proxy_resolver_script.h"
>
</File>
<File
- RelativePath="..\proxy\proxy_resolver_v8.h"
+ RelativePath="..\proxy\proxy_resolver_v8.cc"
>
</File>
<File
- RelativePath="..\proxy\proxy_resolver_script.h"
+ RelativePath="..\proxy\proxy_resolver_v8.h"
>
</File>
<File
diff --git a/net/ftp/ftp_network_transaction.h b/net/ftp/ftp_network_transaction.h
index 43b4712..c7f59cd 100644
--- a/net/ftp/ftp_network_transaction.h
+++ b/net/ftp/ftp_network_transaction.h
@@ -22,7 +22,7 @@ class FtpNetworkTransaction : public FtpTransaction {
FtpNetworkSession* session, ClientSocketFactory* socket_factory);
~FtpNetworkTransaction();
- // FtpTransactionFactory methods:
+ // FtpTransaction methods:
virtual void Destroy();
virtual int Start(
const FtpRequestInfo* request_info, CompletionCallback* callback);
diff --git a/net/net.gyp b/net/net.gyp
index 00caf09..1d4123a 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -282,6 +282,8 @@
'url_request/url_request_job_metrics.h',
'url_request/url_request_job_tracker.cc',
'url_request/url_request_job_tracker.h',
+ 'url_request/url_request_new_ftp_job.cc',
+ 'url_request/url_request_new_ftp_job.h',
'url_request/url_request_simple_job.cc',
'url_request/url_request_simple_job.h',
'url_request/url_request_status.h',
diff --git a/net/net_lib.scons b/net/net_lib.scons
index fc9505e..073ec08 100644
--- a/net/net_lib.scons
+++ b/net/net_lib.scons
@@ -155,6 +155,8 @@ input_files = ChromeFileList([
'url_request/url_request_job_metrics.h',
'url_request/url_request_job_tracker.cc',
'url_request/url_request_job_tracker.h',
+ 'url_request/url_request_new_ftp_job.cc',
+ 'url_request/url_request_new_ftp_job.h',
'url_request/url_request_simple_job.cc',
'url_request/url_request_simple_job.h',
'url_request/url_request_status.h',
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index e02cedd..8c09c90 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -16,8 +16,9 @@
#include "net/ftp/ftp_auth_cache.h"
namespace net {
-class HttpTransactionFactory;
class CookieMonster;
+class FtpTransactionFactory;
+class HttpTransactionFactory;
class ProxyService;
}
@@ -28,6 +29,7 @@ class URLRequestContext :
URLRequestContext()
: proxy_service_(NULL),
http_transaction_factory_(NULL),
+ ftp_transaction_factory_(NULL),
cookie_store_(NULL) {
}
@@ -41,6 +43,11 @@ class URLRequestContext :
return http_transaction_factory_;
}
+ // Gets the ftp transaction factory for this context.
+ net::FtpTransactionFactory* ftp_transaction_factory() {
+ return ftp_transaction_factory_;
+ }
+
// Gets the cookie store for this context.
net::CookieMonster* cookie_store() { return cookie_store_; }
@@ -72,6 +79,7 @@ class URLRequestContext :
// subclasses.
net::ProxyService* proxy_service_;
net::HttpTransactionFactory* http_transaction_factory_;
+ net::FtpTransactionFactory* ftp_transaction_factory_;
net::CookieMonster* cookie_store_;
net::CookiePolicy cookie_policy_;
net::FtpAuthCache ftp_auth_cache_;
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc
index 86e7bdf..00a62ac 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -11,13 +11,14 @@
#include "base/string_util.h"
#include "base/time.h"
#include "net/base/auth.h"
+#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/base/net_util.h"
#include "net/base/wininet_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_error_job.h"
-#include "net/base/escape.h"
+#include "net/url_request/url_request_new_ftp_job.h"
using std::string;
@@ -53,6 +54,10 @@ static bool UnescapeAndValidatePath(const URLRequest* request,
// static
URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
const std::string &scheme) {
+ // Checking whether we are using new or old FTP implementation.
+ if (request->context() && request->context()->ftp_transaction_factory())
+ return URLRequestNewFtpJob::Factory(request, scheme);
+
DCHECK(scheme == "ftp");
if (request->url().has_port() &&
diff --git a/net/url_request/url_request_new_ftp_job.cc b/net/url_request/url_request_new_ftp_job.cc
new file mode 100644
index 0000000..3101783
--- /dev/null
+++ b/net/url_request/url_request_new_ftp_job.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/url_request/url_request_new_ftp_job.h"
+
+#include "base/file_version_info.h"
+#include "net/base/net_util.h"
+#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_error_job.h"
+
+
+URLRequestNewFtpJob::URLRequestNewFtpJob(URLRequest* request)
+ : URLRequestJob(request),
+ server_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ start_callback_(this, &URLRequestNewFtpJob::OnStartCompleted)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ read_callback_(this, &URLRequestNewFtpJob::OnReadCompleted)),
+ read_in_progress_(false),
+ context_(request->context()) {
+}
+
+URLRequestNewFtpJob::~URLRequestNewFtpJob() {
+}
+
+// static
+URLRequestJob* URLRequestNewFtpJob::Factory(URLRequest* request,
+ const std::string& scheme) {
+ DCHECK(scheme == "ftp");
+
+ if (request->url().has_port() &&
+ !net::IsPortAllowedByFtp(request->url().IntPort()))
+ return new URLRequestErrorJob(request, net::ERR_UNSAFE_PORT);
+
+ DCHECK(request->context());
+ DCHECK(request->context()->ftp_transaction_factory());
+ return new URLRequestNewFtpJob(request);
+}
+
+void URLRequestNewFtpJob::Start() {
+ NOTIMPLEMENTED();
+}
+
+void URLRequestNewFtpJob::Kill() {
+ NOTIMPLEMENTED();
+}
+
+uint64 URLRequestNewFtpJob::GetUploadProgress() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+void URLRequestNewFtpJob::GetResponseInfo() {
+ NOTIMPLEMENTED();
+}
+
+int URLRequestNewFtpJob::GetResponseCode() {
+ NOTIMPLEMENTED();
+ return -1;
+}
+
+bool URLRequestNewFtpJob::GetMoreData() {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool URLRequestNewFtpJob::ReadRawData(net::IOBuffer* buf,
+ int buf_size,
+ int *bytes_read) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void URLRequestNewFtpJob::OnStartCompleted(int result) {
+ NOTIMPLEMENTED();
+}
+
+void URLRequestNewFtpJob::OnReadCompleted(int result) {
+ NOTIMPLEMENTED();
+}
+
+void URLRequestNewFtpJob::DestroyTransaction() {
+ NOTIMPLEMENTED();
+}
+
+void URLRequestNewFtpJob::StartTransaction() {
+ NOTIMPLEMENTED();
+}
diff --git a/net/url_request/url_request_new_ftp_job.h b/net/url_request/url_request_new_ftp_job.h
new file mode 100644
index 0000000..79b165c
--- /dev/null
+++ b/net/url_request/url_request_new_ftp_job.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_URL_REQUEST_URL_REQUEST_NEW_FTP_JOB_H_
+#define NET_URL_REQUEST_URL_REQUEST_NEW_FTP_JOB_H_
+
+#include <string>
+#include <vector>
+
+#include "net/base/auth.h"
+#include "net/base/completion_callback.h"
+#include "net/url_request/url_request_job.h"
+
+class URLRequestContext;
+
+// A URLRequestJob subclass that is built on top of FtpTransaction. It
+// provides an implementation for FTP.
+class URLRequestNewFtpJob : public URLRequestJob {
+ public:
+
+ explicit URLRequestNewFtpJob(URLRequest* request);
+
+ virtual ~URLRequestNewFtpJob();
+
+ static URLRequestJob* Factory(URLRequest* request, const std::string& scheme);
+
+ private:
+ // URLRequestJob methods:
+ virtual void Start();
+ virtual void Kill();
+ virtual uint64 GetUploadProgress() const;
+ virtual void GetResponseInfo();
+ virtual int GetResponseCode();
+ virtual bool GetMoreData();
+ virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read);
+
+ void NotifyHeadersComplete();
+
+ void DestroyTransaction();
+ void StartTransaction();
+
+ void OnStartCompleted(int result);
+ void OnReadCompleted(int result);
+
+ net::AuthState server_auth_state_;
+
+ net::CompletionCallbackImpl<URLRequestNewFtpJob> start_callback_;
+ net::CompletionCallbackImpl<URLRequestNewFtpJob> read_callback_;
+
+ bool read_in_progress_;
+
+ // Keep a reference to the url request context to be sure it's not deleted
+ // before us.
+ scoped_refptr<URLRequestContext> context_;
+
+ DISALLOW_COPY_AND_ASSIGN(URLRequestNewFtpJob);
+};
+
+#endif // NET_URL_REQUEST_URL_REQUEST_NEW_FTP_JOB_H_