summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc11
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h2
-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
11 files changed, 197 insertions, 6 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index a33716e..528c0e1 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -15,6 +15,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
+#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_cache.h"
#include "net/http/http_network_layer.h"
#include "net/http/http_util.h"
@@ -82,6 +83,15 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginal(
}
context->http_transaction_factory_ = cache;
+ // The kNewFtp switch is Windows specific only because we have multiple FTP
+ // implementations on Windows.
+#if defined(OS_WIN)
+ if (command_line.HasSwitch(switches::kNewFtp))
+ context->ftp_transaction_factory_ = new net::FtpNetworkLayer;
+#else
+ context->ftp_transaction_factory_ = new net::FtpNetworkLayer;
+#endif
+
// setup cookie store
if (!context->cookie_store_) {
DCHECK(!cookie_store_path.empty());
@@ -288,6 +298,7 @@ ChromeURLRequestContext::~ChromeURLRequestContext() {
NotificationService::NoDetails());
delete cookie_store_;
+ delete ftp_transaction_factory_;
delete http_transaction_factory_;
// Do not delete the proxy service in the case of OTR, as it is owned by the
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 1a7e91b..0a101b4 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -392,6 +392,9 @@ const wchar_t kTestName[] = L"test-name";
// command line. (Useful values might be "valgrind" or "gdb --args")
const wchar_t kRendererCmdPrefix[] = L"renderer-cmd-prefix";
+// Temparary option for new ftp implemetation.
+const wchar_t kNewFtp[] = L"new-ftp";
+
// On POSIX only: use FIFO for IPC channels so that "unrelated" process
// can connect to a channel, provided it knows its name. For debugging purposes.
const wchar_t kIPCUseFIFO[] = L"ipc-use-fifo";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 07b171f..cd78d00 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -149,6 +149,8 @@ extern const wchar_t kTestName[];
extern const wchar_t kRendererCmdPrefix[];
+extern const wchar_t kNewFtp[];
+
extern const wchar_t kIPCUseFIFO[];
extern const wchar_t kEnableOutOfProcessDevTools[];
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_