summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-03 06:15:42 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-03 06:15:42 +0000
commit00e48bf0a04e5d50e367b07af1a8ec956825912e (patch)
tree471511ae54d0343d4eb9cf4190b0ab299c5565b4 /net
parent38806d8e6215e6ab65caf305519556a918b81e64 (diff)
downloadchromium_src-00e48bf0a04e5d50e367b07af1a8ec956825912e.zip
chromium_src-00e48bf0a04e5d50e367b07af1a8ec956825912e.tar.gz
chromium_src-00e48bf0a04e5d50e367b07af1a8ec956825912e.tar.bz2
Fix URLRequestHttpJob to use ScopedRunnableMethodFactory.
This will prevent us from leaking SSLClientSockets on shutdown since the certificate related functions complete asynchronously. There's no reason to keep the URLRequestHttpJob alive, since Kill() will cancel the delegates appropriately, so we use ScopedRunnableMethodFactory to avoid AddRef()'ing when we PostTask(). BUG=63692 TEST=existing Review URL: http://codereview.chromium.org/5556004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/url_request/url_request_http_job.cc27
-rw-r--r--net/url_request/url_request_http_job.h3
2 files changed, 21 insertions, 9 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 70e43fe..888e94c 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -98,7 +98,8 @@ URLRequestHttpJob::URLRequestHttpJob(net::URLRequest* request)
sdch_dictionary_advertised_(false),
sdch_test_activated_(false),
sdch_test_control_(false),
- is_cached_content_(false) {
+ is_cached_content_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
}
URLRequestHttpJob::~URLRequestHttpJob() {
@@ -369,8 +370,10 @@ void URLRequestHttpJob::CancelAuth() {
//
// We have to do this via InvokeLater to avoid "recursing" the consumer.
//
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &URLRequestHttpJob::OnStartCompleted, net::OK));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &URLRequestHttpJob::OnStartCompleted, net::OK));
}
void URLRequestHttpJob::ContinueWithCertificate(
@@ -389,8 +392,10 @@ void URLRequestHttpJob::ContinueWithCertificate(
// The transaction started synchronously, but we need to notify the
// net::URLRequest delegate via the message loop.
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &URLRequestHttpJob::OnStartCompleted, rv));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &URLRequestHttpJob::OnStartCompleted, rv));
}
void URLRequestHttpJob::ContinueDespiteLastError() {
@@ -410,8 +415,10 @@ void URLRequestHttpJob::ContinueDespiteLastError() {
// The transaction started synchronously, but we need to notify the
// net::URLRequest delegate via the message loop.
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &URLRequestHttpJob::OnStartCompleted, rv));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &URLRequestHttpJob::OnStartCompleted, rv));
}
bool URLRequestHttpJob::ReadRawData(net::IOBuffer* buf, int buf_size,
@@ -660,8 +667,10 @@ void URLRequestHttpJob::StartTransaction() {
// The transaction started synchronously, but we need to notify the
// net::URLRequest delegate via the message loop.
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &URLRequestHttpJob::OnStartCompleted, rv));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &URLRequestHttpJob::OnStartCompleted, rv));
}
void URLRequestHttpJob::AddExtraHeaders() {
diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h
index c9139b0..471b406 100644
--- a/net/url_request/url_request_http_job.h
+++ b/net/url_request/url_request_http_job.h
@@ -11,6 +11,7 @@
#include "base/scoped_ptr.h"
#include "base/string16.h"
+#include "base/task.h"
#include "net/base/auth.h"
#include "net/base/completion_callback.h"
#include "net/http/http_request_info.h"
@@ -135,6 +136,8 @@ class URLRequestHttpJob : public URLRequestJob {
private:
virtual ~URLRequestHttpJob();
+ ScopedRunnableMethodFactory<URLRequestHttpJob> method_factory_;
+
DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob);
};