summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-12 01:47:54 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-12 01:47:54 +0000
commit03ea3c52ca254436886a0372eb9fb4b1eb8aefd9 (patch)
tree738a9307b765945f29a79a879ad12358b10633e4 /net
parent8e95ee1fcfc765f940bcb1cb0a961c8158e9bff5 (diff)
downloadchromium_src-03ea3c52ca254436886a0372eb9fb4b1eb8aefd9.zip
chromium_src-03ea3c52ca254436886a0372eb9fb4b1eb8aefd9.tar.gz
chromium_src-03ea3c52ca254436886a0372eb9fb4b1eb8aefd9.tar.bz2
net: Add namespace net to URLRequestFtpJob.
BUG=64263 TEST=trybots Review URL: http://codereview.chromium.org/5739005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/url_request/url_request_ftp_job.cc62
-rw-r--r--net/url_request/url_request_ftp_job.h34
-rw-r--r--net/url_request/url_request_job_manager.cc2
3 files changed, 53 insertions, 45 deletions
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc
index 0463278..6eb09e0 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -16,8 +16,10 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_error_job.h"
-URLRequestFtpJob::URLRequestFtpJob(net::URLRequest* request)
- : net::URLRequestJob(request),
+namespace net {
+
+URLRequestFtpJob::URLRequestFtpJob(URLRequest* request)
+ : URLRequestJob(request),
ALLOW_THIS_IN_INITIALIZER_LIST(
start_callback_(this, &URLRequestFtpJob::OnStartCompleted)),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -31,14 +33,14 @@ URLRequestFtpJob::~URLRequestFtpJob() {
}
// static
-net::URLRequestJob* URLRequestFtpJob::Factory(net::URLRequest* request,
- const std::string& scheme) {
+URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
+ const std::string& scheme) {
DCHECK_EQ(scheme, "ftp");
int port = request->url().IntPort();
if (request->url().has_port() &&
- !net::IsPortAllowedByFtp(port) && !net::IsPortAllowedByOverride(port))
- return new URLRequestErrorJob(request, net::ERR_UNSAFE_PORT);
+ !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port))
+ return new URLRequestErrorJob(request, ERR_UNSAFE_PORT);
DCHECK(request->context());
DCHECK(request->context()->ftp_transaction_factory());
@@ -63,13 +65,13 @@ void URLRequestFtpJob::Kill() {
if (!transaction_.get())
return;
transaction_.reset();
- net::URLRequestJob::Kill();
+ URLRequestJob::Kill();
method_factory_.RevokeAll();
}
-net::LoadState URLRequestFtpJob::GetLoadState() const {
+LoadState URLRequestFtpJob::GetLoadState() const {
return transaction_.get() ?
- transaction_->GetLoadState() : net::LOAD_STATE_IDLE;
+ transaction_->GetLoadState() : LOAD_STATE_IDLE;
}
bool URLRequestFtpJob::NeedsAuth() {
@@ -77,17 +79,17 @@ bool URLRequestFtpJob::NeedsAuth() {
// requires auth (and not a proxy), because connecting to FTP via proxy
// effectively means the browser communicates via HTTP, and uses HTTP's
// Proxy-Authenticate protocol when proxy servers require auth.
- return server_auth_ && server_auth_->state == net::AUTH_STATE_NEED_AUTH;
+ return server_auth_ && server_auth_->state == AUTH_STATE_NEED_AUTH;
}
void URLRequestFtpJob::GetAuthChallengeInfo(
- scoped_refptr<net::AuthChallengeInfo>* result) {
+ scoped_refptr<AuthChallengeInfo>* result) {
DCHECK((server_auth_ != NULL) &&
- (server_auth_->state == net::AUTH_STATE_NEED_AUTH));
- scoped_refptr<net::AuthChallengeInfo> auth_info(new net::AuthChallengeInfo);
+ (server_auth_->state == AUTH_STATE_NEED_AUTH));
+ scoped_refptr<AuthChallengeInfo> auth_info(new AuthChallengeInfo);
auth_info->is_proxy = false;
auth_info->host_and_port = ASCIIToWide(
- net::GetHostAndPort(request_->url()));
+ GetHostAndPort(request_->url()));
auth_info->scheme = L"";
auth_info->realm = L"";
result->swap(auth_info);
@@ -96,7 +98,7 @@ void URLRequestFtpJob::GetAuthChallengeInfo(
void URLRequestFtpJob::SetAuth(const string16& username,
const string16& password) {
DCHECK(NeedsAuth());
- server_auth_->state = net::AUTH_STATE_HAVE_AUTH;
+ server_auth_->state = AUTH_STATE_HAVE_AUTH;
server_auth_->username = username;
server_auth_->password = password;
@@ -108,7 +110,7 @@ void URLRequestFtpJob::SetAuth(const string16& username,
void URLRequestFtpJob::CancelAuth() {
DCHECK(NeedsAuth());
- server_auth_->state = net::AUTH_STATE_CANCELED;
+ server_auth_->state = AUTH_STATE_CANCELED;
// Once the auth is cancelled, we proceed with the request as though
// there were no auth. Schedule this for later so that we don't cause
@@ -116,10 +118,10 @@ void URLRequestFtpJob::CancelAuth() {
MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
- &URLRequestFtpJob::OnStartCompleted, net::OK));
+ &URLRequestFtpJob::OnStartCompleted, OK));
}
-bool URLRequestFtpJob::ReadRawData(net::IOBuffer* buf,
+bool URLRequestFtpJob::ReadRawData(IOBuffer* buf,
int buf_size,
int *bytes_read) {
DCHECK_NE(buf_size, 0);
@@ -132,7 +134,7 @@ bool URLRequestFtpJob::ReadRawData(net::IOBuffer* buf,
return true;
}
- if (rv == net::ERR_IO_PENDING) {
+ if (rv == ERR_IO_PENDING) {
read_in_progress_ = true;
SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
} else {
@@ -150,20 +152,20 @@ void URLRequestFtpJob::OnStartCompleted(int result) {
set_expected_content_size(
transaction_->GetResponseInfo()->expected_content_size);
- if (result == net::OK) {
+ if (result == OK) {
NotifyHeadersComplete();
} else if (transaction_->GetResponseInfo()->needs_auth) {
GURL origin = request_->url().GetOrigin();
- if (server_auth_ && server_auth_->state == net::AUTH_STATE_HAVE_AUTH) {
+ if (server_auth_ && server_auth_->state == AUTH_STATE_HAVE_AUTH) {
request_->context()->ftp_auth_cache()->Remove(origin,
server_auth_->username,
server_auth_->password);
} else if (!server_auth_) {
- server_auth_ = new net::AuthData();
+ server_auth_ = new AuthData();
}
- server_auth_->state = net::AUTH_STATE_NEED_AUTH;
+ server_auth_->state = AUTH_STATE_NEED_AUTH;
- net::FtpAuthCache::Entry* cached_auth =
+ FtpAuthCache::Entry* cached_auth =
request_->context()->ftp_auth_cache()->Lookup(origin);
if (cached_auth) {
@@ -192,7 +194,7 @@ void URLRequestFtpJob::OnReadCompleted(int result) {
}
void URLRequestFtpJob::RestartTransactionWithAuth() {
- DCHECK(server_auth_ && server_auth_->state == net::AUTH_STATE_HAVE_AUTH);
+ DCHECK(server_auth_ && server_auth_->state == AUTH_STATE_HAVE_AUTH);
// No matter what, we want to report our status as IO pending since we will
// be notifying our consumer asynchronously via OnStartCompleted.
@@ -201,7 +203,7 @@ void URLRequestFtpJob::RestartTransactionWithAuth() {
int rv = transaction_->RestartWithAuth(server_auth_->username,
server_auth_->password,
&start_callback_);
- if (rv == net::ERR_IO_PENDING)
+ if (rv == ERR_IO_PENDING)
return;
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
@@ -224,15 +226,17 @@ void URLRequestFtpJob::StartTransaction() {
if (transaction_.get()) {
rv = transaction_->Start(
&request_info_, &start_callback_, request_->net_log());
- if (rv == net::ERR_IO_PENDING)
+ if (rv == ERR_IO_PENDING)
return;
} else {
- rv = net::ERR_FAILED;
+ rv = ERR_FAILED;
}
// The transaction started synchronously, but we need to notify the
- // net::URLRequest delegate via the message loop.
+ // URLRequest delegate via the message loop.
MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
&URLRequestFtpJob::OnStartCompleted, rv));
}
+
+} // namespace net
diff --git a/net/url_request/url_request_ftp_job.h b/net/url_request/url_request_ftp_job.h
index c4b6fbd..58d0efb 100644
--- a/net/url_request/url_request_ftp_job.h
+++ b/net/url_request/url_request_ftp_job.h
@@ -18,36 +18,38 @@
class URLRequestContext;
-// A net::URLRequestJob subclass that is built on top of FtpTransaction. It
+namespace net {
+
+// A URLRequestJob subclass that is built on top of FtpTransaction. It
// provides an implementation for FTP.
-class URLRequestFtpJob : public net::URLRequestJob {
+class URLRequestFtpJob : public URLRequestJob {
public:
- explicit URLRequestFtpJob(net::URLRequest* request);
+ explicit URLRequestFtpJob(URLRequest* request);
- static net::URLRequestJob* Factory(net::URLRequest* request,
- const std::string& scheme);
+ static URLRequestJob* Factory(URLRequest* request,
+ const std::string& scheme);
- // net::URLRequestJob methods:
+ // Overridden from URLRequestJob:
virtual bool GetMimeType(std::string* mime_type) const;
private:
virtual ~URLRequestFtpJob();
- // net::URLRequestJob methods:
+ // Overridden from URLRequestJob:
virtual void Start();
virtual void Kill();
- virtual net::LoadState GetLoadState() const;
+ virtual LoadState GetLoadState() const;
virtual bool NeedsAuth();
virtual void GetAuthChallengeInfo(
- scoped_refptr<net::AuthChallengeInfo>* auth_info);
+ scoped_refptr<AuthChallengeInfo>* auth_info);
virtual void SetAuth(const string16& username,
const string16& password);
virtual void CancelAuth();
// TODO(ibrar): Yet to give another look at this function.
virtual uint64 GetUploadProgress() const { return 0; }
- virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read);
+ virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read);
void StartTransaction();
@@ -58,15 +60,15 @@ class URLRequestFtpJob : public net::URLRequestJob {
void LogFtpServerType(char server_type);
- net::FtpRequestInfo request_info_;
- scoped_ptr<net::FtpTransaction> transaction_;
+ FtpRequestInfo request_info_;
+ scoped_ptr<FtpTransaction> transaction_;
- net::CompletionCallbackImpl<URLRequestFtpJob> start_callback_;
- net::CompletionCallbackImpl<URLRequestFtpJob> read_callback_;
+ CompletionCallbackImpl<URLRequestFtpJob> start_callback_;
+ CompletionCallbackImpl<URLRequestFtpJob> read_callback_;
bool read_in_progress_;
- scoped_refptr<net::AuthData> server_auth_;
+ scoped_refptr<AuthData> server_auth_;
// Keep a reference to the url request context to be sure it's not deleted
// before us.
@@ -77,4 +79,6 @@ class URLRequestFtpJob : public net::URLRequestJob {
DISALLOW_COPY_AND_ASSIGN(URLRequestFtpJob);
};
+} // namespace net
+
#endif // NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_
diff --git a/net/url_request/url_request_job_manager.cc b/net/url_request/url_request_job_manager.cc
index 72a2426..490d8dd 100644
--- a/net/url_request/url_request_job_manager.cc
+++ b/net/url_request/url_request_job_manager.cc
@@ -32,7 +32,7 @@ static const SchemeToFactory kBuiltinFactories[] = {
{ "http", URLRequestHttpJob::Factory },
{ "https", URLRequestHttpJob::Factory },
{ "file", URLRequestFileJob::Factory },
- { "ftp", URLRequestFtpJob::Factory },
+ { "ftp", net::URLRequestFtpJob::Factory },
{ "about", net::URLRequestAboutJob::Factory },
{ "data", URLRequestDataJob::Factory },
};