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

Unified Diff: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc

Issue 8985012: base::Bind: Convert net/proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more include. 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/proxy/dhcp_proxy_script_fetcher_win.cc ('k') | net/proxy/mock_proxy_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
index 9c2dc2489aaa12323f5f37e108da58b80443c854..97a6d8e34559031e4162fc635eea516601f60268 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
@@ -6,6 +6,8 @@
#include <vector>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/message_loop.h"
#include "base/perftimer.h"
#include "base/rand_util.h"
@@ -49,8 +51,6 @@ class RealFetchTester {
: context_((new TestURLRequestContext())),
fetcher_(new DhcpProxyScriptFetcherWin(context_.get())),
finished_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- completion_callback_(this, &RealFetchTester::OnCompletion)),
on_completion_is_error_(false) {
// Make sure the test ends.
timeout_.Start(FROM_HERE,
@@ -58,7 +58,9 @@ class RealFetchTester {
}
void RunTest() {
- int result = fetcher_->Fetch(&pac_text_, &completion_callback_);
+ int result = fetcher_->Fetch(
+ &pac_text_,
+ base::Bind(&RealFetchTester::OnCompletion, base::Unretained(this)));
if (result != ERR_IO_PENDING)
finished_ = true;
}
@@ -116,7 +118,6 @@ class RealFetchTester {
scoped_ptr<DhcpProxyScriptFetcherWin> fetcher_;
bool finished_;
string16 pac_text_;
- OldCompletionCallbackImpl<RealFetchTester> completion_callback_;
base::OneShotTimer<RealFetchTester> timeout_;
base::OneShotTimer<RealFetchTester> cancel_timer_;
bool on_completion_is_error_;
@@ -216,13 +217,12 @@ class DummyDhcpProxyScriptAdapterFetcher
did_finish_(false),
result_(OK),
pac_script_(L"bingo"),
- fetch_delay_ms_(1),
- client_callback_(NULL) {
+ fetch_delay_ms_(1) {
}
void Fetch(const std::string& adapter_name,
- OldCompletionCallback* callback) OVERRIDE {
- client_callback_ = callback;
+ const CompletionCallback& callback) OVERRIDE {
+ callback_ = callback;
timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(fetch_delay_ms_),
this, &DummyDhcpProxyScriptAdapterFetcher::OnTimer);
}
@@ -244,7 +244,7 @@ class DummyDhcpProxyScriptAdapterFetcher
}
void OnTimer() {
- client_callback_->Run(result_);
+ callback_.Run(result_);
}
void Configure(
@@ -260,7 +260,7 @@ class DummyDhcpProxyScriptAdapterFetcher
int result_;
string16 pac_script_;
int fetch_delay_ms_;
- OldCompletionCallback* client_callback_;
+ CompletionCallback callback_;
base::OneShotTimer<DummyDhcpProxyScriptAdapterFetcher> timer_;
};
@@ -372,13 +372,13 @@ class FetcherClient {
public:
FetcherClient()
: finished_(false),
- result_(ERR_UNEXPECTED),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- completion_callback_(this, &FetcherClient::OnCompletion)) {
+ result_(ERR_UNEXPECTED) {
}
void RunTest() {
- int result = fetcher_.Fetch(&pac_text_, &completion_callback_);
+ int result = fetcher_.Fetch(
+ &pac_text_,
+ base::Bind(&FetcherClient::OnCompletion, base::Unretained(this)));
ASSERT_EQ(ERR_IO_PENDING, result);
}
@@ -413,7 +413,6 @@ public:
bool finished_;
int result_;
string16 pac_text_;
- OldCompletionCallbackImpl<FetcherClient> completion_callback_;
};
// We separate out each test's logic so that we can easily implement
« no previous file with comments | « net/proxy/dhcp_proxy_script_fetcher_win.cc ('k') | net/proxy/mock_proxy_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698