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

Unified Diff: net/url_request/url_request_ftp_job.cc

Issue 8824006: Migrate net/socket/socket.h, net/socket/stream_socket.h to base::Bind(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years 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
« no previous file with comments | « net/url_request/url_request_ftp_job.h ('k') | remoting/jingle_glue/ssl_socket_adapter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 669a8898bb2fe458e4ce6813ad8abc8c56a280e1..a07b94e6813f33148f00ce238cd45b8cba4a407d 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -21,13 +21,9 @@ namespace net {
URLRequestFtpJob::URLRequestFtpJob(URLRequest* request)
: URLRequestJob(request),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- start_callback_(this, &URLRequestFtpJob::OnStartCompleted)),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- read_callback_(this, &URLRequestFtpJob::OnReadCompleted)),
read_in_progress_(false),
context_(request->context()),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
// static
@@ -78,7 +74,10 @@ void URLRequestFtpJob::StartTransaction() {
int rv;
if (transaction_.get()) {
rv = transaction_->Start(
- &request_info_, &start_callback_, request_->net_log());
+ &request_info_,
+ base::Bind(&URLRequestFtpJob::OnStartCompleted,
+ base::Unretained(this)),
+ request_->net_log());
if (rv == ERR_IO_PENDING)
return;
} else {
@@ -88,8 +87,8 @@ void URLRequestFtpJob::StartTransaction() {
// URLRequest delegate via the message loop.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestFtpJob::OnStartCompleted, rv));
+ base::Bind(&URLRequestFtpJob::OnStartCompleted,
+ weak_factory_.GetWeakPtr(), rv));
}
void URLRequestFtpJob::OnStartCompleted(int result) {
@@ -148,15 +147,17 @@ void URLRequestFtpJob::RestartTransactionWithAuth() {
// be notifying our consumer asynchronously via OnStartCompleted.
SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
- int rv = transaction_->RestartWithAuth(server_auth_->credentials,
- &start_callback_);
+ int rv = transaction_->RestartWithAuth(
+ server_auth_->credentials,
+ base::Bind(&URLRequestFtpJob::OnStartCompleted,
+ base::Unretained(this)));
if (rv == ERR_IO_PENDING)
return;
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestFtpJob::OnStartCompleted, rv));
+ base::Bind(&URLRequestFtpJob::OnStartCompleted,
+ weak_factory_.GetWeakPtr(), rv));
}
void URLRequestFtpJob::Start() {
@@ -170,7 +171,7 @@ void URLRequestFtpJob::Kill() {
return;
transaction_.reset();
URLRequestJob::Kill();
- method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
}
LoadState URLRequestFtpJob::GetLoadState() const {
@@ -219,8 +220,8 @@ void URLRequestFtpJob::CancelAuth() {
// any recursing into the caller as a result of this call.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestFtpJob::OnStartCompleted, OK));
+ base::Bind(&URLRequestFtpJob::OnStartCompleted,
+ weak_factory_.GetWeakPtr(), OK));
}
uint64 URLRequestFtpJob::GetUploadProgress() const {
@@ -234,7 +235,9 @@ bool URLRequestFtpJob::ReadRawData(IOBuffer* buf,
DCHECK(bytes_read);
DCHECK(!read_in_progress_);
- int rv = transaction_->Read(buf, buf_size, &read_callback_);
+ int rv = transaction_->Read(buf, buf_size,
+ base::Bind(&URLRequestFtpJob::OnReadCompleted,
+ base::Unretained(this)));
if (rv >= 0) {
*bytes_read = rv;
return true;
« no previous file with comments | « net/url_request/url_request_ftp_job.h ('k') | remoting/jingle_glue/ssl_socket_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698