summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 21:12:34 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 21:12:34 +0000
commit098b2911b28bbfabde8fe38cfa45f2d6c94e2c6e (patch)
treef575dc5d46a3527bcacba05db679415be0ae47c8 /net/url_request
parenta6a408717b680f1201b2f8a30cb928a65c7d08b2 (diff)
downloadchromium_src-098b2911b28bbfabde8fe38cfa45f2d6c94e2c6e.zip
chromium_src-098b2911b28bbfabde8fe38cfa45f2d6c94e2c6e.tar.gz
chromium_src-098b2911b28bbfabde8fe38cfa45f2d6c94e2c6e.tar.bz2
Convert NewRunnableMethod() calls to base::Bind().
BUG=none TEST=existing tests. Review URL: http://codereview.chromium.org/8956017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_about_job.cc5
-rw-r--r--net/url_request/url_request_about_job.h4
-rw-r--r--net/url_request/url_request_error_job.cc5
-rw-r--r--net/url_request/url_request_error_job.h4
-rw-r--r--net/url_request/url_request_file_dir_job.cc9
-rw-r--r--net/url_request/url_request_file_dir_job.h4
-rw-r--r--net/url_request/url_request_file_job.cc4
-rw-r--r--net/url_request/url_request_file_job.h3
-rw-r--r--net/url_request/url_request_http_job.cc27
-rw-r--r--net/url_request/url_request_http_job.h4
-rw-r--r--net/url_request/url_request_job.cc8
-rw-r--r--net/url_request/url_request_job.h4
-rw-r--r--net/url_request/url_request_job_factory_unittest.cc10
-rw-r--r--net/url_request/url_request_redirect_job.cc6
-rw-r--r--net/url_request/url_request_redirect_job.h4
-rw-r--r--net/url_request/url_request_simple_job.cc6
-rw-r--r--net/url_request/url_request_simple_job.h4
-rw-r--r--net/url_request/url_request_test_job.cc17
-rw-r--r--net/url_request/url_request_test_job.h4
19 files changed, 68 insertions, 64 deletions
diff --git a/net/url_request/url_request_about_job.cc b/net/url_request/url_request_about_job.cc
index 2ef7ad5..f305909 100644
--- a/net/url_request/url_request_about_job.cc
+++ b/net/url_request/url_request_about_job.cc
@@ -8,6 +8,7 @@
#include "net/url_request/url_request_about_job.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
@@ -15,7 +16,7 @@ namespace net {
URLRequestAboutJob::URLRequestAboutJob(URLRequest* request)
: URLRequestJob(request),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
// static
@@ -29,7 +30,7 @@ void URLRequestAboutJob::Start() {
// callbacks happen as they would for network requests.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(&URLRequestAboutJob::StartAsync));
+ base::Bind(&URLRequestAboutJob::StartAsync, weak_factory_.GetWeakPtr()));
}
bool URLRequestAboutJob::GetMimeType(std::string* mime_type) const {
diff --git a/net/url_request/url_request_about_job.h b/net/url_request/url_request_about_job.h
index 55f0478..957e233 100644
--- a/net/url_request/url_request_about_job.h
+++ b/net/url_request/url_request_about_job.h
@@ -8,7 +8,7 @@
#include <string>
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_job.h"
@@ -29,7 +29,7 @@ class NET_EXPORT URLRequestAboutJob : public URLRequestJob {
void StartAsync();
- ScopedRunnableMethodFactory<URLRequestAboutJob> method_factory_;
+ base::WeakPtrFactory<URLRequestAboutJob> weak_factory_;
};
} // namespace net
diff --git a/net/url_request/url_request_error_job.cc b/net/url_request/url_request_error_job.cc
index 0d72dcc..4924c01 100644
--- a/net/url_request/url_request_error_job.cc
+++ b/net/url_request/url_request_error_job.cc
@@ -4,6 +4,7 @@
#include "net/url_request/url_request_error_job.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "net/base/net_errors.h"
@@ -14,14 +15,14 @@ namespace net {
URLRequestErrorJob::URLRequestErrorJob(URLRequest* request, int error)
: URLRequestJob(request),
error_(error),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
URLRequestErrorJob::~URLRequestErrorJob() {}
void URLRequestErrorJob::Start() {
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(&URLRequestErrorJob::StartAsync));
+ base::Bind(&URLRequestErrorJob::StartAsync, weak_factory_.GetWeakPtr()));
}
void URLRequestErrorJob::StartAsync() {
diff --git a/net/url_request/url_request_error_job.h b/net/url_request/url_request_error_job.h
index cdf28d9..7f34984 100644
--- a/net/url_request/url_request_error_job.h
+++ b/net/url_request/url_request_error_job.h
@@ -9,7 +9,7 @@
#define NET_URL_REQUEST_URL_REQUEST_ERROR_JOB_H_
#pragma once
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/base/net_export.h"
#include "net/url_request/url_request_job.h"
@@ -28,7 +28,7 @@ class NET_EXPORT URLRequestErrorJob : public URLRequestJob {
int error_;
- ScopedRunnableMethodFactory<URLRequestErrorJob> method_factory_;
+ base::WeakPtrFactory<URLRequestErrorJob> weak_factory_;
};
} // namespace net
diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc
index c47e800..0b05cbb 100644
--- a/net/url_request/url_request_file_dir_job.cc
+++ b/net/url_request/url_request_file_dir_job.cc
@@ -4,6 +4,7 @@
#include "net/url_request/url_request_file_dir_job.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -32,7 +33,7 @@ URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request,
wrote_header_(false),
read_pending_(false),
read_buffer_length_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
void URLRequestFileDirJob::StartAsync() {
@@ -46,8 +47,8 @@ void URLRequestFileDirJob::Start() {
// callbacks happen as they would for network requests.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestFileDirJob::StartAsync));
+ base::Bind(&URLRequestFileDirJob::StartAsync,
+ weak_factory_.GetWeakPtr()));
}
void URLRequestFileDirJob::Kill() {
@@ -61,7 +62,7 @@ void URLRequestFileDirJob::Kill() {
URLRequestJob::Kill();
- method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
}
bool URLRequestFileDirJob::ReadRawData(IOBuffer* buf, int buf_size,
diff --git a/net/url_request/url_request_file_dir_job.h b/net/url_request/url_request_file_dir_job.h
index eb9437d..ad3cee8 100644
--- a/net/url_request/url_request_file_dir_job.h
+++ b/net/url_request/url_request_file_dir_job.h
@@ -10,7 +10,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/base/directory_lister.h"
#include "net/url_request/url_request_job.h"
@@ -70,7 +70,7 @@ class URLRequestFileDirJob
bool read_pending_;
scoped_refptr<IOBuffer> read_buffer_;
int read_buffer_length_;
- ScopedRunnableMethodFactory<URLRequestFileDirJob> method_factory_;
+ base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob);
};
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index f3fdd11..db61784 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -86,8 +86,7 @@ URLRequestFileJob::URLRequestFileJob(URLRequest* request,
: URLRequestJob(request),
file_path_(file_path),
is_directory_(false),
- remaining_bytes_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ remaining_bytes_(0) {
}
// static
@@ -163,7 +162,6 @@ void URLRequestFileJob::Kill() {
}
URLRequestJob::Kill();
- method_factory_.RevokeAll();
}
bool URLRequestFileJob::ReadRawData(IOBuffer* dest, int dest_size,
diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h
index 6f13b3a..0c250f8 100644
--- a/net/url_request/url_request_file_job.h
+++ b/net/url_request/url_request_file_job.h
@@ -10,7 +10,6 @@
#include <vector>
#include "base/file_path.h"
-#include "base/task.h"
#include "net/base/file_stream.h"
#include "net/base/net_export.h"
#include "net/http/http_byte_range.h"
@@ -72,8 +71,6 @@ class NET_EXPORT URLRequestFileJob : public URLRequestJob {
friend class AsyncResolver;
scoped_refptr<AsyncResolver> async_resolver_;
- ScopedRunnableMethodFactory<URLRequestFileJob> method_factory_;
-
DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob);
};
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index bf3df81..c5b7a2e 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -222,8 +222,7 @@ URLRequestHttpJob::URLRequestHttpJob(URLRequest* request)
final_packet_time_(),
ALLOW_THIS_IN_INITIALIZER_LIST(
filter_context_(new HttpFilterContext(this))),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
- weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(on_headers_received_callback_(
base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback,
base::Unretained(this)))),
@@ -370,8 +369,8 @@ void URLRequestHttpJob::StartTransactionInternal() {
// URLRequest delegate via the message loop.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestHttpJob::OnStartCompleted, rv));
+ base::Bind(&URLRequestHttpJob::OnStartCompleted,
+ weak_factory_.GetWeakPtr(), rv));
}
void URLRequestHttpJob::AddExtraHeaders() {
@@ -472,7 +471,7 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() {
cookie_monster->GetAllCookiesForURLAsync(
request_->url(),
base::Bind(&URLRequestHttpJob::CheckCookiePolicyAndLoad,
- weak_ptr_factory_.GetWeakPtr()));
+ weak_factory_.GetWeakPtr()));
} else {
DoLoadCookies();
}
@@ -487,7 +486,7 @@ void URLRequestHttpJob::DoLoadCookies() {
request_->context()->cookie_store()->GetCookiesWithInfoAsync(
request_->url(), options,
base::Bind(&URLRequestHttpJob::OnCookiesLoaded,
- weak_ptr_factory_.GetWeakPtr()));
+ weak_factory_.GetWeakPtr()));
}
void URLRequestHttpJob::CheckCookiePolicyAndLoad(
@@ -564,7 +563,7 @@ void URLRequestHttpJob::SaveNextCookie() {
request_->context()->cookie_store()->SetCookieWithOptionsAsync(
request_->url(), response_cookies_[response_cookies_save_index_],
options, base::Bind(&URLRequestHttpJob::OnCookieSaved,
- weak_ptr_factory_.GetWeakPtr()));
+ weak_factory_.GetWeakPtr()));
return;
}
}
@@ -807,7 +806,7 @@ void URLRequestHttpJob::Kill() {
if (!transaction_.get())
return;
- weak_ptr_factory_.InvalidateWeakPtrs();
+ weak_factory_.InvalidateWeakPtrs();
DestroyTransaction();
URLRequestJob::Kill();
}
@@ -1010,8 +1009,8 @@ void URLRequestHttpJob::CancelAuth() {
//
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestHttpJob::OnStartCompleted, OK));
+ base::Bind(&URLRequestHttpJob::OnStartCompleted,
+ weak_factory_.GetWeakPtr(), OK));
}
void URLRequestHttpJob::ContinueWithCertificate(
@@ -1034,8 +1033,8 @@ void URLRequestHttpJob::ContinueWithCertificate(
// URLRequest delegate via the message loop.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestHttpJob::OnStartCompleted, rv));
+ base::Bind(&URLRequestHttpJob::OnStartCompleted,
+ weak_factory_.GetWeakPtr(), rv));
}
void URLRequestHttpJob::ContinueDespiteLastError() {
@@ -1059,8 +1058,8 @@ void URLRequestHttpJob::ContinueDespiteLastError() {
// URLRequest delegate via the message loop.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &URLRequestHttpJob::OnStartCompleted, rv));
+ base::Bind(&URLRequestHttpJob::OnStartCompleted,
+ weak_factory_.GetWeakPtr(), rv));
}
bool URLRequestHttpJob::ShouldFixMismatchedContentLength(int rv) const {
diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h
index c924e1c..a3b475d 100644
--- a/net/url_request/url_request_http_job.h
+++ b/net/url_request/url_request_http_job.h
@@ -12,7 +12,6 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/task.h"
#include "base/time.h"
#include "net/base/auth.h"
#include "net/base/completion_callback.h"
@@ -214,8 +213,7 @@ class URLRequestHttpJob : public URLRequestJob {
base::TimeTicks start_time_;
scoped_ptr<HttpFilterContext> filter_context_;
- ScopedRunnableMethodFactory<URLRequestHttpJob> method_factory_;
- base::WeakPtrFactory<URLRequestHttpJob> weak_ptr_factory_;
+ base::WeakPtrFactory<URLRequestHttpJob> weak_factory_;
CompletionCallback on_headers_received_callback_;
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index ff6299a..f34fd27 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -4,6 +4,7 @@
#include "net/url_request/url_request_job.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "base/string_number_conversions.h"
@@ -31,7 +32,7 @@ URLRequestJob::URLRequestJob(URLRequest* request)
has_handled_response_(false),
expected_content_size_(-1),
deferred_redirect_status_code_(-1),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
base::SystemMonitor* system_monitor = base::SystemMonitor::Get();
if (system_monitor)
base::SystemMonitor::Get()->AddPowerObserver(this);
@@ -44,7 +45,7 @@ void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) {
}
void URLRequestJob::Kill() {
- method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
// Make sure the request is notified that we are done. We assume that the
// request took care of setting its error status before calling Kill.
if (request_)
@@ -424,7 +425,8 @@ void URLRequestJob::NotifyDone(const URLRequestStatus &status) {
// delegate if we're done because of a synchronous call.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(&URLRequestJob::CompleteNotifyDone));
+ base::Bind(&URLRequestJob::CompleteNotifyDone,
+ weak_factory_.GetWeakPtr()));
}
void URLRequestJob::CompleteNotifyDone() {
diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h
index 46bc54c..e849bd0 100644
--- a/net/url_request/url_request_job.h
+++ b/net/url_request/url_request_job.h
@@ -11,8 +11,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/system_monitor/system_monitor.h"
-#include "base/task.h"
#include "base/time.h"
#include "googleurl/src/gurl.h"
#include "net/base/filter.h"
@@ -373,7 +373,7 @@ class NET_EXPORT URLRequestJob : public base::RefCounted<URLRequestJob>,
GURL deferred_redirect_url_;
int deferred_redirect_status_code_;
- ScopedRunnableMethodFactory<URLRequestJob> method_factory_;
+ base::WeakPtrFactory<URLRequestJob> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(URLRequestJob);
};
diff --git a/net/url_request/url_request_job_factory_unittest.cc b/net/url_request/url_request_job_factory_unittest.cc
index 56b1a56..509df08 100644
--- a/net/url_request/url_request_job_factory_unittest.cc
+++ b/net/url_request/url_request_job_factory_unittest.cc
@@ -4,7 +4,8 @@
#include "net/url_request/url_request_job_factory.h"
-#include "base/task.h"
+#include "base/bind.h"
+#include "base/memory/weak_ptr.h"
#include "net/url_request/url_request_job.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -18,14 +19,15 @@ class MockURLRequestJob : public URLRequestJob {
MockURLRequestJob(URLRequest* request, const URLRequestStatus& status)
: URLRequestJob(request),
status_(status),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
virtual void Start() {
// Start reading asynchronously so that all error reporting and data
// callbacks happen as they would for network requests.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(&MockURLRequestJob::StartAsync));
+ base::Bind(&MockURLRequestJob::StartAsync,
+ weak_factory_.GetWeakPtr()));
}
private:
@@ -35,7 +37,7 @@ class MockURLRequestJob : public URLRequestJob {
}
URLRequestStatus status_;
- ScopedRunnableMethodFactory<MockURLRequestJob> method_factory_;
+ base::WeakPtrFactory<MockURLRequestJob> weak_factory_;
};
class DummyProtocolHandler : public URLRequestJobFactory::ProtocolHandler {
diff --git a/net/url_request/url_request_redirect_job.cc b/net/url_request/url_request_redirect_job.cc
index 5ff9ebd..01b2559 100644
--- a/net/url_request/url_request_redirect_job.cc
+++ b/net/url_request/url_request_redirect_job.cc
@@ -4,6 +4,7 @@
#include "net/url_request/url_request_redirect_job.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
@@ -14,12 +15,13 @@ URLRequestRedirectJob::URLRequestRedirectJob(URLRequest* request,
: URLRequestJob(request),
redirect_destination_(redirect_destination),
http_status_code_(302),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
void URLRequestRedirectJob::Start() {
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(&URLRequestRedirectJob::StartAsync));
+ base::Bind(&URLRequestRedirectJob::StartAsync,
+ weak_factory_.GetWeakPtr()));
}
bool URLRequestRedirectJob::IsRedirectResponse(GURL* location,
diff --git a/net/url_request/url_request_redirect_job.h b/net/url_request/url_request_redirect_job.h
index b63cf91..4e91e79 100644
--- a/net/url_request/url_request_redirect_job.h
+++ b/net/url_request/url_request_redirect_job.h
@@ -6,7 +6,7 @@
#define NET_URL_REQUEST_URL_REQUEST_REDIRECT_JOB_H_
#pragma once
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/base/net_export.h"
#include "net/url_request/url_request_job.h"
@@ -47,7 +47,7 @@ class NET_EXPORT URLRequestRedirectJob : public URLRequestJob {
GURL redirect_destination_;
int http_status_code_;
- ScopedRunnableMethodFactory<URLRequestRedirectJob> method_factory_;
+ base::WeakPtrFactory<URLRequestRedirectJob> weak_factory_;
};
} // namespace net
diff --git a/net/url_request/url_request_simple_job.cc b/net/url_request/url_request_simple_job.cc
index f137490..538dcf1 100644
--- a/net/url_request/url_request_simple_job.cc
+++ b/net/url_request/url_request_simple_job.cc
@@ -4,6 +4,7 @@
#include "net/url_request/url_request_simple_job.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "net/base/io_buffer.h"
@@ -15,14 +16,15 @@ namespace net {
URLRequestSimpleJob::URLRequestSimpleJob(URLRequest* request)
: URLRequestJob(request),
data_offset_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
void URLRequestSimpleJob::Start() {
// Start reading asynchronously so that all error reporting and data
// callbacks happen as they would for network requests.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(&URLRequestSimpleJob::StartAsync));
+ base::Bind(&URLRequestSimpleJob::StartAsync,
+ weak_factory_.GetWeakPtr()));
}
bool URLRequestSimpleJob::GetMimeType(std::string* mime_type) const {
diff --git a/net/url_request/url_request_simple_job.h b/net/url_request/url_request_simple_job.h
index 9e22f28..e6b60d0 100644
--- a/net/url_request/url_request_simple_job.h
+++ b/net/url_request/url_request_simple_job.h
@@ -8,7 +8,7 @@
#include <string>
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/base/net_export.h"
#include "net/url_request/url_request_job.h"
@@ -43,7 +43,7 @@ class NET_EXPORT URLRequestSimpleJob : public URLRequestJob {
std::string charset_;
std::string data_;
int data_offset_;
- ScopedRunnableMethodFactory<URLRequestSimpleJob> method_factory_;
+ base::WeakPtrFactory<URLRequestSimpleJob> weak_factory_;
};
} // namespace net
diff --git a/net/url_request/url_request_test_job.cc b/net/url_request/url_request_test_job.cc
index 6668b03..2c8efa6 100644
--- a/net/url_request/url_request_test_job.cc
+++ b/net/url_request/url_request_test_job.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <list>
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/lazy_instance.h"
#include "base/message_loop.h"
@@ -91,7 +92,7 @@ URLRequestTestJob::URLRequestTestJob(URLRequest* request)
offset_(0),
async_buf_(NULL),
async_buf_size_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
URLRequestTestJob::URLRequestTestJob(URLRequest* request,
@@ -102,7 +103,7 @@ URLRequestTestJob::URLRequestTestJob(URLRequest* request,
offset_(0),
async_buf_(NULL),
async_buf_size_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
URLRequestTestJob::URLRequestTestJob(URLRequest* request,
@@ -117,7 +118,7 @@ URLRequestTestJob::URLRequestTestJob(URLRequest* request,
offset_(0),
async_buf_(NULL),
async_buf_size_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
URLRequestTestJob::~URLRequestTestJob() {
@@ -138,8 +139,8 @@ void URLRequestTestJob::Start() {
// Start reading asynchronously so that all error reporting and data
// callbacks happen as they would for network requests.
MessageLoop::current()->PostTask(
- FROM_HERE, method_factory_.NewRunnableMethod(
- &URLRequestTestJob::StartAsync));
+ FROM_HERE, base::Bind(&URLRequestTestJob::StartAsync,
+ weak_factory_.GetWeakPtr()));
}
void URLRequestTestJob::StartAsync() {
@@ -227,7 +228,7 @@ bool URLRequestTestJob::IsRedirectResponse(GURL* location,
void URLRequestTestJob::Kill() {
stage_ = DONE;
URLRequestJob::Kill();
- method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
g_pending_jobs.Get().erase(
std::remove(
g_pending_jobs.Get().begin(), g_pending_jobs.Get().end(), this),
@@ -268,8 +269,8 @@ void URLRequestTestJob::ProcessNextOperation() {
void URLRequestTestJob::AdvanceJob() {
if (auto_advance_) {
MessageLoop::current()->PostTask(
- FROM_HERE, method_factory_.NewRunnableMethod(
- &URLRequestTestJob::ProcessNextOperation));
+ FROM_HERE, base::Bind(&URLRequestTestJob::ProcessNextOperation,
+ weak_factory_.GetWeakPtr()));
return;
}
g_pending_jobs.Get().push_back(this);
diff --git a/net/url_request/url_request_test_job.h b/net/url_request/url_request_test_job.h
index 439e80c..81e41be 100644
--- a/net/url_request/url_request_test_job.h
+++ b/net/url_request/url_request_test_job.h
@@ -8,7 +8,7 @@
#include <string>
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_job.h"
@@ -139,7 +139,7 @@ class NET_EXPORT_PRIVATE URLRequestTestJob : public URLRequestJob {
IOBuffer* async_buf_;
int async_buf_size_;
- ScopedRunnableMethodFactory<URLRequestTestJob> method_factory_;
+ base::WeakPtrFactory<URLRequestTestJob> weak_factory_;
};
} // namespace net