summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-22 03:04:11 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-22 03:04:11 +0000
commitbf0580984f1df29bc6e419fac610e521b90ee3e5 (patch)
tree65d13f0ef2139daf70c1b7657c47630e3faba8a3
parent95bba3796b53af298d6ebbd133e148d6579c3bdc (diff)
downloadchromium_src-bf0580984f1df29bc6e419fac610e521b90ee3e5.zip
chromium_src-bf0580984f1df29bc6e419fac610e521b90ee3e5.tar.gz
chromium_src-bf0580984f1df29bc6e419fac610e521b90ee3e5.tar.bz2
base::Bind: COnvert webkit/blob.
BUG=none TEST=none R=csilv Review URL: http://codereview.chromium.org/8949058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115474 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/blob/blob_url_request_job_unittest.cc22
-rw-r--r--webkit/blob/view_blob_internals_job.cc9
-rw-r--r--webkit/blob/view_blob_internals_job.h4
3 files changed, 13 insertions, 22 deletions
diff --git a/webkit/blob/blob_url_request_job_unittest.cc b/webkit/blob/blob_url_request_job_unittest.cc
index 7a5412c..12a0cb7 100644
--- a/webkit/blob/blob_url_request_job_unittest.cc
+++ b/webkit/blob/blob_url_request_job_unittest.cc
@@ -108,21 +108,10 @@ class BlobURLRequestJobTest : public testing::Test {
// Helper class run a test on our io_thread. The io_thread
// is spun up once and reused for all tests.
template <class Method>
- class WrapperTask : public Task {
- public:
- WrapperTask(BlobURLRequestJobTest* test, Method method)
- : test_(test), method_(method) {
- }
-
- virtual void Run() {
- test_->SetUpTest();
- (test_->*method_)();
- }
-
- private:
- BlobURLRequestJobTest* test_;
- Method method_;
- };
+ void MethodWrapper(Method method) {
+ SetUpTest();
+ (this->*method)();
+ }
void SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
@@ -168,7 +157,8 @@ class BlobURLRequestJobTest : public testing::Test {
void RunTestOnIOThread(Method method) {
test_finished_event_ .reset(new base::WaitableEvent(false, false));
io_thread_->message_loop()->PostTask(
- FROM_HERE, new WrapperTask<Method>(this, method));
+ FROM_HERE, base::Bind(&BlobURLRequestJobTest::MethodWrapper<Method>,
+ base::Unretained(this), method));
test_finished_event_->Wait();
}
diff --git a/webkit/blob/view_blob_internals_job.cc b/webkit/blob/view_blob_internals_job.cc
index 84a7497..7d44c38 100644
--- a/webkit/blob/view_blob_internals_job.cc
+++ b/webkit/blob/view_blob_internals_job.cc
@@ -4,6 +4,7 @@
#include "webkit/blob/view_blob_internals_job.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/format_macros.h"
#include "base/i18n/number_formatting.h"
@@ -99,7 +100,7 @@ ViewBlobInternalsJob::ViewBlobInternalsJob(
net::URLRequest* request, BlobStorageController* blob_storage_controller)
: net::URLRequestSimpleJob(request),
blob_storage_controller_(blob_storage_controller),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
ViewBlobInternalsJob::~ViewBlobInternalsJob() {
@@ -107,8 +108,8 @@ ViewBlobInternalsJob::~ViewBlobInternalsJob() {
void ViewBlobInternalsJob::Start() {
MessageLoop::current()->PostTask(
- FROM_HERE,
- method_factory_.NewRunnableMethod(&ViewBlobInternalsJob::DoWorkAsync));
+ FROM_HERE, base::Bind(&ViewBlobInternalsJob::DoWorkAsync,
+ weak_factory_.GetWeakPtr()));
}
bool ViewBlobInternalsJob::IsRedirectResponse(GURL* location,
@@ -126,7 +127,7 @@ bool ViewBlobInternalsJob::IsRedirectResponse(GURL* location,
void ViewBlobInternalsJob::Kill() {
net::URLRequestSimpleJob::Kill();
- method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
}
void ViewBlobInternalsJob::DoWorkAsync() {
diff --git a/webkit/blob/view_blob_internals_job.h b/webkit/blob/view_blob_internals_job.h
index f88f310..1167815 100644
--- a/webkit/blob/view_blob_internals_job.h
+++ b/webkit/blob/view_blob_internals_job.h
@@ -7,7 +7,7 @@
#include <string>
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/url_request/url_request_simple_job.h"
#include "webkit/blob/blob_export.h"
@@ -44,7 +44,7 @@ class BLOB_EXPORT ViewBlobInternalsJob : public net::URLRequestSimpleJob {
std::string* out);
BlobStorageController* blob_storage_controller_;
- ScopedRunnableMethodFactory<ViewBlobInternalsJob> method_factory_;
+ base::WeakPtrFactory<ViewBlobInternalsJob> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ViewBlobInternalsJob);
};