summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 19:25:48 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 19:25:48 +0000
commit915f251d0504a176e4a612a2b2ff2b00592a8819 (patch)
treed1005c9105f1308ab05ae8e93684f43f8da50041 /net/http
parentbadc5a57fd63efdb03ce99e65d4dd9e90a2f870e (diff)
downloadchromium_src-915f251d0504a176e4a612a2b2ff2b00592a8819.zip
chromium_src-915f251d0504a176e4a612a2b2ff2b00592a8819.tar.gz
chromium_src-915f251d0504a176e4a612a2b2ff2b00592a8819.tar.bz2
base::Bind: Remove even moar OldCompletionCallback.
BUG=none TEST=none R=dpapad Review URL: http://codereview.chromium.org/8947024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114838 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache.cc3
-rw-r--r--net/http/mock_http_cache.cc40
-rw-r--r--net/http/mock_http_cache.h5
3 files changed, 20 insertions, 28 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 78b0eaf..8ee0ac6 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -638,7 +638,8 @@ int HttpCache::AsyncDoomEntry(const std::string& key, Transaction* trans) {
BackendCallback* my_callback = new BackendCallback(this, pending_op);
pending_op->callback = my_callback;
- int rv = disk_cache_->DoomEntry(key, my_callback);
+ int rv = disk_cache_->DoomEntry(
+ key, base::Bind(&net::OldCompletionCallbackAdapter, my_callback));
if (rv != ERR_IO_PENDING) {
item->ClearTransaction();
my_callback->Run(rv);
diff --git a/net/http/mock_http_cache.cc b/net/http/mock_http_cache.cc
index 5fe148e..c53453c 100644
--- a/net/http/mock_http_cache.cc
+++ b/net/http/mock_http_cache.cc
@@ -11,6 +11,10 @@
namespace {
+// We can override the test mode for a given operation by setting this global
+// variable.
+int g_test_mode = 0;
+
int GetTestModeForEntry(const std::string& key) {
// 'key' is prefixed with an identifier if it corresponds to a cached POST.
// Skip past that to locate the actual URL.
@@ -31,9 +35,9 @@ int GetTestModeForEntry(const std::string& key) {
return t->test_mode;
}
-// We can override the test mode for a given operation by setting this global
-// variable.
-int g_test_mode = 0;
+void CallbackForwader(const net::CompletionCallback& callback, int result) {
+ callback.Run(result);
+}
} // namespace
@@ -325,20 +329,6 @@ bool MockDiskEntry::ignore_callbacks_ = false;
//-----------------------------------------------------------------------------
-class MockDiskCache::CallbackRunner : public Task {
- public:
- CallbackRunner(net::OldCompletionCallback* callback, int result)
- : callback_(callback), result_(result) {}
- virtual void Run() {
- callback_->Run(result_);
- }
-
- private:
- net::OldCompletionCallback* callback_;
- int result_;
- DISALLOW_COPY_AND_ASSIGN(CallbackRunner);
-};
-
MockDiskCache::MockDiskCache()
: open_count_(0), create_count_(0), fail_requests_(false),
soft_failures_(false), double_create_check_(true) {
@@ -379,7 +369,8 @@ int MockDiskCache::OpenEntry(const std::string& key, disk_cache::Entry** entry,
if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START)
return net::OK;
- CallbackLater(callback, net::OK);
+ CallbackLater(
+ base::Bind(&net::OldCompletionCallbackAdapter, callback), net::OK);
return net::ERR_IO_PENDING;
}
@@ -418,13 +409,14 @@ int MockDiskCache::CreateEntry(const std::string& key,
if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START)
return net::OK;
- CallbackLater(callback, net::OK);
+ CallbackLater(
+ base::Bind(&net::OldCompletionCallbackAdapter, callback), net::OK);
return net::ERR_IO_PENDING;
}
int MockDiskCache::DoomEntry(const std::string& key,
- net::OldCompletionCallback* callback) {
- DCHECK(callback);
+ const net::CompletionCallback& callback) {
+ DCHECK(!callback.is_null());
EntryMap::iterator it = entries_.find(key);
if (it != entries_.end()) {
it->second->Release();
@@ -475,10 +467,10 @@ void MockDiskCache::ReleaseAll() {
entries_.clear();
}
-void MockDiskCache::CallbackLater(net::OldCompletionCallback* callback,
+void MockDiskCache::CallbackLater(const net::CompletionCallback& callback,
int result) {
- MessageLoop::current()->PostTask(FROM_HERE,
- new CallbackRunner(callback, result));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&CallbackForwader, callback, result));
}
//-----------------------------------------------------------------------------
diff --git a/net/http/mock_http_cache.h b/net/http/mock_http_cache.h
index 8e492a9..d934e49 100644
--- a/net/http/mock_http_cache.h
+++ b/net/http/mock_http_cache.h
@@ -101,7 +101,7 @@ class MockDiskCache : public disk_cache::Backend {
virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry,
net::OldCompletionCallback* callback) OVERRIDE;
virtual int DoomEntry(const std::string& key,
- net::OldCompletionCallback* callback) OVERRIDE;
+ const net::CompletionCallback& callback) OVERRIDE;
virtual int DoomAllEntries(const net::CompletionCallback& callback) OVERRIDE;
virtual int DoomEntriesBetween(
const base::Time initial_time,
@@ -135,9 +135,8 @@ class MockDiskCache : public disk_cache::Backend {
private:
typedef base::hash_map<std::string, MockDiskEntry*> EntryMap;
- class CallbackRunner;
- void CallbackLater(net::OldCompletionCallback* callback, int result);
+ void CallbackLater(const net::CompletionCallback& callback, int result);
EntryMap entries_;
int open_count_;