summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/resolve_proxy_msg_helper.cc15
-rw-r--r--content/browser/resolve_proxy_msg_helper.h3
-rw-r--r--net/http/http_network_transaction_unittest.cc4
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc20
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win.h8
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc4
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher.cc4
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher.h4
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win.cc19
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win.h8
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc29
-rw-r--r--net/proxy/mock_proxy_resolver.cc26
-rw-r--r--net/proxy/mock_proxy_resolver.h16
-rw-r--r--net/proxy/mock_proxy_script_fetcher.cc17
-rw-r--r--net/proxy/mock_proxy_script_fetcher.h5
-rw-r--r--net/proxy/multi_threaded_proxy_resolver.cc57
-rw-r--r--net/proxy/multi_threaded_proxy_resolver.h4
-rw-r--r--net/proxy/multi_threaded_proxy_resolver_unittest.cc150
-rw-r--r--net/proxy/network_delegate_error_observer.cc4
-rw-r--r--net/proxy/network_delegate_error_observer_unittest.cc14
-rw-r--r--net/proxy/polling_proxy_config_service.cc5
-rw-r--r--net/proxy/proxy_config_service_mac.cc4
-rw-r--r--net/proxy/proxy_resolver.h4
-rw-r--r--net/proxy/proxy_resolver_mac.cc4
-rw-r--r--net/proxy/proxy_resolver_mac.h4
-rw-r--r--net/proxy/proxy_resolver_perftest.cc16
-rw-r--r--net/proxy/proxy_resolver_v8.cc12
-rw-r--r--net/proxy/proxy_resolver_v8.h4
-rw-r--r--net/proxy/proxy_resolver_v8_unittest.cc96
-rw-r--r--net/proxy/proxy_resolver_winhttp.cc4
-rw-r--r--net/proxy/proxy_resolver_winhttp.h4
-rw-r--r--net/proxy/proxy_script_decider.cc27
-rw-r--r--net/proxy/proxy_script_decider.h5
-rw-r--r--net/proxy/proxy_script_decider_unittest.cc81
-rw-r--r--net/proxy/proxy_script_fetcher.h2
-rw-r--r--net/proxy/proxy_script_fetcher_impl.cc24
-rw-r--r--net/proxy/proxy_script_fetcher_impl.h7
-rw-r--r--net/proxy/proxy_script_fetcher_impl_unittest.cc72
-rw-r--r--net/proxy/proxy_service.cc133
-rw-r--r--net/proxy/proxy_service.h8
-rw-r--r--net/proxy/proxy_service_unittest.cc310
-rw-r--r--net/proxy/sync_host_resolver_bridge.cc3
-rw-r--r--net/proxy/sync_host_resolver_bridge_unittest.cc17
-rw-r--r--net/socket_stream/socket_stream.cc4
-rw-r--r--net/socket_stream/socket_stream.h3
45 files changed, 600 insertions, 664 deletions
diff --git a/content/browser/resolve_proxy_msg_helper.cc b/content/browser/resolve_proxy_msg_helper.cc
index 9d984d7..65a12a0 100644
--- a/content/browser/resolve_proxy_msg_helper.cc
+++ b/content/browser/resolve_proxy_msg_helper.cc
@@ -4,6 +4,8 @@
#include "content/browser/resolve_proxy_msg_helper.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "content/common/view_messages.h"
#include "net/base/net_errors.h"
@@ -12,16 +14,12 @@
ResolveProxyMsgHelper::ResolveProxyMsgHelper(
net::URLRequestContextGetter* getter)
- : ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
- this, &ResolveProxyMsgHelper::OnResolveProxyCompleted)),
- context_getter_(getter),
+ : context_getter_(getter),
proxy_service_(NULL) {
}
ResolveProxyMsgHelper::ResolveProxyMsgHelper(net::ProxyService* proxy_service)
- : ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
- this, &ResolveProxyMsgHelper::OnResolveProxyCompleted)),
- proxy_service_(proxy_service) {
+ : proxy_service_(proxy_service) {
}
bool ResolveProxyMsgHelper::OnMessageReceived(const IPC::Message& message,
@@ -73,7 +71,10 @@ void ResolveProxyMsgHelper::StartPendingRequest() {
// Start the request.
int result = proxy_service_->ResolveProxy(
- req.url, &proxy_info_, &callback_, &req.pac_req, net::BoundNetLog());
+ req.url, &proxy_info_,
+ base::Bind(&ResolveProxyMsgHelper::OnResolveProxyCompleted,
+ base::Unretained(this)),
+ &req.pac_req, net::BoundNetLog());
// Completed synchronously.
if (result != net::ERR_IO_PENDING)
diff --git a/content/browser/resolve_proxy_msg_helper.h b/content/browser/resolve_proxy_msg_helper.h
index e80b396..920ff74 100644
--- a/content/browser/resolve_proxy_msg_helper.h
+++ b/content/browser/resolve_proxy_msg_helper.h
@@ -70,8 +70,7 @@ class CONTENT_EXPORT ResolveProxyMsgHelper
net::ProxyService::PacRequest* pac_req;
};
- // Members for the current outstanding proxy request.
- net::OldCompletionCallbackImpl<ResolveProxyMsgHelper> callback_;
+ // Info about the current outstanding proxy request.
net::ProxyInfo proxy_info_;
// FIFO queue of pending requests. The first entry is always the current one.
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 9284f76..04308ab 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -7075,7 +7075,7 @@ class CapturingProxyResolver : public ProxyResolver {
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) {
ProxyServer proxy_server(ProxyServer::SCHEME_HTTP,
@@ -7105,7 +7105,7 @@ class CapturingProxyResolver : public ProxyResolver {
}
virtual int SetPacScript(const scoped_refptr<ProxyResolverScriptData>&,
- OldCompletionCallback* /*callback*/) {
+ const CompletionCallback& /*callback*/) {
return OK;
}
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc
index 5a24c63..660b49f 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc
@@ -5,6 +5,7 @@
#include "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/message_loop_proxy.h"
#include "base/metrics/histogram.h"
#include "base/sys_string_conversions.h"
@@ -33,10 +34,6 @@ DhcpProxyScriptAdapterFetcher::DhcpProxyScriptAdapterFetcher(
URLRequestContext* url_request_context)
: state_(STATE_START),
result_(ERR_IO_PENDING),
- callback_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- script_fetcher_callback_(
- this, &DhcpProxyScriptAdapterFetcher::OnFetcherDone)),
url_request_context_(url_request_context) {
}
@@ -50,7 +47,7 @@ DhcpProxyScriptAdapterFetcher::~DhcpProxyScriptAdapterFetcher() {
}
void DhcpProxyScriptAdapterFetcher::Fetch(
- const std::string& adapter_name, OldCompletionCallback* callback) {
+ const std::string& adapter_name, const CompletionCallback& callback) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(state_, STATE_START);
result_ = ERR_IO_PENDING;
@@ -76,7 +73,7 @@ void DhcpProxyScriptAdapterFetcher::Fetch(
void DhcpProxyScriptAdapterFetcher::Cancel() {
DCHECK(CalledOnValidThread());
- callback_ = NULL;
+ callback_.Reset();
wait_timer_.Stop();
script_fetcher_.reset();
@@ -161,7 +158,10 @@ void DhcpProxyScriptAdapterFetcher::OnDhcpQueryDone(
} else {
state_ = STATE_WAIT_URL;
script_fetcher_.reset(ImplCreateScriptFetcher());
- script_fetcher_->Fetch(pac_url_, &pac_script_, &script_fetcher_callback_);
+ script_fetcher_->Fetch(
+ pac_url_, &pac_script_,
+ base::Bind(&DhcpProxyScriptAdapterFetcher::OnFetcherDone,
+ base::Unretained(this)));
}
}
@@ -186,12 +186,12 @@ void DhcpProxyScriptAdapterFetcher::OnFetcherDone(int result) {
void DhcpProxyScriptAdapterFetcher::TransitionToFinish() {
DCHECK(state_ == STATE_WAIT_DHCP || state_ == STATE_WAIT_URL);
state_ = STATE_FINISH;
- OldCompletionCallback* callback = callback_;
- callback_ = NULL;
+ CompletionCallback callback = callback_;
+ callback_.Reset();
// Be careful not to touch any member state after this, as the client
// may delete us during this callback.
- callback->Run(result_);
+ callback.Run(result_);
}
DhcpProxyScriptAdapterFetcher::State
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h
index 562441f..54954fc 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h
@@ -43,7 +43,7 @@ class NET_EXPORT_PRIVATE DhcpProxyScriptAdapterFetcher
// You may only call Fetch() once on a given instance of
// DhcpProxyScriptAdapterFetcher.
virtual void Fetch(const std::string& adapter_name,
- OldCompletionCallback* callback);
+ const net::CompletionCallback& callback);
// Cancels the fetch on this adapter.
virtual void Cancel();
@@ -159,15 +159,11 @@ class NET_EXPORT_PRIVATE DhcpProxyScriptAdapterFetcher
// Callback to let our client know we're done. Invalid in states
// START, FINISH and CANCEL.
- OldCompletionCallback* callback_;
+ net::CompletionCallback callback_;
// Fetcher to retrieve PAC files once URL is known.
scoped_ptr<ProxyScriptFetcher> script_fetcher_;
- // Callback from the script fetcher.
- OldCompletionCallbackImpl<DhcpProxyScriptAdapterFetcher>
- script_fetcher_callback_;
-
// Implements a timeout on the call to the Win32 DHCP API.
base::OneShotTimer<DhcpProxyScriptAdapterFetcher> wait_timer_;
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
index 57f02f5..ff75fbe 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
@@ -141,7 +141,7 @@ class FetcherClient {
}
void RunTest() {
- fetcher_->Fetch("adapter name", &callback_);
+ fetcher_->Fetch("adapter name", callback_.callback());
}
void FinishTestAllowCleanup() {
@@ -149,7 +149,7 @@ class FetcherClient {
MessageLoop::current()->RunAllPending();
}
- TestOldCompletionCallback callback_;
+ TestCompletionCallback callback_;
scoped_refptr<URLRequestContext> url_request_context_;
scoped_ptr<MockDhcpProxyScriptAdapterFetcher> fetcher_;
string16 pac_text_;
diff --git a/net/proxy/dhcp_proxy_script_fetcher.cc b/net/proxy/dhcp_proxy_script_fetcher.cc
index 2d6f526..a13c1c4 100644
--- a/net/proxy/dhcp_proxy_script_fetcher.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher.cc
@@ -24,8 +24,8 @@ DoNothingDhcpProxyScriptFetcher::DoNothingDhcpProxyScriptFetcher() {
DoNothingDhcpProxyScriptFetcher::~DoNothingDhcpProxyScriptFetcher() {
}
-int DoNothingDhcpProxyScriptFetcher::Fetch(string16* utf16_text,
- OldCompletionCallback* callback) {
+int DoNothingDhcpProxyScriptFetcher::Fetch(
+ string16* utf16_text, const CompletionCallback& callback) {
return ERR_NOT_IMPLEMENTED;
}
diff --git a/net/proxy/dhcp_proxy_script_fetcher.h b/net/proxy/dhcp_proxy_script_fetcher.h
index cd98a87..101ddff 100644
--- a/net/proxy/dhcp_proxy_script_fetcher.h
+++ b/net/proxy/dhcp_proxy_script_fetcher.h
@@ -58,7 +58,7 @@ class NET_EXPORT_PRIVATE DhcpProxyScriptFetcher {
//
// Only one fetch is allowed to be outstanding at a time.
virtual int Fetch(string16* utf16_text,
- OldCompletionCallback* callback) = 0;
+ const CompletionCallback& callback) = 0;
// Aborts the in-progress fetch (if any).
virtual void Cancel() = 0;
@@ -87,7 +87,7 @@ class NET_EXPORT_PRIVATE DoNothingDhcpProxyScriptFetcher
virtual ~DoNothingDhcpProxyScriptFetcher();
virtual int Fetch(string16* utf16_text,
- OldCompletionCallback* callback) OVERRIDE;
+ const CompletionCallback& callback) OVERRIDE;
virtual void Cancel() OVERRIDE;
virtual const GURL& GetPacURL() const OVERRIDE;
private:
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win.cc b/net/proxy/dhcp_proxy_script_fetcher_win.cc
index 9ec7113..cec2b1c 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win.cc
@@ -5,6 +5,7 @@
#include "net/proxy/dhcp_proxy_script_fetcher_win.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/metrics/histogram.h"
#include "base/perftimer.h"
#include "base/threading/worker_pool.h"
@@ -37,8 +38,6 @@ namespace net {
DhcpProxyScriptFetcherWin::DhcpProxyScriptFetcherWin(
URLRequestContext* url_request_context)
: state_(STATE_START),
- ALLOW_THIS_IN_INITIALIZER_LIST(fetcher_callback_(
- this, &DhcpProxyScriptFetcherWin::OnFetcherDone)),
num_pending_fetchers_(0),
url_request_context_(url_request_context) {
DCHECK(url_request_context_);
@@ -55,7 +54,7 @@ DhcpProxyScriptFetcherWin::~DhcpProxyScriptFetcherWin() {
}
int DhcpProxyScriptFetcherWin::Fetch(string16* utf16_text,
- OldCompletionCallback* callback) {
+ const CompletionCallback& callback) {
DCHECK(CalledOnValidThread());
if (state_ != STATE_START && state_ != STATE_DONE) {
NOTREACHED();
@@ -65,7 +64,7 @@ int DhcpProxyScriptFetcherWin::Fetch(string16* utf16_text,
fetch_start_time_ = base::TimeTicks::Now();
state_ = STATE_WAIT_ADAPTERS;
- client_callback_ = callback;
+ callback_ = callback;
destination_string_ = utf16_text;
last_query_ = ImplCreateAdapterQuery();
@@ -100,7 +99,7 @@ void DhcpProxyScriptFetcherWin::CancelImpl() {
DCHECK(CalledOnValidThread());
if (state_ != STATE_DONE) {
- client_callback_ = NULL;
+ callback_.Reset();
wait_timer_.Stop();
state_ = STATE_DONE;
@@ -145,7 +144,9 @@ void DhcpProxyScriptFetcherWin::OnGetCandidateAdapterNamesDone(
it != adapter_names.end();
++it) {
DhcpProxyScriptAdapterFetcher* fetcher(ImplCreateAdapterFetcher());
- fetcher->Fetch(*it, &fetcher_callback_);
+ fetcher->Fetch(
+ *it, base::Bind(&DhcpProxyScriptFetcherWin::OnFetcherDone,
+ base::Unretained(this)));
fetchers_.push_back(fetcher);
}
num_pending_fetchers_ = fetchers_.size();
@@ -245,11 +246,11 @@ void DhcpProxyScriptFetcherWin::TransitionToDone() {
}
}
- OldCompletionCallback* callback = client_callback_;
+ CompletionCallback callback = callback_;
CancelImpl();
DCHECK_EQ(state_, STATE_DONE);
DCHECK(fetchers_.empty());
- DCHECK(!client_callback_); // Invariant of data.
+ DCHECK(callback_.is_null()); // Invariant of data.
UMA_HISTOGRAM_TIMES("Net.DhcpWpadCompletionTime",
base::TimeTicks::Now() - fetch_start_time_);
@@ -260,7 +261,7 @@ void DhcpProxyScriptFetcherWin::TransitionToDone() {
}
// We may be deleted re-entrantly within this outcall.
- callback->Run(result);
+ callback.Run(result);
}
int DhcpProxyScriptFetcherWin::num_pending_fetchers() const {
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win.h b/net/proxy/dhcp_proxy_script_fetcher_win.h
index 0d7dc3e..ce6c7dc 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win.h
+++ b/net/proxy/dhcp_proxy_script_fetcher_win.h
@@ -35,7 +35,8 @@ class NET_EXPORT_PRIVATE DhcpProxyScriptFetcherWin
virtual ~DhcpProxyScriptFetcherWin();
// DhcpProxyScriptFetcher implementation.
- int Fetch(string16* utf16_text, OldCompletionCallback* callback) OVERRIDE;
+ int Fetch(string16* utf16_text,
+ const net::CompletionCallback& callback) OVERRIDE;
void Cancel() OVERRIDE;
const GURL& GetPacURL() const OVERRIDE;
std::string GetFetcherName() const OVERRIDE;
@@ -138,14 +139,11 @@ class NET_EXPORT_PRIVATE DhcpProxyScriptFetcherWin
typedef ScopedVector<DhcpProxyScriptAdapterFetcher> FetcherVector;
FetcherVector fetchers_;
- // Callback invoked when any fetcher completes.
- OldCompletionCallbackImpl<DhcpProxyScriptFetcherWin> fetcher_callback_;
-
// Number of fetchers we are waiting for.
int num_pending_fetchers_;
// Lets our client know we're done. Not valid in states START or DONE.
- OldCompletionCallback* client_callback_;
+ net::CompletionCallback callback_;
// Pointer to string we will write results to. Not valid in states
// START and DONE.
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
index 9c2dc24..97a6d8e 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
diff --git a/net/proxy/mock_proxy_resolver.cc b/net/proxy/mock_proxy_resolver.cc
index 597a06c..a7fe409 100644
--- a/net/proxy/mock_proxy_resolver.cc
+++ b/net/proxy/mock_proxy_resolver.cc
@@ -10,10 +10,8 @@
namespace net {
MockAsyncProxyResolverBase::Request::Request(
- MockAsyncProxyResolverBase* resolver,
- const GURL& url,
- ProxyInfo* results,
- OldCompletionCallback* callback)
+ MockAsyncProxyResolverBase* resolver, const GURL& url, ProxyInfo* results,
+ const CompletionCallback& callback)
: resolver_(resolver),
url_(url),
results_(results),
@@ -22,12 +20,12 @@ MockAsyncProxyResolverBase::Request::Request(
}
void MockAsyncProxyResolverBase::Request::CompleteNow(int rv) {
- OldCompletionCallback* callback = callback_;
+ CompletionCallback callback = callback_;
// May delete |this|.
resolver_->RemovePendingRequest(this);
- callback->Run(rv);
+ callback.Run(rv);
}
MockAsyncProxyResolverBase::Request::~Request() {}
@@ -36,7 +34,7 @@ MockAsyncProxyResolverBase::Request::~Request() {}
MockAsyncProxyResolverBase::SetPacScriptRequest::SetPacScriptRequest(
MockAsyncProxyResolverBase* resolver,
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback)
+ const CompletionCallback& callback)
: resolver_(resolver),
script_data_(script_data),
callback_(callback),
@@ -46,21 +44,19 @@ MockAsyncProxyResolverBase::SetPacScriptRequest::SetPacScriptRequest(
MockAsyncProxyResolverBase::SetPacScriptRequest::~SetPacScriptRequest() {}
void MockAsyncProxyResolverBase::SetPacScriptRequest::CompleteNow(int rv) {
- OldCompletionCallback* callback = callback_;
+ CompletionCallback callback = callback_;
// Will delete |this|.
resolver_->RemovePendingSetPacScriptRequest(this);
- callback->Run(rv);
+ callback.Run(rv);
}
MockAsyncProxyResolverBase::~MockAsyncProxyResolverBase() {}
-int MockAsyncProxyResolverBase::GetProxyForURL(const GURL& url,
- ProxyInfo* results,
- OldCompletionCallback* callback,
- RequestHandle* request_handle,
- const BoundNetLog& /*net_log*/) {
+int MockAsyncProxyResolverBase::GetProxyForURL(
+ const GURL& url, ProxyInfo* results, const CompletionCallback& callback,
+ RequestHandle* request_handle, const BoundNetLog& /*net_log*/) {
scoped_refptr<Request> request = new Request(this, url, results, callback);
pending_requests_.push_back(request);
@@ -91,7 +87,7 @@ LoadState MockAsyncProxyResolverBase::GetLoadStateThreadSafe(
int MockAsyncProxyResolverBase::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback) {
+ const CompletionCallback& callback) {
DCHECK(!pending_set_pac_script_request_.get());
pending_set_pac_script_request_.reset(
new SetPacScriptRequest(this, script_data, callback));
diff --git a/net/proxy/mock_proxy_resolver.h b/net/proxy/mock_proxy_resolver.h
index bff2a71..bf1b4a9 100644
--- a/net/proxy/mock_proxy_resolver.h
+++ b/net/proxy/mock_proxy_resolver.h
@@ -26,11 +26,11 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
Request(MockAsyncProxyResolverBase* resolver,
const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback);
+ const net::CompletionCallback& callback);
const GURL& url() const { return url_; }
ProxyInfo* results() const { return results_; }
- OldCompletionCallback* callback() const { return callback_; }
+ const net::CompletionCallback& callback() const { return callback_; }
void CompleteNow(int rv);
@@ -42,7 +42,7 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
MockAsyncProxyResolverBase* resolver_;
const GURL url_;
ProxyInfo* results_;
- OldCompletionCallback* callback_;
+ net::CompletionCallback callback_;
MessageLoop* origin_loop_;
};
@@ -51,7 +51,7 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
SetPacScriptRequest(
MockAsyncProxyResolverBase* resolver,
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback);
+ const net::CompletionCallback& callback);
~SetPacScriptRequest();
const ProxyResolverScriptData* script_data() const { return script_data_; }
@@ -61,7 +61,7 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
private:
MockAsyncProxyResolverBase* resolver_;
const scoped_refptr<ProxyResolverScriptData> script_data_;
- OldCompletionCallback* callback_;
+ net::CompletionCallback callback_;
MessageLoop* origin_loop_;
};
@@ -69,10 +69,10 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
virtual ~MockAsyncProxyResolverBase();
- // ProxyResolver implementation:
+ // ProxyResolver implementation.
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const net::CompletionCallback& callback,
RequestHandle* request_handle,
const BoundNetLog& /*net_log*/) OVERRIDE;
virtual void CancelRequest(RequestHandle request_handle) OVERRIDE;
@@ -81,7 +81,7 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
RequestHandle request_handle) const OVERRIDE;
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback) OVERRIDE;
+ const net::CompletionCallback& callback) OVERRIDE;
virtual void CancelSetPacScript() OVERRIDE;
const RequestsList& pending_requests() const {
diff --git a/net/proxy/mock_proxy_script_fetcher.cc b/net/proxy/mock_proxy_script_fetcher.cc
index 1c695b7..9aeab1c 100644
--- a/net/proxy/mock_proxy_script_fetcher.cc
+++ b/net/proxy/mock_proxy_script_fetcher.cc
@@ -12,13 +12,14 @@
namespace net {
MockProxyScriptFetcher::MockProxyScriptFetcher()
- : pending_request_callback_(NULL), pending_request_text_(NULL) {
+ : pending_request_text_(NULL) {
}
+MockProxyScriptFetcher::~MockProxyScriptFetcher() {}
+
// ProxyScriptFetcher implementation.
-int MockProxyScriptFetcher::Fetch(const GURL& url,
- string16* text,
- OldCompletionCallback* callback) {
+int MockProxyScriptFetcher::Fetch(const GURL& url, string16* text,
+ const CompletionCallback& callback) {
DCHECK(!has_pending_request());
// Save the caller's information, and have them wait.
@@ -32,9 +33,9 @@ void MockProxyScriptFetcher::NotifyFetchCompletion(
int result, const std::string& ascii_text) {
DCHECK(has_pending_request());
*pending_request_text_ = ASCIIToUTF16(ascii_text);
- OldCompletionCallback* callback = pending_request_callback_;
- pending_request_callback_ = NULL;
- callback->Run(result);
+ CompletionCallback callback = pending_request_callback_;
+ pending_request_callback_.Reset();
+ callback.Run(result);
}
void MockProxyScriptFetcher::Cancel() {
@@ -49,7 +50,7 @@ const GURL& MockProxyScriptFetcher::pending_request_url() const {
}
bool MockProxyScriptFetcher::has_pending_request() const {
- return pending_request_callback_ != NULL;
+ return !pending_request_callback_.is_null();
}
} // namespace net
diff --git a/net/proxy/mock_proxy_script_fetcher.h b/net/proxy/mock_proxy_script_fetcher.h
index 9ddd780..4e88c17 100644
--- a/net/proxy/mock_proxy_script_fetcher.h
+++ b/net/proxy/mock_proxy_script_fetcher.h
@@ -21,11 +21,12 @@ class URLRequestContext;
class MockProxyScriptFetcher : public ProxyScriptFetcher {
public:
MockProxyScriptFetcher();
+ virtual ~MockProxyScriptFetcher();
// ProxyScriptFetcher implementation.
virtual int Fetch(const GURL& url,
string16* text,
- OldCompletionCallback* callback) OVERRIDE;
+ const CompletionCallback& callback) OVERRIDE;
virtual void Cancel() OVERRIDE;
virtual URLRequestContext* GetRequestContext() const OVERRIDE;
@@ -35,7 +36,7 @@ class MockProxyScriptFetcher : public ProxyScriptFetcher {
private:
GURL pending_request_url_;
- OldCompletionCallback* pending_request_callback_;
+ CompletionCallback pending_request_callback_;
string16* pending_request_text_;
};
diff --git a/net/proxy/multi_threaded_proxy_resolver.cc b/net/proxy/multi_threaded_proxy_resolver.cc
index 03c3e44..e971f6c 100644
--- a/net/proxy/multi_threaded_proxy_resolver.cc
+++ b/net/proxy/multi_threaded_proxy_resolver.cc
@@ -4,6 +4,7 @@
#include "net/proxy/multi_threaded_proxy_resolver.h"
+#include "base/bind.h"
#include "base/message_loop_proxy.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
@@ -100,9 +101,9 @@ class MultiThreadedProxyResolver::Job
TYPE_SET_PAC_SCRIPT_INTERNAL,
};
- Job(Type type, OldCompletionCallback* user_callback)
+ Job(Type type, const CompletionCallback& callback)
: type_(type),
- user_callback_(user_callback),
+ callback_(callback),
executor_(NULL),
was_cancelled_(false) {
}
@@ -133,8 +134,8 @@ class MultiThreadedProxyResolver::Job
// scheduled internally (for example TYPE_SET_PAC_SCRIPT_INTERNAL).
//
// Otherwise jobs that correspond with user-initiated work will
- // have a non-NULL callback up until the callback is run.
- bool has_user_callback() const { return user_callback_ != NULL; }
+ // have a non-null callback up until the callback is run.
+ bool has_user_callback() const { return !callback_.is_null(); }
// This method is called when the job is inserted into a wait queue
// because no executors were ready to accept it.
@@ -157,10 +158,10 @@ class MultiThreadedProxyResolver::Job
void RunUserCallback(int result) {
DCHECK(has_user_callback());
- OldCompletionCallback* callback = user_callback_;
- // Null the callback so has_user_callback() will now return false.
- user_callback_ = NULL;
- callback->Run(result);
+ CompletionCallback callback = callback_;
+ // Reset the callback so has_user_callback() will now return false.
+ callback_.Reset();
+ callback.Run(result);
}
friend class base::RefCountedThreadSafe<MultiThreadedProxyResolver::Job>;
@@ -169,7 +170,7 @@ class MultiThreadedProxyResolver::Job
private:
const Type type_;
- OldCompletionCallback* user_callback_;
+ CompletionCallback callback_;
Executor* executor_;
bool was_cancelled_;
};
@@ -181,8 +182,9 @@ class MultiThreadedProxyResolver::SetPacScriptJob
: public MultiThreadedProxyResolver::Job {
public:
SetPacScriptJob(const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback)
- : Job(callback ? TYPE_SET_PAC_SCRIPT : TYPE_SET_PAC_SCRIPT_INTERNAL,
+ const CompletionCallback& callback)
+ : Job(!callback.is_null() ? TYPE_SET_PAC_SCRIPT :
+ TYPE_SET_PAC_SCRIPT_INTERNAL,
callback),
script_data_(script_data) {
}
@@ -190,12 +192,12 @@ class MultiThreadedProxyResolver::SetPacScriptJob
// Runs on the worker thread.
virtual void Run(scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE {
ProxyResolver* resolver = executor()->resolver();
- int rv = resolver->SetPacScript(script_data_, NULL);
+ int rv = resolver->SetPacScript(script_data_, CompletionCallback());
DCHECK_NE(rv, ERR_IO_PENDING);
origin_loop->PostTask(
FROM_HERE,
- NewRunnableMethod(this, &SetPacScriptJob::RequestComplete, rv));
+ base::Bind(&SetPacScriptJob::RequestComplete, this, rv));
}
private:
@@ -220,14 +222,14 @@ class MultiThreadedProxyResolver::GetProxyForURLJob
// |results| -- the structure to fill with proxy resolve results.
GetProxyForURLJob(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
const BoundNetLog& net_log)
: Job(TYPE_GET_PROXY_FOR_URL, callback),
results_(results),
net_log_(net_log),
url_(url),
was_waiting_for_thread_(false) {
- DCHECK(callback);
+ DCHECK(!callback.is_null());
}
BoundNetLog* net_log() { return &net_log_; }
@@ -256,12 +258,12 @@ class MultiThreadedProxyResolver::GetProxyForURLJob
virtual void Run(scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE {
ProxyResolver* resolver = executor()->resolver();
int rv = resolver->GetProxyForURL(
- url_, &results_buf_, NULL, NULL, net_log_);
+ url_, &results_buf_, CompletionCallback(), NULL, net_log_);
DCHECK_NE(rv, ERR_IO_PENDING);
origin_loop->PostTask(
FROM_HERE,
- NewRunnableMethod(this, &GetProxyForURLJob::QueryComplete, rv));
+ base::Bind(&GetProxyForURLJob::QueryComplete, this, rv));
}
private:
@@ -320,8 +322,7 @@ void MultiThreadedProxyResolver::Executor::StartJob(Job* job) {
job->FinishedWaitingForThread();
thread_->message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(job, &Job::Run,
- base::MessageLoopProxy::current()));
+ base::Bind(&Job::Run, job, base::MessageLoopProxy::current()));
}
void MultiThreadedProxyResolver::Executor::OnJobCompleted(Job* job) {
@@ -366,7 +367,7 @@ void MultiThreadedProxyResolver::Executor::PurgeMemory() {
scoped_refptr<PurgeMemoryTask> helper(new PurgeMemoryTask(resolver_.get()));
thread_->message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(helper.get(), &PurgeMemoryTask::PurgeMemory));
+ base::Bind(&PurgeMemoryTask::PurgeMemory, helper.get()));
}
MultiThreadedProxyResolver::Executor::~Executor() {
@@ -395,13 +396,11 @@ MultiThreadedProxyResolver::~MultiThreadedProxyResolver() {
ReleaseAllExecutors();
}
-int MultiThreadedProxyResolver::GetProxyForURL(const GURL& url,
- ProxyInfo* results,
- OldCompletionCallback* callback,
- RequestHandle* request,
- const BoundNetLog& net_log) {
+int MultiThreadedProxyResolver::GetProxyForURL(
+ const GURL& url, ProxyInfo* results, const CompletionCallback& callback,
+ RequestHandle* request, const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread());
- DCHECK(callback);
+ DCHECK(!callback.is_null());
DCHECK(current_script_data_.get())
<< "Resolver is un-initialized. Must call SetPacScript() first!";
@@ -431,7 +430,7 @@ int MultiThreadedProxyResolver::GetProxyForURL(const GURL& url,
if (executors_.size() < max_num_threads_) {
executor = AddNewExecutor();
executor->StartJob(
- new SetPacScriptJob(current_script_data_, NULL));
+ new SetPacScriptJob(current_script_data_, CompletionCallback()));
}
return ERR_IO_PENDING;
@@ -498,9 +497,9 @@ void MultiThreadedProxyResolver::PurgeMemory() {
int MultiThreadedProxyResolver::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback) {
+ const CompletionCallback&callback) {
DCHECK(CalledOnValidThread());
- DCHECK(callback);
+ DCHECK(!callback.is_null());
// Save the script details, so we can provision new executors later.
current_script_data_ = script_data;
diff --git a/net/proxy/multi_threaded_proxy_resolver.h b/net/proxy/multi_threaded_proxy_resolver.h
index deca2a5..73c3aba 100644
--- a/net/proxy/multi_threaded_proxy_resolver.h
+++ b/net/proxy/multi_threaded_proxy_resolver.h
@@ -94,7 +94,7 @@ class NET_EXPORT_PRIVATE MultiThreadedProxyResolver
// ProxyResolver implementation:
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle request) OVERRIDE;
@@ -105,7 +105,7 @@ class NET_EXPORT_PRIVATE MultiThreadedProxyResolver
virtual void PurgeMemory() OVERRIDE;
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback) OVERRIDE;
+ const CompletionCallback& callback) OVERRIDE;
private:
class Executor;
diff --git a/net/proxy/multi_threaded_proxy_resolver_unittest.cc b/net/proxy/multi_threaded_proxy_resolver_unittest.cc
index 481d5b5..59c33f4 100644
--- a/net/proxy/multi_threaded_proxy_resolver_unittest.cc
+++ b/net/proxy/multi_threaded_proxy_resolver_unittest.cc
@@ -35,10 +35,10 @@ class MockProxyResolver : public ProxyResolver {
purge_count_(0),
resolve_latency_ms_(0) {}
- // ProxyResolver implementation:
+ // ProxyResolver implementation.
virtual int GetProxyForURL(const GURL& query_url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE {
if (resolve_latency_ms_)
@@ -46,7 +46,7 @@ class MockProxyResolver : public ProxyResolver {
CheckIsOnWorkerThread();
- EXPECT_TRUE(callback == NULL);
+ EXPECT_TRUE(callback.is_null());
EXPECT_TRUE(request == NULL);
// Write something into |net_log| (doesn't really have any meaning.)
@@ -79,7 +79,7 @@ class MockProxyResolver : public ProxyResolver {
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback) OVERRIDE {
+ const CompletionCallback& callback) OVERRIDE {
CheckIsOnWorkerThread();
last_script_data_ = script_data;
return OK;
@@ -148,7 +148,7 @@ class BlockableProxyResolver : public MockProxyResolver {
virtual int GetProxyForURL(const GURL& query_url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE {
if (should_block_) {
@@ -175,7 +175,7 @@ class ForwardingProxyResolver : public ProxyResolver {
virtual int GetProxyForURL(const GURL& query_url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE {
return impl_->GetProxyForURL(
@@ -203,7 +203,7 @@ class ForwardingProxyResolver : public ProxyResolver {
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback) OVERRIDE {
+ const CompletionCallback& callback) OVERRIDE {
return impl_->SetPacScript(script_data, callback);
}
@@ -266,21 +266,21 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_Basic) {
// Call SetPacScriptByData() -- verify that it reaches the synchronous
// resolver.
- TestOldCompletionCallback set_script_callback;
+ TestCompletionCallback set_script_callback;
rv = resolver.SetPacScript(
ProxyResolverScriptData::FromUTF8("pac script bytes"),
- &set_script_callback);
+ set_script_callback.callback());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, set_script_callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("pac script bytes"),
mock->last_script_data()->utf16());
// Start request 0.
- TestOldCompletionCallback callback0;
+ TestCompletionCallback callback0;
CapturingBoundNetLog log0(CapturingNetLog::kUnbounded);
ProxyInfo results0;
- rv = resolver.GetProxyForURL(
- GURL("http://request0"), &results0, &callback0, NULL, log0.bound());
+ rv = resolver.GetProxyForURL(GURL("http://request0"), &results0,
+ callback0.callback(), NULL, log0.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Wait for request 0 to finish.
@@ -300,22 +300,22 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_Basic) {
// Start 3 more requests (request1 to request3).
- TestOldCompletionCallback callback1;
+ TestCompletionCallback callback1;
ProxyInfo results1;
- rv = resolver.GetProxyForURL(
- GURL("http://request1"), &results1, &callback1, NULL, BoundNetLog());
+ rv = resolver.GetProxyForURL(GURL("http://request1"), &results1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyInfo results2;
- rv = resolver.GetProxyForURL(
- GURL("http://request2"), &results2, &callback2, NULL, BoundNetLog());
+ rv = resolver.GetProxyForURL(GURL("http://request2"), &results2,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- TestOldCompletionCallback callback3;
+ TestCompletionCallback callback3;
ProxyInfo results3;
- rv = resolver.GetProxyForURL(
- GURL("http://request3"), &results3, &callback3, NULL, BoundNetLog());
+ rv = resolver.GetProxyForURL(GURL("http://request3"), &results3,
+ callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Wait for the requests to finish (they must finish in the order they were
@@ -340,9 +340,9 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_Basic) {
// There is no way to get a callback directly when PurgeMemory() completes, so
// we queue up a dummy request after the PurgeMemory() call and wait until it
// finishes to ensure PurgeMemory() has had a chance to run.
- TestOldCompletionCallback dummy_callback;
+ TestCompletionCallback dummy_callback;
rv = resolver.SetPacScript(ProxyResolverScriptData::FromUTF8("dummy"),
- &dummy_callback);
+ dummy_callback.callback());
EXPECT_EQ(OK, dummy_callback.WaitForResult());
EXPECT_EQ(1, mock->purge_count());
}
@@ -359,9 +359,9 @@ TEST(MultiThreadedProxyResolverTest,
int rv;
// Initialize the resolver.
- TestOldCompletionCallback init_callback;
+ TestCompletionCallback init_callback;
rv = resolver.SetPacScript(ProxyResolverScriptData::FromUTF8("foo"),
- &init_callback);
+ init_callback.callback());
EXPECT_EQ(OK, init_callback.WaitForResult());
// Block the proxy resolver, so no request can complete.
@@ -369,28 +369,28 @@ TEST(MultiThreadedProxyResolverTest,
// Start request 0.
ProxyResolver::RequestHandle request0;
- TestOldCompletionCallback callback0;
+ TestCompletionCallback callback0;
ProxyInfo results0;
CapturingBoundNetLog log0(CapturingNetLog::kUnbounded);
- rv = resolver.GetProxyForURL(
- GURL("http://request0"), &results0, &callback0, &request0, log0.bound());
+ rv = resolver.GetProxyForURL(GURL("http://request0"), &results0,
+ callback0.callback(), &request0, log0.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Start 2 more requests (request1 and request2).
- TestOldCompletionCallback callback1;
+ TestCompletionCallback callback1;
ProxyInfo results1;
CapturingBoundNetLog log1(CapturingNetLog::kUnbounded);
- rv = resolver.GetProxyForURL(
- GURL("http://request1"), &results1, &callback1, NULL, log1.bound());
+ rv = resolver.GetProxyForURL(GURL("http://request1"), &results1,
+ callback1.callback(), NULL, log1.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyResolver::RequestHandle request2;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyInfo results2;
CapturingBoundNetLog log2(CapturingNetLog::kUnbounded);
- rv = resolver.GetProxyForURL(
- GURL("http://request2"), &results2, &callback2, &request2, log2.bound());
+ rv = resolver.GetProxyForURL(GURL("http://request2"), &results2,
+ callback2.callback(), &request2, log2.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Unblock the worker thread so the requests can continue running.
@@ -453,9 +453,9 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_CancelRequest) {
int rv;
// Initialize the resolver.
- TestOldCompletionCallback init_callback;
+ TestCompletionCallback init_callback;
rv = resolver.SetPacScript(ProxyResolverScriptData::FromUTF8("foo"),
- &init_callback);
+ init_callback.callback());
EXPECT_EQ(OK, init_callback.WaitForResult());
// Block the proxy resolver, so no request can complete.
@@ -463,10 +463,10 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_CancelRequest) {
// Start request 0.
ProxyResolver::RequestHandle request0;
- TestOldCompletionCallback callback0;
+ TestCompletionCallback callback0;
ProxyInfo results0;
- rv = resolver.GetProxyForURL(
- GURL("http://request0"), &results0, &callback0, &request0, BoundNetLog());
+ rv = resolver.GetProxyForURL(GURL("http://request0"), &results0,
+ callback0.callback(), &request0, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Wait until requests 0 reaches the worker thread.
@@ -474,23 +474,23 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_CancelRequest) {
// Start 3 more requests (request1 : request3).
- TestOldCompletionCallback callback1;
+ TestCompletionCallback callback1;
ProxyInfo results1;
- rv = resolver.GetProxyForURL(
- GURL("http://request1"), &results1, &callback1, NULL, BoundNetLog());
+ rv = resolver.GetProxyForURL(GURL("http://request1"), &results1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyResolver::RequestHandle request2;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyInfo results2;
- rv = resolver.GetProxyForURL(
- GURL("http://request2"), &results2, &callback2, &request2, BoundNetLog());
+ rv = resolver.GetProxyForURL(GURL("http://request2"), &results2,
+ callback2.callback(), &request2, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- TestOldCompletionCallback callback3;
+ TestCompletionCallback callback3;
ProxyInfo results3;
- rv = resolver.GetProxyForURL(
- GURL("http://request3"), &results3, &callback3, NULL, BoundNetLog());
+ rv = resolver.GetProxyForURL(GURL("http://request3"), &results3,
+ callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Cancel request0 (inprogress) and request2 (pending).
@@ -530,9 +530,9 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_CancelRequestByDeleting) {
int rv;
// Initialize the resolver.
- TestOldCompletionCallback init_callback;
+ TestCompletionCallback init_callback;
rv = resolver->SetPacScript(ProxyResolverScriptData::FromUTF8("foo"),
- &init_callback);
+ init_callback.callback());
EXPECT_EQ(OK, init_callback.WaitForResult());
// Block the proxy resolver, so no request can complete.
@@ -540,22 +540,22 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_CancelRequestByDeleting) {
// Start 3 requests.
- TestOldCompletionCallback callback0;
+ TestCompletionCallback callback0;
ProxyInfo results0;
- rv = resolver->GetProxyForURL(
- GURL("http://request0"), &results0, &callback0, NULL, BoundNetLog());
+ rv = resolver->GetProxyForURL(GURL("http://request0"), &results0,
+ callback0.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- TestOldCompletionCallback callback1;
+ TestCompletionCallback callback1;
ProxyInfo results1;
- rv = resolver->GetProxyForURL(
- GURL("http://request1"), &results1, &callback1, NULL, BoundNetLog());
+ rv = resolver->GetProxyForURL(GURL("http://request1"), &results1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyInfo results2;
- rv = resolver->GetProxyForURL(
- GURL("http://request2"), &results2, &callback2, NULL, BoundNetLog());
+ rv = resolver->GetProxyForURL(GURL("http://request2"), &results2,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Wait until request 0 reaches the worker thread.
@@ -591,18 +591,18 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_CancelSetPacScript) {
int rv;
- TestOldCompletionCallback set_pac_script_callback;
+ TestCompletionCallback set_pac_script_callback;
rv = resolver.SetPacScript(ProxyResolverScriptData::FromUTF8("data"),
- &set_pac_script_callback);
+ set_pac_script_callback.callback());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Cancel the SetPacScriptByData request.
resolver.CancelSetPacScript();
// Start another SetPacScript request
- TestOldCompletionCallback set_pac_script_callback2;
+ TestCompletionCallback set_pac_script_callback2;
rv = resolver.SetPacScript(ProxyResolverScriptData::FromUTF8("data2"),
- &set_pac_script_callback2);
+ set_pac_script_callback2.callback());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Wait for the initialization to complete.
@@ -628,10 +628,10 @@ TEST(MultiThreadedProxyResolverTest, ThreeThreads_Basic) {
// Call SetPacScriptByData() -- verify that it reaches the synchronous
// resolver.
- TestOldCompletionCallback set_script_callback;
+ TestCompletionCallback set_script_callback;
rv = resolver.SetPacScript(
ProxyResolverScriptData::FromUTF8("pac script bytes"),
- &set_script_callback);
+ set_script_callback.callback());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, set_script_callback.WaitForResult());
// One thread has been provisioned (i.e. one ProxyResolver was created).
@@ -640,14 +640,14 @@ TEST(MultiThreadedProxyResolverTest, ThreeThreads_Basic) {
factory->resolvers()[0]->last_script_data()->utf16());
const int kNumRequests = 9;
- TestOldCompletionCallback callback[kNumRequests];
+ TestCompletionCallback callback[kNumRequests];
ProxyInfo results[kNumRequests];
ProxyResolver::RequestHandle request[kNumRequests];
// Start request 0 -- this should run on thread 0 as there is nothing else
// going on right now.
rv = resolver.GetProxyForURL(
- GURL("http://request0"), &results[0], &callback[0], &request[0],
+ GURL("http://request0"), &results[0], callback[0].callback(), &request[0],
BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -667,7 +667,7 @@ TEST(MultiThreadedProxyResolverTest, ThreeThreads_Basic) {
for (int i = 1; i < kNumRequests; ++i) {
rv = resolver.GetProxyForURL(
GURL(base::StringPrintf("http://request%d", i)), &results[i],
- &callback[i], &request[i], BoundNetLog());
+ callback[i].callback(), &request[i], BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
}
@@ -697,9 +697,9 @@ TEST(MultiThreadedProxyResolverTest, ThreeThreads_Basic) {
// We call SetPacScript again, solely to stop the current worker threads.
// (That way we can test to see the values observed by the synchronous
// resolvers in a non-racy manner).
- TestOldCompletionCallback set_script_callback2;
+ TestCompletionCallback set_script_callback2;
rv = resolver.SetPacScript(ProxyResolverScriptData::FromUTF8("xyz"),
- &set_script_callback2);
+ set_script_callback2.callback());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, set_script_callback2.WaitForResult());
ASSERT_EQ(4u, factory->resolvers().size());
@@ -740,10 +740,10 @@ TEST(MultiThreadedProxyResolverTest, OneThreadBlocked) {
EXPECT_TRUE(resolver.expects_pac_bytes());
// Initialize the resolver.
- TestOldCompletionCallback set_script_callback;
+ TestCompletionCallback set_script_callback;
rv = resolver.SetPacScript(
ProxyResolverScriptData::FromUTF8("pac script bytes"),
- &set_script_callback);
+ set_script_callback.callback());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, set_script_callback.WaitForResult());
// One thread has been provisioned (i.e. one ProxyResolver was created).
@@ -752,7 +752,7 @@ TEST(MultiThreadedProxyResolverTest, OneThreadBlocked) {
factory->resolvers()[0]->last_script_data()->utf16());
const int kNumRequests = 4;
- TestOldCompletionCallback callback[kNumRequests];
+ TestCompletionCallback callback[kNumRequests];
ProxyInfo results[kNumRequests];
ProxyResolver::RequestHandle request[kNumRequests];
@@ -761,7 +761,7 @@ TEST(MultiThreadedProxyResolverTest, OneThreadBlocked) {
factory->resolvers()[0]->Block();
rv = resolver.GetProxyForURL(
- GURL("http://request0"), &results[0], &callback[0], &request[0],
+ GURL("http://request0"), &results[0], callback[0].callback(), &request[0],
BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -773,7 +773,7 @@ TEST(MultiThreadedProxyResolverTest, OneThreadBlocked) {
for (int i = 1; i < kNumRequests; ++i) {
rv = resolver.GetProxyForURL(
GURL(base::StringPrintf("http://request%d", i)),
- &results[i], &callback[i], &request[i], BoundNetLog());
+ &results[i], callback[i].callback(), &request[i], BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
}
diff --git a/net/proxy/network_delegate_error_observer.cc b/net/proxy/network_delegate_error_observer.cc
index d4f6cfb..e2412b4 100644
--- a/net/proxy/network_delegate_error_observer.cc
+++ b/net/proxy/network_delegate_error_observer.cc
@@ -4,6 +4,7 @@
#include "net/proxy/network_delegate_error_observer.h"
+#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop_proxy.h"
#include "net/base/net_errors.h"
@@ -49,8 +50,7 @@ void NetworkDelegateErrorObserver::Core::NotifyPACScriptError(
if (!origin_loop_->BelongsToCurrentThread()) {
origin_loop_->PostTask(
FROM_HERE,
- NewRunnableMethod(this, &Core::NotifyPACScriptError,
- line_number, error));
+ base::Bind(&Core::NotifyPACScriptError, this, line_number, error));
return;
}
if (network_delegate_)
diff --git a/net/proxy/network_delegate_error_observer_unittest.cc b/net/proxy/network_delegate_error_observer_unittest.cc
index d41dbc0..9eb9204 100644
--- a/net/proxy/network_delegate_error_observer_unittest.cc
+++ b/net/proxy/network_delegate_error_observer_unittest.cc
@@ -4,14 +4,14 @@
#include "net/proxy/network_delegate_error_observer.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/message_loop_proxy.h"
#include "base/threading/thread.h"
#include "net/base/net_errors.h"
#include "net/base/network_delegate.h"
#include "testing/gtest/include/gtest/gtest.h"
-DISABLE_RUNNABLE_METHOD_REFCOUNT(net::NetworkDelegateErrorObserver);
-
namespace net {
namespace {
@@ -80,9 +80,8 @@ TEST(NetworkDelegateErrorObserverTest, CallOnThread) {
base::MessageLoopProxy::current());
thread.message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(&observer,
- &NetworkDelegateErrorObserver::OnPACScriptError,
- 42, string16()));
+ base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
+ base::Unretained(&observer), 42, string16()));
thread.Stop();
MessageLoop::current()->RunAllPending();
ASSERT_TRUE(network_delegate.got_pac_error());
@@ -96,9 +95,8 @@ TEST(NetworkDelegateErrorObserverTest, NoDelegate) {
observer(NULL, base::MessageLoopProxy::current());
thread.message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(&observer,
- &NetworkDelegateErrorObserver::OnPACScriptError,
- 42, string16()));
+ base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError,
+ base::Unretained(&observer), 42, string16()));
thread.Stop();
MessageLoop::current()->RunAllPending();
// Shouldn't have crashed until here...
diff --git a/net/proxy/polling_proxy_config_service.cc b/net/proxy/polling_proxy_config_service.cc
index e1b921a..97fcda9 100644
--- a/net/proxy/polling_proxy_config_service.cc
+++ b/net/proxy/polling_proxy_config_service.cc
@@ -4,6 +4,7 @@
#include "net/proxy/polling_proxy_config_service.h"
+#include "base/bind.h"
#include "base/location.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop_proxy.h"
@@ -91,7 +92,7 @@ class PollingProxyConfigService::Core
poll_task_queued_ = false;
base::WorkerPool::PostTask(
FROM_HERE,
- NewRunnableMethod(this, &Core::PollOnWorkerThread, get_config_func_),
+ base::Bind(&Core::PollOnWorkerThread, this, get_config_func_),
true);
}
@@ -104,7 +105,7 @@ class PollingProxyConfigService::Core
if (origin_loop_proxy_) {
origin_loop_proxy_->PostTask(
FROM_HERE,
- NewRunnableMethod(this, &Core::GetConfigCompleted, config));
+ base::Bind(&Core::GetConfigCompleted, this, config));
}
}
diff --git a/net/proxy/proxy_config_service_mac.cc b/net/proxy/proxy_config_service_mac.cc
index 12db347..a1055ff 100644
--- a/net/proxy/proxy_config_service_mac.cc
+++ b/net/proxy/proxy_config_service_mac.cc
@@ -7,6 +7,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include <SystemConfiguration/SystemConfiguration.h>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
@@ -248,8 +249,7 @@ void ProxyConfigServiceMac::OnNetworkConfigChange(CFArrayRef changed_keys) {
// Call OnProxyConfigChanged() on the IO thread to notify our observers.
io_loop_->PostTask(
FROM_HERE,
- NewRunnableMethod(
- helper_.get(), &Helper::OnProxyConfigChanged, new_config));
+ base::Bind(&Helper::OnProxyConfigChanged, helper_.get(), new_config));
}
void ProxyConfigServiceMac::OnProxyConfigChanged(
diff --git a/net/proxy/proxy_resolver.h b/net/proxy/proxy_resolver.h
index 3bdfd28..1774558 100644
--- a/net/proxy/proxy_resolver.h
+++ b/net/proxy/proxy_resolver.h
@@ -43,7 +43,7 @@ class NET_EXPORT_PRIVATE ProxyResolver {
// |*request| is written to, and can be passed to CancelRequest().
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const net::CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) = 0;
@@ -74,7 +74,7 @@ class NET_EXPORT_PRIVATE ProxyResolver {
// the result through |callback|.
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& pac_script,
- OldCompletionCallback* callback) = 0;
+ const net::CompletionCallback& callback) = 0;
// Optional shutdown code to be run before destruction. This is only used
// by the multithreaded runner to signal cleanup from origin thread
diff --git a/net/proxy/proxy_resolver_mac.cc b/net/proxy/proxy_resolver_mac.cc
index 3f28876..b3e2f7e 100644
--- a/net/proxy/proxy_resolver_mac.cc
+++ b/net/proxy/proxy_resolver_mac.cc
@@ -69,7 +69,7 @@ ProxyResolverMac::~ProxyResolverMac() {}
// inspired by http://developer.apple.com/samplecode/CFProxySupportTool/
int ProxyResolverMac::GetProxyForURL(const GURL& query_url,
ProxyInfo* results,
- OldCompletionCallback* /*callback*/,
+ const CompletionCallback& /*callback*/,
RequestHandle* /*request*/,
const BoundNetLog& net_log) {
base::mac::ScopedCFTypeRef<CFStringRef> query_ref(
@@ -202,7 +202,7 @@ void ProxyResolverMac::CancelSetPacScript() {
int ProxyResolverMac::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* /*callback*/) {
+ const CompletionCallback& /*callback*/) {
script_data_ = script_data;
return OK;
}
diff --git a/net/proxy/proxy_resolver_mac.h b/net/proxy/proxy_resolver_mac.h
index 0df4e38..c62ad33 100644
--- a/net/proxy/proxy_resolver_mac.h
+++ b/net/proxy/proxy_resolver_mac.h
@@ -24,7 +24,7 @@ class NET_EXPORT ProxyResolverMac : public ProxyResolver {
// ProxyResolver methods:
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const net::CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE;
@@ -39,7 +39,7 @@ class NET_EXPORT ProxyResolverMac : public ProxyResolver {
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* /*callback*/) OVERRIDE;
+ const net::CompletionCallback& /*callback*/) OVERRIDE;
private:
scoped_refptr<ProxyResolverScriptData> script_data_;
diff --git a/net/proxy/proxy_resolver_perftest.cc b/net/proxy/proxy_resolver_perftest.cc
index 97dfe5c..6a88500 100644
--- a/net/proxy/proxy_resolver_perftest.cc
+++ b/net/proxy/proxy_resolver_perftest.cc
@@ -119,7 +119,8 @@ class PacPerfSuiteRunner {
GURL pac_url =
test_server_.GetURL(std::string("files/") + script_name);
int rv = resolver_->SetPacScript(
- net::ProxyResolverScriptData::FromURL(pac_url), NULL);
+ net::ProxyResolverScriptData::FromURL(pac_url),
+ net::CompletionCallback());
EXPECT_EQ(net::OK, rv);
} else {
LoadPacScriptIntoResolver(script_name);
@@ -131,8 +132,8 @@ class PacPerfSuiteRunner {
{
net::ProxyInfo proxy_info;
int result = resolver_->GetProxyForURL(
- GURL("http://www.warmup.com"), &proxy_info, NULL, NULL,
- net::BoundNetLog());
+ GURL("http://www.warmup.com"), &proxy_info, net::CompletionCallback(),
+ NULL, net::BoundNetLog());
ASSERT_EQ(net::OK, result);
}
@@ -146,9 +147,9 @@ class PacPerfSuiteRunner {
// Resolve.
net::ProxyInfo proxy_info;
- int result = resolver_->GetProxyForURL(GURL(query.query_url),
- &proxy_info, NULL, NULL,
- net::BoundNetLog());
+ int result = resolver_->GetProxyForURL(
+ GURL(query.query_url), &proxy_info, net::CompletionCallback(), NULL,
+ net::BoundNetLog());
// Check that the result was correct. Note that ToPacString() and
// ASSERT_EQ() are fast, so they won't skew the results.
@@ -179,7 +180,8 @@ class PacPerfSuiteRunner {
// Load the PAC script into the ProxyResolver.
int rv = resolver_->SetPacScript(
- net::ProxyResolverScriptData::FromUTF8(file_contents), NULL);
+ net::ProxyResolverScriptData::FromUTF8(file_contents),
+ net::CompletionCallback());
EXPECT_EQ(net::OK, rv);
}
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc
index 9df6e59..92beb80 100644
--- a/net/proxy/proxy_resolver_v8.cc
+++ b/net/proxy/proxy_resolver_v8.cc
@@ -728,11 +728,11 @@ ProxyResolverV8::ProxyResolverV8(
ProxyResolverV8::~ProxyResolverV8() {}
-int ProxyResolverV8::GetProxyForURL(const GURL& query_url,
- ProxyInfo* results,
- OldCompletionCallback* /*callback*/,
- RequestHandle* /*request*/,
- const BoundNetLog& net_log) {
+int ProxyResolverV8::GetProxyForURL(
+ const GURL& query_url, ProxyInfo* results,
+ const CompletionCallback& /*callback*/,
+ RequestHandle* /*request*/,
+ const BoundNetLog& net_log) {
// If the V8 instance has not been initialized (either because
// SetPacScript() wasn't called yet, or because it failed.
if (!context_.get())
@@ -789,7 +789,7 @@ void ProxyResolverV8::Shutdown() {
int ProxyResolverV8::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* /*callback*/) {
+ const CompletionCallback& /*callback*/) {
DCHECK(script_data.get());
context_.reset();
if (script_data->utf16().empty())
diff --git a/net/proxy/proxy_resolver_v8.h b/net/proxy/proxy_resolver_v8.h
index 4d7df97..ecd8d13 100644
--- a/net/proxy/proxy_resolver_v8.h
+++ b/net/proxy/proxy_resolver_v8.h
@@ -47,7 +47,7 @@ class NET_EXPORT_PRIVATE ProxyResolverV8 : public ProxyResolver {
// ProxyResolver implementation:
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* /*callback*/,
+ const net::CompletionCallback& /*callback*/,
RequestHandle* /*request*/,
const BoundNetLog& net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle request) OVERRIDE;
@@ -59,7 +59,7 @@ class NET_EXPORT_PRIVATE ProxyResolverV8 : public ProxyResolver {
virtual void Shutdown() OVERRIDE;
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* /*callback*/) OVERRIDE;
+ const net::CompletionCallback& /*callback*/) OVERRIDE;
private:
// Context holds the Javascript state for the most recently loaded PAC
diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc
index aa97004..9782bb1 100644
--- a/net/proxy/proxy_resolver_v8_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_unittest.cc
@@ -115,7 +115,7 @@ class ProxyResolverV8WithMockBindings : public ProxyResolverV8 {
// Load the PAC script into the ProxyResolver.
return SetPacScript(ProxyResolverScriptData::FromUTF8(file_contents),
- NULL);
+ CompletionCallback());
}
};
@@ -131,8 +131,8 @@ TEST(ProxyResolverV8Test, Direct) {
ProxyInfo proxy_info;
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- log.bound());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, log.bound());
EXPECT_EQ(OK, result);
EXPECT_TRUE(proxy_info.is_direct());
@@ -152,8 +152,8 @@ TEST(ProxyResolverV8Test, ReturnEmptyString) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_TRUE(proxy_info.is_direct());
@@ -172,17 +172,17 @@ TEST(ProxyResolverV8Test, Basic) {
// the correct arguments are being passed to FindProxyForURL().
{
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(GURL("http://query.com/path"),
- &proxy_info, NULL, NULL, BoundNetLog());
+ result = resolver.GetProxyForURL(GURL("http://query.com/path"), &proxy_info,
+ CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_EQ("http.query.com.path.query.com:80",
proxy_info.proxy_server().ToURI());
}
{
ProxyInfo proxy_info;
- int result = resolver.GetProxyForURL(GURL("ftp://query.com:90/path"),
- &proxy_info, NULL, NULL,
- BoundNetLog());
+ int result = resolver.GetProxyForURL(
+ GURL("ftp://query.com:90/path"), &proxy_info, CompletionCallback(),
+ NULL, BoundNetLog());
EXPECT_EQ(OK, result);
// Note that FindProxyForURL(url, host) does not expect |host| to contain
// the port number.
@@ -220,8 +220,8 @@ TEST(ProxyResolverV8Test, BadReturnType) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
@@ -241,8 +241,8 @@ TEST(ProxyResolverV8Test, NoEntryPoint) {
EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_FAILED, result);
}
@@ -254,8 +254,8 @@ TEST(ProxyResolverV8Test, ParseError) {
EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_FAILED, result);
@@ -278,8 +278,8 @@ TEST(ProxyResolverV8Test, SideEffects) {
// The PAC script increments a counter each time we invoke it.
for (int i = 0; i < 3; ++i) {
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_EQ(base::StringPrintf("sideffect_%d:80", i),
proxy_info.proxy_server().ToURI());
@@ -292,8 +292,8 @@ TEST(ProxyResolverV8Test, SideEffects) {
for (int i = 0; i < 3; ++i) {
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_EQ(base::StringPrintf("sideffect_%d:80", i),
proxy_info.proxy_server().ToURI());
@@ -307,8 +307,8 @@ TEST(ProxyResolverV8Test, UnhandledException) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
@@ -326,23 +326,23 @@ TEST(ProxyResolverV8Test, ReturnUnicode) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
// The result from this resolve was unparseable, because it
// wasn't ASCII.
EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
}
-// Test the PAC library functions that we expose in the JS environmnet.
+// Test the PAC library functions that we expose in the JS environment.
TEST(ProxyResolverV8Test, JavascriptLibrary) {
ProxyResolverV8WithMockBindings resolver;
int result = resolver.SetPacScriptFromDisk("pac_library_unittest.js");
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
// If the javascript side of this unit-test fails, it will throw a javascript
// exception. Otherwise it will return "PROXY success:80".
@@ -360,8 +360,8 @@ TEST(ProxyResolverV8Test, NoSetPacScript) {
ProxyInfo proxy_info;
// Resolve should fail, as we are not yet initialized with a script.
- int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ int result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_FAILED, result);
// Initialize it.
@@ -369,24 +369,24 @@ TEST(ProxyResolverV8Test, NoSetPacScript) {
EXPECT_EQ(OK, result);
// Resolve should now succeed.
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
// Clear it, by initializing with an empty string.
resolver.SetPacScript(
- ProxyResolverScriptData::FromUTF16(string16()), NULL);
+ ProxyResolverScriptData::FromUTF16(string16()), CompletionCallback());
// Resolve should fail again now.
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_FAILED, result);
// Load a good script once more.
result = resolver.SetPacScriptFromDisk("direct.js");
EXPECT_EQ(OK, result);
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
@@ -402,8 +402,8 @@ TEST(ProxyResolverV8Test, V8Bindings) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_TRUE(proxy_info.is_direct());
@@ -450,8 +450,8 @@ TEST(ProxyResolverV8Test, BindingCalledDuringInitialization) {
EXPECT_EQ(1, bindings->my_ip_address_count);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_FALSE(proxy_info.is_direct());
@@ -476,8 +476,8 @@ TEST(ProxyResolverV8Test, EndsWithCommentNoNewline) {
ProxyInfo proxy_info;
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- log.bound());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, log.bound());
EXPECT_EQ(OK, result);
EXPECT_FALSE(proxy_info.is_direct());
@@ -496,8 +496,8 @@ TEST(ProxyResolverV8Test, EndsWithStatementNoNewline) {
ProxyInfo proxy_info;
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- log.bound());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, log.bound());
EXPECT_EQ(OK, result);
EXPECT_FALSE(proxy_info.is_direct());
@@ -514,8 +514,8 @@ TEST(ProxyResolverV8Test, DNSResolutionFailure) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_FALSE(proxy_info.is_direct());
@@ -529,8 +529,8 @@ TEST(ProxyResolverV8Test, DNSResolutionOfInternationDomainName) {
// Execute FindProxyForURL().
ProxyInfo proxy_info;
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
- BoundNetLog());
+ result = resolver.GetProxyForURL(
+ kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(OK, result);
EXPECT_TRUE(proxy_info.is_direct());
diff --git a/net/proxy/proxy_resolver_winhttp.cc b/net/proxy/proxy_resolver_winhttp.cc
index 2f24ea9..46665fc 100644
--- a/net/proxy/proxy_resolver_winhttp.cc
+++ b/net/proxy/proxy_resolver_winhttp.cc
@@ -38,7 +38,7 @@ ProxyResolverWinHttp::~ProxyResolverWinHttp() {
int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url,
ProxyInfo* results,
- OldCompletionCallback* /*callback*/,
+ const CompletionCallback& /*callback*/,
RequestHandle* /*request*/,
const BoundNetLog& /*net_log*/) {
// If we don't have a WinHTTP session, then create a new one.
@@ -140,7 +140,7 @@ void ProxyResolverWinHttp::CancelSetPacScript() {
int ProxyResolverWinHttp::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* /*callback*/) {
+ const CompletionCallback& /*callback*/) {
if (script_data->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT) {
pac_url_ = GURL("http://wpad/wpad.dat");
} else {
diff --git a/net/proxy/proxy_resolver_winhttp.h b/net/proxy/proxy_resolver_winhttp.h
index c565808..f99ce02 100644
--- a/net/proxy/proxy_resolver_winhttp.h
+++ b/net/proxy/proxy_resolver_winhttp.h
@@ -24,7 +24,7 @@ class NET_EXPORT_PRIVATE ProxyResolverWinHttp : public ProxyResolver {
// ProxyResolver implementation:
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* /*callback*/,
+ const net::CompletionCallback& /*callback*/,
RequestHandle* /*request*/,
const BoundNetLog& /*net_log*/) OVERRIDE;
virtual void CancelRequest(RequestHandle request) OVERRIDE;
@@ -38,7 +38,7 @@ class NET_EXPORT_PRIVATE ProxyResolverWinHttp : public ProxyResolver {
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* /*callback*/) OVERRIDE;
+ const net::CompletionCallback& /*callback*/) OVERRIDE;
private:
bool OpenWinHttpSession();
diff --git a/net/proxy/proxy_script_decider.cc b/net/proxy/proxy_script_decider.cc
index e3f4857..a247fbb 100644
--- a/net/proxy/proxy_script_decider.cc
+++ b/net/proxy/proxy_script_decider.cc
@@ -4,6 +4,8 @@
#include "net/proxy/proxy_script_decider.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/format_macros.h"
#include "base/logging.h"
@@ -49,9 +51,6 @@ ProxyScriptDecider::ProxyScriptDecider(
NetLog* net_log)
: proxy_script_fetcher_(proxy_script_fetcher),
dhcp_proxy_script_fetcher_(dhcp_proxy_script_fetcher),
- ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(
- this, &ProxyScriptDecider::OnIOCompletion)),
- user_callback_(NULL),
current_pac_source_index_(0u),
pac_mandatory_(false),
next_state_(STATE_NONE),
@@ -65,12 +64,11 @@ ProxyScriptDecider::~ProxyScriptDecider() {
Cancel();
}
-int ProxyScriptDecider::Start(const ProxyConfig& config,
- const base::TimeDelta wait_delay,
- bool fetch_pac_bytes,
- OldCompletionCallback* callback) {
+int ProxyScriptDecider::Start(
+ const ProxyConfig& config, const base::TimeDelta wait_delay,
+ bool fetch_pac_bytes, const CompletionCallback& callback) {
DCHECK_EQ(STATE_NONE, next_state_);
- DCHECK(callback);
+ DCHECK(!callback.is_null());
DCHECK(config.HasAutomaticSettings());
net_log_.BeginEvent(NetLog::TYPE_PROXY_SCRIPT_DECIDER, NULL);
@@ -91,7 +89,7 @@ int ProxyScriptDecider::Start(const ProxyConfig& config,
int rv = DoLoop(OK);
if (rv == ERR_IO_PENDING)
- user_callback_ = callback;
+ callback_ = callback;
else
DidComplete();
@@ -174,8 +172,8 @@ int ProxyScriptDecider::DoLoop(int result) {
void ProxyScriptDecider::DoCallback(int result) {
DCHECK_NE(ERR_IO_PENDING, result);
- DCHECK(user_callback_);
- user_callback_->Run(result);
+ DCHECK(!callback_.is_null());
+ callback_.Run(result);
}
int ProxyScriptDecider::DoWait() {
@@ -223,7 +221,9 @@ int ProxyScriptDecider::DoFetchPacScript() {
return ERR_UNEXPECTED;
}
- return dhcp_proxy_script_fetcher_->Fetch(&pac_script_, &io_callback_);
+ return dhcp_proxy_script_fetcher_->Fetch(
+ &pac_script_, base::Bind(&ProxyScriptDecider::OnIOCompletion,
+ base::Unretained(this)));
}
if (!proxy_script_fetcher_) {
@@ -232,7 +232,8 @@ int ProxyScriptDecider::DoFetchPacScript() {
}
return proxy_script_fetcher_->Fetch(
- effective_pac_url, &pac_script_, &io_callback_);
+ effective_pac_url, &pac_script_,
+ base::Bind(&ProxyScriptDecider::OnIOCompletion, base::Unretained(this)));
}
int ProxyScriptDecider::DoFetchPacScriptComplete(int result) {
diff --git a/net/proxy/proxy_script_decider.h b/net/proxy/proxy_script_decider.h
index 81dff94..14aeb2e 100644
--- a/net/proxy/proxy_script_decider.h
+++ b/net/proxy/proxy_script_decider.h
@@ -69,7 +69,7 @@ class NET_EXPORT_PRIVATE ProxyScriptDecider {
int Start(const ProxyConfig& config,
const base::TimeDelta wait_delay,
bool fetch_pac_bytes,
- OldCompletionCallback* callback);
+ const net::CompletionCallback& callback);
const ProxyConfig& effective_config() const;
@@ -145,8 +145,7 @@ class NET_EXPORT_PRIVATE ProxyScriptDecider {
ProxyScriptFetcher* proxy_script_fetcher_;
DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher_;
- OldCompletionCallbackImpl<ProxyScriptDecider> io_callback_;
- OldCompletionCallback* user_callback_;
+ net::CompletionCallback callback_;
size_t current_pac_source_index_;
diff --git a/net/proxy/proxy_script_decider_unittest.cc b/net/proxy/proxy_script_decider_unittest.cc
index f2d6c82..23fee76 100644
--- a/net/proxy/proxy_script_decider_unittest.cc
+++ b/net/proxy/proxy_script_decider_unittest.cc
@@ -4,6 +4,7 @@
#include <vector>
+#include "base/bind.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/time.h"
@@ -96,7 +97,7 @@ class RuleBasedProxyScriptFetcher : public ProxyScriptFetcher {
// ProxyScriptFetcher implementation.
virtual int Fetch(const GURL& url,
string16* text,
- OldCompletionCallback* callback) {
+ const CompletionCallback& callback) {
const Rules::Rule& rule = rules_->GetRuleByUrl(url);
int rv = rule.fetch_error;
EXPECT_NE(ERR_UNEXPECTED, rv);
@@ -124,11 +125,11 @@ TEST(ProxyScriptDeciderTest, CustomPacSucceeds) {
Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
CapturingNetLog log(CapturingNetLog::kUnbounded);
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
EXPECT_EQ(OK, decider.Start(
- config, base::TimeDelta(), true, &callback));
+ config, base::TimeDelta(), true, callback.callback()));
EXPECT_EQ(rule.text(), decider.script_data()->utf16());
// Check the NetLog was filled correctly.
@@ -160,11 +161,12 @@ TEST(ProxyScriptDeciderTest, CustomPacFails1) {
rules.AddFailDownloadRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
CapturingNetLog log(CapturingNetLog::kUnbounded);
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
EXPECT_EQ(kFailedDownloading,
- decider.Start(config, base::TimeDelta(), true, &callback));
+ decider.Start(config, base::TimeDelta(), true,
+ callback.callback()));
EXPECT_EQ(NULL, decider.script_data());
// Check the NetLog was filled correctly.
@@ -195,10 +197,11 @@ TEST(ProxyScriptDeciderTest, CustomPacFails2) {
rules.AddFailParsingRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
EXPECT_EQ(kFailedParsing,
- decider.Start(config, base::TimeDelta(), true, &callback));
+ decider.Start(config, base::TimeDelta(), true,
+ callback.callback()));
EXPECT_EQ(NULL, decider.script_data());
}
@@ -210,10 +213,11 @@ TEST(ProxyScriptDeciderTest, HasNullProxyScriptFetcher) {
ProxyConfig config;
config.set_pac_url(GURL("http://custom/proxy.pac"));
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(NULL, &dhcp_fetcher, NULL);
EXPECT_EQ(ERR_UNEXPECTED,
- decider.Start(config, base::TimeDelta(), true, &callback));
+ decider.Start(config, base::TimeDelta(), true,
+ callback.callback()));
EXPECT_EQ(NULL, decider.script_data());
}
@@ -228,10 +232,10 @@ TEST(ProxyScriptDeciderTest, AutodetectSuccess) {
Rules::Rule rule = rules.AddSuccessRule("http://wpad/wpad.dat");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
EXPECT_EQ(OK, decider.Start(
- config, base::TimeDelta(), true, &callback));
+ config, base::TimeDelta(), true, callback.callback()));
EXPECT_EQ(rule.text(), decider.script_data()->utf16());
EXPECT_TRUE(decider.effective_config().has_pac_url());
@@ -251,10 +255,10 @@ TEST(ProxyScriptDeciderTest, AutodetectFailCustomSuccess1) {
rules.AddFailDownloadRule("http://wpad/wpad.dat");
Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
EXPECT_EQ(OK, decider.Start(
- config, base::TimeDelta(), true, &callback));
+ config, base::TimeDelta(), true, callback.callback()));
EXPECT_EQ(rule.text(), decider.script_data()->utf16());
EXPECT_TRUE(decider.effective_config().has_pac_url());
@@ -276,12 +280,12 @@ TEST(ProxyScriptDeciderTest, AutodetectFailCustomSuccess2) {
rules.AddFailParsingRule("http://wpad/wpad.dat");
Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
CapturingNetLog log(CapturingNetLog::kUnbounded);
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
EXPECT_EQ(OK, decider.Start(config, base::TimeDelta(),
- true, &callback));
+ true, callback.callback()));
EXPECT_EQ(rule.text(), decider.script_data()->utf16());
// Verify that the effective configuration no longer contains auto detect or
@@ -339,10 +343,11 @@ TEST(ProxyScriptDeciderTest, AutodetectFailCustomFails1) {
rules.AddFailDownloadRule("http://wpad/wpad.dat");
rules.AddFailDownloadRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
EXPECT_EQ(kFailedDownloading,
- decider.Start(config, base::TimeDelta(), true, &callback));
+ decider.Start(config, base::TimeDelta(), true,
+ callback.callback()));
EXPECT_EQ(NULL, decider.script_data());
}
@@ -359,10 +364,11 @@ TEST(ProxyScriptDeciderTest, AutodetectFailCustomFails2) {
rules.AddFailDownloadRule("http://wpad/wpad.dat");
rules.AddFailParsingRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
EXPECT_EQ(kFailedParsing,
- decider.Start(config, base::TimeDelta(), true, &callback));
+ decider.Start(config, base::TimeDelta(), true,
+ callback.callback()));
EXPECT_EQ(NULL, decider.script_data());
}
@@ -379,12 +385,12 @@ TEST(ProxyScriptDeciderTest, CustomPacFails1_WithPositiveDelay) {
rules.AddFailDownloadRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
CapturingNetLog log(CapturingNetLog::kUnbounded);
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
EXPECT_EQ(ERR_IO_PENDING,
decider.Start(config, base::TimeDelta::FromMilliseconds(1),
- true, &callback));
+ true, callback.callback()));
EXPECT_EQ(kFailedDownloading, callback.WaitForResult());
EXPECT_EQ(NULL, decider.script_data());
@@ -421,12 +427,12 @@ TEST(ProxyScriptDeciderTest, CustomPacFails1_WithNegativeDelay) {
rules.AddFailDownloadRule("http://custom/proxy.pac");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
CapturingNetLog log(CapturingNetLog::kUnbounded);
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, &log);
EXPECT_EQ(kFailedDownloading,
decider.Start(config, base::TimeDelta::FromSeconds(-5),
- true, &callback));
+ true, callback.callback()));
EXPECT_EQ(NULL, decider.script_data());
// Check the NetLog was filled correctly.
@@ -450,7 +456,7 @@ class SynchronousSuccessDhcpFetcher : public DhcpProxyScriptFetcher {
: gurl_("http://dhcppac/"), expected_text_(expected_text) {
}
- int Fetch(string16* utf16_text, OldCompletionCallback* callback) OVERRIDE {
+ int Fetch(string16* utf16_text, const CompletionCallback& callback) OVERRIDE {
*utf16_text = expected_text_;
return OK;
}
@@ -490,10 +496,10 @@ TEST(ProxyScriptDeciderTest, AutodetectDhcpSuccess) {
rules.AddSuccessRule("http://bingo/");
rules.AddFailDownloadRule("http://wpad/wpad.dat");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
EXPECT_EQ(OK, decider.Start(
- config, base::TimeDelta(), true, &callback));
+ config, base::TimeDelta(), true, callback.callback()));
EXPECT_EQ(dhcp_fetcher.expected_text(),
decider.script_data()->utf16());
@@ -513,12 +519,12 @@ TEST(ProxyScriptDeciderTest, AutodetectDhcpFailParse) {
rules.AddFailParsingRule("http://bingo/");
rules.AddFailDownloadRule("http://wpad/wpad.dat");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
// Since there is fallback to DNS-based WPAD, the final error will be that
// it failed downloading, not that it failed parsing.
EXPECT_EQ(kFailedDownloading,
- decider.Start(config, base::TimeDelta(), true, &callback));
+ decider.Start(config, base::TimeDelta(), true, callback.callback()));
EXPECT_EQ(NULL, decider.script_data());
EXPECT_FALSE(decider.effective_config().has_pac_url());
@@ -528,19 +534,18 @@ class AsyncFailDhcpFetcher
: public DhcpProxyScriptFetcher,
public base::RefCountedThreadSafe<AsyncFailDhcpFetcher> {
public:
- AsyncFailDhcpFetcher() : callback_(NULL) {
- }
+ AsyncFailDhcpFetcher() {}
- int Fetch(string16* utf16_text, OldCompletionCallback* callback) OVERRIDE {
+ int Fetch(string16* utf16_text, const CompletionCallback& callback) OVERRIDE {
callback_ = callback;
MessageLoop::current()->PostTask(
FROM_HERE,
- NewRunnableMethod(this, &AsyncFailDhcpFetcher::CallbackWithFailure));
+ base::Bind(&AsyncFailDhcpFetcher::CallbackWithFailure, this));
return ERR_IO_PENDING;
}
void Cancel() OVERRIDE {
- callback_ = NULL;
+ callback_.Reset();
}
const GURL& GetPacURL() const OVERRIDE {
@@ -548,13 +553,13 @@ class AsyncFailDhcpFetcher
}
void CallbackWithFailure() {
- if (callback_)
- callback_->Run(ERR_PAC_NOT_IN_DHCP);
+ if (!callback_.is_null())
+ callback_.Run(ERR_PAC_NOT_IN_DHCP);
}
private:
GURL dummy_gurl_;
- OldCompletionCallback* callback_;
+ CompletionCallback callback_;
};
TEST(ProxyScriptDeciderTest, DhcpCancelledByDestructor) {
@@ -571,12 +576,12 @@ TEST(ProxyScriptDeciderTest, DhcpCancelledByDestructor) {
config.set_auto_detect(true);
rules.AddFailDownloadRule("http://wpad/wpad.dat");
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
// Scope so ProxyScriptDecider gets destroyed early.
{
ProxyScriptDecider decider(&fetcher, dhcp_fetcher.get(), NULL);
- decider.Start(config, base::TimeDelta(), true, &callback);
+ decider.Start(config, base::TimeDelta(), true, callback.callback());
}
// Run the message loop to let the DHCP fetch complete and post the results
diff --git a/net/proxy/proxy_script_fetcher.h b/net/proxy/proxy_script_fetcher.h
index 7c7e4eb..efcd371 100644
--- a/net/proxy/proxy_script_fetcher.h
+++ b/net/proxy/proxy_script_fetcher.h
@@ -46,7 +46,7 @@ class NET_EXPORT_PRIVATE ProxyScriptFetcher {
//
// Only one fetch is allowed to be outstanding at a time.
virtual int Fetch(const GURL& url, string16* utf16_text,
- OldCompletionCallback* callback) = 0;
+ const net::CompletionCallback& callback) = 0;
// Aborts the in-progress fetch (if any).
virtual void Cancel() = 0;
diff --git a/net/proxy/proxy_script_fetcher_impl.cc b/net/proxy/proxy_script_fetcher_impl.cc
index 321f0f0..8bd8858 100644
--- a/net/proxy/proxy_script_fetcher_impl.cc
+++ b/net/proxy/proxy_script_fetcher_impl.cc
@@ -73,13 +73,12 @@ void ConvertResponseToUTF16(const std::string& charset,
ProxyScriptFetcherImpl::ProxyScriptFetcherImpl(
URLRequestContext* url_request_context)
- : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
url_request_context_(url_request_context),
buf_(new IOBuffer(kBufSize)),
next_id_(0),
cur_request_(NULL),
cur_request_id_(0),
- callback_(NULL),
result_code_(OK),
result_text_(NULL),
max_response_bytes_(kDefaultMaxResponseBytes),
@@ -116,13 +115,11 @@ void ProxyScriptFetcherImpl::OnResponseCompleted(URLRequest* request) {
FetchCompleted();
}
-int ProxyScriptFetcherImpl::Fetch(const GURL& url,
- string16* text,
- OldCompletionCallback* callback) {
+int ProxyScriptFetcherImpl::Fetch(
+ const GURL& url, string16* text, const CompletionCallback& callback) {
// It is invalid to call Fetch() while a request is already in progress.
DCHECK(!cur_request_.get());
-
- DCHECK(callback);
+ DCHECK(!callback.is_null());
DCHECK(text);
// Handle base-64 encoded data-urls that contain custom PAC scripts.
@@ -161,9 +158,10 @@ int ProxyScriptFetcherImpl::Fetch(const GURL& url,
// Post a task to timeout this request if it takes too long.
cur_request_id_ = ++next_id_;
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- task_factory_.NewRunnableMethod(&ProxyScriptFetcherImpl::OnTimeout,
- cur_request_id_),
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ProxyScriptFetcherImpl::OnTimeout, weak_factory_.GetWeakPtr(),
+ cur_request_id_),
static_cast<int>(max_duration_.InMilliseconds()));
// Start the request.
@@ -295,20 +293,20 @@ void ProxyScriptFetcherImpl::FetchCompleted() {
}
int result_code = result_code_;
- OldCompletionCallback* callback = callback_;
+ CompletionCallback callback = callback_;
// Hold a reference to the URLRequestContext to prevent re-entrancy from
// ~URLRequestContext.
scoped_refptr<const URLRequestContext> context(cur_request_->context());
ResetCurRequestState();
- callback->Run(result_code);
+ callback.Run(result_code);
}
void ProxyScriptFetcherImpl::ResetCurRequestState() {
cur_request_.reset();
cur_request_id_ = 0;
- callback_ = NULL;
+ callback_.Reset();
result_code_ = OK;
result_text_ = NULL;
}
diff --git a/net/proxy/proxy_script_fetcher_impl.h b/net/proxy/proxy_script_fetcher_impl.h
index 964030a..927c2c5 100644
--- a/net/proxy/proxy_script_fetcher_impl.h
+++ b/net/proxy/proxy_script_fetcher_impl.h
@@ -12,6 +12,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "base/task.h"
#include "base/time.h"
@@ -47,7 +48,7 @@ class NET_EXPORT ProxyScriptFetcherImpl : public ProxyScriptFetcher,
// ProxyScriptFetcher methods:
virtual int Fetch(const GURL& url, string16* text,
- OldCompletionCallback* callback) OVERRIDE;
+ const net::CompletionCallback& callback) OVERRIDE;
virtual void Cancel() OVERRIDE;
virtual URLRequestContext* GetRequestContext() const OVERRIDE;
@@ -82,7 +83,7 @@ class NET_EXPORT ProxyScriptFetcherImpl : public ProxyScriptFetcher,
// Factory for creating the time-out task. This takes care of revoking
// outstanding tasks when |this| is deleted.
- ScopedRunnableMethodFactory<ProxyScriptFetcherImpl> task_factory_;
+ base::WeakPtrFactory<ProxyScriptFetcherImpl> weak_factory_;
// The context used for making network requests.
URLRequestContext* url_request_context_;
@@ -102,7 +103,7 @@ class NET_EXPORT ProxyScriptFetcherImpl : public ProxyScriptFetcher,
int cur_request_id_;
// Callback to invoke on completion of the fetch.
- OldCompletionCallback* callback_;
+ net::CompletionCallback callback_;
// Holds the error condition that was hit on the current request, or OK.
int result_code_;
diff --git a/net/proxy/proxy_script_fetcher_impl_unittest.cc b/net/proxy/proxy_script_fetcher_impl_unittest.cc
index 6250252..e3c0be9 100644
--- a/net/proxy/proxy_script_fetcher_impl_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_impl_unittest.cc
@@ -135,18 +135,18 @@ TEST_F(ProxyScriptFetcherImplTest, FileUrl) {
{ // Fetch a non-existent file.
string16 text;
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
int result = pac_fetcher.Fetch(GetTestFileUrl("does-not-exist"),
- &text, &callback);
+ &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(ERR_FILE_NOT_FOUND, callback.WaitForResult());
EXPECT_TRUE(text.empty());
}
{ // Fetch a file that exists.
string16 text;
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
int result = pac_fetcher.Fetch(GetTestFileUrl("pac.txt"),
- &text, &callback);
+ &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-pac.txt-\n"), text);
@@ -164,8 +164,8 @@ TEST_F(ProxyScriptFetcherImplTest, HttpMimeType) {
{ // Fetch a PAC with mime type "text/plain"
GURL url(test_server_.GetURL("files/pac.txt"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-pac.txt-\n"), text);
@@ -173,8 +173,8 @@ TEST_F(ProxyScriptFetcherImplTest, HttpMimeType) {
{ // Fetch a PAC with mime type "text/html"
GURL url(test_server_.GetURL("files/pac.html"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-pac.html-\n"), text);
@@ -182,8 +182,8 @@ TEST_F(ProxyScriptFetcherImplTest, HttpMimeType) {
{ // Fetch a PAC with mime type "application/x-ns-proxy-autoconfig"
GURL url(test_server_.GetURL("files/pac.nsproxy"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-pac.nsproxy-\n"), text);
@@ -199,8 +199,8 @@ TEST_F(ProxyScriptFetcherImplTest, HttpStatusCode) {
{ // Fetch a PAC which gives a 500 -- FAIL
GURL url(test_server_.GetURL("files/500.pac"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(ERR_PAC_STATUS_NOT_OK, callback.WaitForResult());
EXPECT_TRUE(text.empty());
@@ -208,8 +208,8 @@ TEST_F(ProxyScriptFetcherImplTest, HttpStatusCode) {
{ // Fetch a PAC which gives a 404 -- FAIL
GURL url(test_server_.GetURL("files/404.pac"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(ERR_PAC_STATUS_NOT_OK, callback.WaitForResult());
EXPECT_TRUE(text.empty());
@@ -226,8 +226,8 @@ TEST_F(ProxyScriptFetcherImplTest, ContentDisposition) {
// have no effect.
GURL url(test_server_.GetURL("files/downloadable.pac"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-downloadable.pac-\n"), text);
@@ -243,8 +243,8 @@ TEST_F(ProxyScriptFetcherImplTest, NoCache) {
GURL url(test_server_.GetURL("files/cacheable_1hr.pac"));
{
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-cacheable_1hr.pac-\n"), text);
@@ -258,8 +258,8 @@ TEST_F(ProxyScriptFetcherImplTest, NoCache) {
// get a success.
{
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult());
}
@@ -285,8 +285,8 @@ TEST_F(ProxyScriptFetcherImplTest, TooLarge) {
for (size_t i = 0; i < arraysize(urls); ++i) {
const GURL& url = urls[i];
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(ERR_FILE_TOO_BIG, callback.WaitForResult());
EXPECT_TRUE(text.empty());
@@ -298,8 +298,8 @@ TEST_F(ProxyScriptFetcherImplTest, TooLarge) {
{ // Make sure we can still fetch regular URLs.
GURL url(test_server_.GetURL("files/pac.nsproxy"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-pac.nsproxy-\n"), text);
@@ -320,8 +320,8 @@ TEST_F(ProxyScriptFetcherImplTest, Hang) {
// after 500 ms, and fail with a timeout error.
{ GURL url(test_server_.GetURL("slow/proxy.pac?1.2"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(ERR_TIMED_OUT, callback.WaitForResult());
EXPECT_TRUE(text.empty());
@@ -333,8 +333,8 @@ TEST_F(ProxyScriptFetcherImplTest, Hang) {
{ // Make sure we can still fetch regular URLs.
GURL url(test_server_.GetURL("files/pac.nsproxy"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("-pac.nsproxy-\n"), text);
@@ -354,8 +354,8 @@ TEST_F(ProxyScriptFetcherImplTest, Encodings) {
{
GURL url(test_server_.GetURL("files/gzipped_pac"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("This data was gzipped.\n"), text);
@@ -366,8 +366,8 @@ TEST_F(ProxyScriptFetcherImplTest, Encodings) {
{
GURL url(test_server_.GetURL("files/utf16be_pac"));
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_IO_PENDING, result);
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ASCIIToUTF16("This was encoded as UTF-16BE.\n"), text);
@@ -393,8 +393,8 @@ TEST_F(ProxyScriptFetcherImplTest, DataURLs) {
{
GURL url(kEncodedUrl);
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(OK, result);
EXPECT_EQ(ASCIIToUTF16(kPacScript), text);
}
@@ -406,8 +406,8 @@ TEST_F(ProxyScriptFetcherImplTest, DataURLs) {
{
GURL url(kEncodedUrlBroken);
string16 text;
- TestOldCompletionCallback callback;
- int result = pac_fetcher.Fetch(url, &text, &callback);
+ TestCompletionCallback callback;
+ int result = pac_fetcher.Fetch(url, &text, callback.callback());
EXPECT_EQ(ERR_FAILED, result);
}
}
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 647718b..c8193b4 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -108,10 +108,10 @@ class ProxyResolverNull : public ProxyResolver {
public:
ProxyResolverNull() : ProxyResolver(false /*expects_pac_bytes*/) {}
- // ProxyResolver implementation:
+ // ProxyResolver implementation.
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE {
return ERR_NOT_IMPLEMENTED;
@@ -138,7 +138,7 @@ class ProxyResolverNull : public ProxyResolver {
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& /*script_data*/,
- OldCompletionCallback* /*callback*/) OVERRIDE {
+ const CompletionCallback& /*callback*/) OVERRIDE {
return ERR_NOT_IMPLEMENTED;
}
};
@@ -153,7 +153,7 @@ class ProxyResolverFromPacString : public ProxyResolver {
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE {
results->UsePacString(pac_string_);
@@ -181,7 +181,7 @@ class ProxyResolverFromPacString : public ProxyResolver {
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& pac_script,
- OldCompletionCallback* callback) OVERRIDE {
+ const CompletionCallback& callback) OVERRIDE {
return OK;
}
@@ -334,10 +334,7 @@ class ProxyService::InitProxyResolver {
NetLog* net_log)
: decider_(proxy_script_fetcher, dhcp_proxy_script_fetcher, net_log),
effective_config_(NULL),
- proxy_resolver_(proxy_resolver),
- user_callback_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(
- this, &InitProxyResolver::OnIOCompletion)) {
+ proxy_resolver_(proxy_resolver) {
}
~InitProxyResolver() {
@@ -351,11 +348,11 @@ class ProxyService::InitProxyResolver {
int Init(const ProxyConfig& config,
base::TimeDelta wait_delay,
ProxyConfig* effective_config,
- OldCompletionCallback* callback) {
+ const CompletionCallback& callback) {
config_ = config;
wait_delay_ = wait_delay;
effective_config_ = effective_config;
- user_callback_ = callback;
+ callback_ = callback;
next_state_ = STATE_DECIDE_PROXY_SCRIPT;
return DoLoop(OK);
@@ -405,7 +402,7 @@ class ProxyService::InitProxyResolver {
return decider_.Start(
config_, wait_delay_, proxy_resolver_->expects_pac_bytes(),
- &io_callback_);
+ base::Bind(&InitProxyResolver::OnIOCompletion, base::Unretained(this)));
}
int DoDecideProxyScriptComplete(int result) {
@@ -421,7 +418,9 @@ class ProxyService::InitProxyResolver {
DCHECK(decider_.script_data());
// TODO(eroman): Should log this latency to the NetLog.
next_state_ = STATE_SET_PAC_SCRIPT_COMPLETE;
- return proxy_resolver_->SetPacScript(decider_.script_data(), &io_callback_);
+ return proxy_resolver_->SetPacScript(
+ decider_.script_data(),
+ base::Bind(&InitProxyResolver::OnIOCompletion, base::Unretained(this)));
}
int DoSetPacScriptComplete(int result) {
@@ -437,7 +436,7 @@ class ProxyService::InitProxyResolver {
void DoCallback(int result) {
DCHECK_NE(ERR_IO_PENDING, result);
- user_callback_->Run(result);
+ callback_.Run(result);
}
ProxyConfig config_;
@@ -445,8 +444,7 @@ class ProxyService::InitProxyResolver {
ProxyScriptDecider decider_;
ProxyConfig* effective_config_;
ProxyResolver* proxy_resolver_;
- OldCompletionCallback* user_callback_;
- OldCompletionCallbackImpl<InitProxyResolver> io_callback_;
+ CompletionCallback callback_;
State next_state_;
DISALLOW_COPY_AND_ASSIGN(InitProxyResolver);
@@ -457,33 +455,13 @@ class ProxyService::InitProxyResolver {
class ProxyService::PacRequest
: public base::RefCounted<ProxyService::PacRequest> {
public:
- PacRequest(ProxyService* service,
- const GURL& url,
- ProxyInfo* results,
- OldCompletionCallback* user_callback,
- const BoundNetLog& net_log)
- : service_(service),
- old_user_callback_(user_callback),
- ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(
- this, &PacRequest::QueryComplete)),
- results_(results),
- url_(url),
- resolve_job_(NULL),
- config_id_(ProxyConfig::kInvalidConfigID),
- net_log_(net_log) {
- DCHECK(user_callback);
- }
-
- PacRequest(ProxyService* service,
+ PacRequest(ProxyService* service,
const GURL& url,
ProxyInfo* results,
const net::CompletionCallback& user_callback,
const BoundNetLog& net_log)
: service_(service),
- old_user_callback_(NULL),
user_callback_(user_callback),
- ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(
- this, &PacRequest::QueryComplete)),
results_(results),
url_(url),
resolve_job_(NULL),
@@ -502,7 +480,9 @@ class ProxyService::PacRequest
config_id_ = service_->config_.id();
return resolver()->GetProxyForURL(
- url_, results_, &io_callback_, &resolve_job_, net_log_);
+ url_, results_,
+ base::Bind(&PacRequest::QueryComplete, base::Unretained(this)),
+ &resolve_job_, net_log_);
}
bool is_started() const {
@@ -534,7 +514,6 @@ class ProxyService::PacRequest
// Mark as cancelled, to prevent accessing this again later.
service_ = NULL;
- old_user_callback_ = NULL;
user_callback_.Reset();
results_ = NULL;
@@ -543,7 +522,7 @@ class ProxyService::PacRequest
// Returns true if Cancel() has been called.
bool was_cancelled() const {
- return old_user_callback_ == NULL && user_callback_.is_null();
+ return user_callback_.is_null();
}
// Helper to call after ProxyResolver completion (both synchronous and
@@ -581,11 +560,7 @@ class ProxyService::PacRequest
// Remove this completed PacRequest from the service's pending list.
/// (which will probably cause deletion of |this|).
- if (old_user_callback_) {
- OldCompletionCallback* callback = old_user_callback_;
- service_->RemovePendingRequest(this);
- callback->Run(result_code);
- } else if (!user_callback_.is_null()){
+ if (!user_callback_.is_null()){
net::CompletionCallback callback = user_callback_;
service_->RemovePendingRequest(this);
callback.Run(result_code);
@@ -598,9 +573,7 @@ class ProxyService::PacRequest
// requests are cancelled during ~ProxyService, so this is guaranteed
// to be valid throughout our lifetime.
ProxyService* service_;
- OldCompletionCallback* old_user_callback_;
net::CompletionCallback user_callback_;
- OldCompletionCallbackImpl<PacRequest> io_callback_;
ProxyInfo* results_;
GURL url_;
ProxyResolver::RequestHandle resolve_job_;
@@ -615,8 +588,6 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
NetLog* net_log)
: resolver_(resolver),
next_config_id_(1),
- ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_(
- this, &ProxyService::OnInitProxyResolverComplete)),
current_state_(STATE_NONE) ,
net_log_(net_log),
stall_proxy_auto_config_delay_(
@@ -740,54 +711,6 @@ ProxyService* ProxyService::CreateFixedFromPacResult(
int ProxyService::ResolveProxy(const GURL& raw_url,
ProxyInfo* result,
- OldCompletionCallback* callback,
- PacRequest** pac_request,
- const BoundNetLog& net_log) {
- DCHECK(CalledOnValidThread());
- DCHECK(callback);
-
- net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE, NULL);
-
- config_service_->OnLazyPoll();
- if (current_state_ == STATE_NONE)
- ApplyProxyConfigIfAvailable();
-
- // Strip away any reference fragments and the username/password, as they
- // are not relevant to proxy resolution.
- GURL url = SimplifyUrlForRequest(raw_url);
-
- // Check if the request can be completed right away. (This is the case when
- // using a direct connection for example).
- int rv = TryToCompleteSynchronously(url, result);
- if (rv != ERR_IO_PENDING)
- return DidFinishResolvingProxy(result, rv, net_log);
-
- scoped_refptr<PacRequest> req(
- new PacRequest(this, url, result, callback, net_log));
-
- if (current_state_ == STATE_READY) {
- // Start the resolve request.
- rv = req->Start();
- if (rv != ERR_IO_PENDING)
- return req->QueryDidComplete(rv);
- } else {
- req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC,
- NULL);
- }
-
- DCHECK_EQ(ERR_IO_PENDING, rv);
- DCHECK(!ContainsPendingRequest(req));
- pending_requests_.push_back(req);
-
- // Completion will be notified through |callback|, unless the caller cancels
- // the request using |pac_request|.
- if (pac_request)
- *pac_request = req.get();
- return rv; // ERR_IO_PENDING
-}
-
-int ProxyService::ResolveProxy(const GURL& raw_url,
- ProxyInfo* result,
const net::CompletionCallback& callback,
PacRequest** pac_request,
const BoundNetLog& net_log) {
@@ -1242,7 +1165,9 @@ void ProxyService::InitializeUsingLastFetchedConfig() {
stall_proxy_autoconfig_until_ - base::TimeTicks::Now();
int rv = init_proxy_resolver_->Init(
- fetched_config_, wait_delay, &config_, &init_proxy_resolver_callback_);
+ fetched_config_, wait_delay, &config_,
+ base::Bind(&ProxyService::OnInitProxyResolverComplete,
+ base::Unretained(this)));
if (rv != ERR_IO_PENDING)
OnInitProxyResolverComplete(rv);
@@ -1274,8 +1199,10 @@ int SyncProxyServiceHelper::ResolveProxy(const GURL& url,
const BoundNetLog& net_log) {
DCHECK(io_message_loop_ != MessageLoop::current());
- io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SyncProxyServiceHelper::StartAsyncResolve, url, net_log));
+ io_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&SyncProxyServiceHelper::StartAsyncResolve, this, url,
+ net_log));
event_.Wait();
@@ -1289,8 +1216,10 @@ int SyncProxyServiceHelper::ReconsiderProxyAfterError(
const GURL& url, ProxyInfo* proxy_info, const BoundNetLog& net_log) {
DCHECK(io_message_loop_ != MessageLoop::current());
- io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SyncProxyServiceHelper::StartAsyncReconsider, url, net_log));
+ io_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&SyncProxyServiceHelper::StartAsyncReconsider, this, url,
+ net_log));
event_.Wait();
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h
index 0e011c5..41eabb3 100644
--- a/net/proxy/proxy_service.h
+++ b/net/proxy/proxy_service.h
@@ -76,11 +76,6 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// Profiling information for the request is saved to |net_log| if non-NULL.
int ResolveProxy(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
- PacRequest** pac_request,
- const BoundNetLog& net_log);
- int ResolveProxy(const GURL& url,
- ProxyInfo* results,
const net::CompletionCallback& callback,
PacRequest** pac_request,
const BoundNetLog& net_log);
@@ -347,9 +342,6 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// no need for DHCP PAC script fetching.
scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher_;
- // Callback for when |init_proxy_resolver_| is done.
- OldCompletionCallbackImpl<ProxyService> init_proxy_resolver_callback_;
-
// Helper to download the PAC script (wpad + custom) and apply fallback rules.
//
// Note that the declaration is important here: |proxy_script_fetcher_| and
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index e602216..271dfc4 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -81,9 +81,10 @@ TEST(ProxyServiceTest, Direct) {
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = service.ResolveProxy(url, &info, &callback, NULL, log.bound());
+ int rv = service.ResolveProxy(
+ url, &info, callback.callback(), NULL, log.bound());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(resolver->pending_requests().empty());
@@ -114,10 +115,11 @@ TEST(ProxyServiceTest, PAC) {
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = service.ResolveProxy(url, &info, &callback, NULL, log.bound());
+ int rv = service.ResolveProxy(
+ url, &info, callback.callback(), NULL, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -163,8 +165,9 @@ TEST(ProxyServiceTest, PAC_NoIdentityOrHash) {
GURL url("http://username:password@www.google.com/?ref#hash#hash");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(url, &info, &callback, NULL, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(
+ url, &info, callback.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -190,8 +193,9 @@ TEST(ProxyServiceTest, PAC_FailoverWithoutDirect) {
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -213,8 +217,8 @@ TEST(ProxyServiceTest, PAC_FailoverWithoutDirect) {
// left to fallback to, since our proxy list was NOT terminated by
// DIRECT.
TestCompletionCallback callback2;
- rv = service.ReconsiderProxyAfterError(url, &info, callback2.callback(), NULL,
- BoundNetLog());
+ rv = service.ReconsiderProxyAfterError(
+ url, &info, callback2.callback(), NULL, BoundNetLog());
// ReconsiderProxyAfterError returns error indicating nothing left.
EXPECT_EQ(ERR_FAILED, rv);
EXPECT_TRUE(info.is_empty());
@@ -247,8 +251,9 @@ TEST(ProxyServiceTest, PAC_FailoverAfterDirect) {
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -312,8 +317,9 @@ TEST(ProxyServiceTest, ProxyResolverFails) {
// Start first resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -333,8 +339,9 @@ TEST(ProxyServiceTest, ProxyResolverFails) {
// The second resolve request will try to run through the proxy resolver,
// regardless of whether the first request failed in it.
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(url, &info, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(
+ url, &info, callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(1u, resolver->pending_requests().size());
@@ -367,8 +374,9 @@ TEST(ProxyServiceTest, ProxyScriptFetcherFailsDownloadingMandatoryPac) {
// Start first resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -385,8 +393,9 @@ TEST(ProxyServiceTest, ProxyScriptFetcherFailsDownloadingMandatoryPac) {
// As the proxy resolver failed the request and is configured for a mandatory
// PAC script, ProxyService must not implicitly fall-back to DIRECT.
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(url, &info, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(
+ url, &info, callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, rv);
EXPECT_FALSE(info.is_direct());
}
@@ -414,8 +423,9 @@ TEST(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) {
// Start resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(url, &info, &callback, NULL, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(
+ url, &info, callback.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Check that nothing has been sent to the proxy resolver yet.
@@ -456,8 +466,9 @@ TEST(ProxyServiceTest, ProxyResolverFailsInJavaScriptMandatoryPac) {
// Start first resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -478,8 +489,9 @@ TEST(ProxyServiceTest, ProxyResolverFailsInJavaScriptMandatoryPac) {
// The second resolve request will try to run through the proxy resolver,
// regardless of whether the first request failed in it.
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(url, &info, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(
+ url, &info, callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(1u, resolver->pending_requests().size());
@@ -510,8 +522,9 @@ TEST(ProxyServiceTest, ProxyFallback) {
// Get the proxy information.
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -543,8 +556,9 @@ TEST(ProxyServiceTest, ProxyFallback) {
// first proxy as bad.
service.ReportSuccess(info);
- TestOldCompletionCallback callback3;
- rv = service.ResolveProxy(url, &info, &callback3, NULL, BoundNetLog());
+ TestCompletionCallback callback3;
+ rv = service.ResolveProxy(
+ url, &info, callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(1u, resolver->pending_requests().size());
@@ -622,8 +636,9 @@ TEST(ProxyServiceTest, ProxyFallbackToDirect) {
// Get the proxy information.
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -684,8 +699,9 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) {
// Get the proxy information.
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -776,8 +792,9 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) {
// Get the proxy information.
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -807,8 +824,9 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) {
// Fake a PAC failure.
ProxyInfo info2;
- TestOldCompletionCallback callback3;
- rv = service.ResolveProxy(url, &info2, &callback3, NULL, BoundNetLog());
+ TestCompletionCallback callback3;
+ rv = service.ResolveProxy(
+ url, &info2, callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(1u, resolver->pending_requests().size());
@@ -863,8 +881,9 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfigMandatory) {
// Get the proxy information.
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(url, &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(
+ url, &info, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -894,8 +913,9 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfigMandatory) {
// Fake a PAC failure.
ProxyInfo info2;
- TestOldCompletionCallback callback3;
- rv = service.ResolveProxy(url, &info2, &callback3, NULL, BoundNetLog());
+ TestCompletionCallback callback3;
+ rv = service.ResolveProxy(
+ url, &info2, callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(1u, resolver->pending_requests().size());
@@ -937,7 +957,7 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfigMandatory) {
TEST(ProxyServiceTest, ProxyBypassList) {
// Test that the proxy bypass rules are consulted.
- TestOldCompletionCallback callback[2];
+ TestCompletionCallback callback[2];
ProxyInfo info[2];
ProxyConfig config;
config.proxy_rules().ParseFromString("foopy1:8080;foopy2:9090");
@@ -952,12 +972,14 @@ TEST(ProxyServiceTest, ProxyBypassList) {
GURL url2("http://www.webkit.com");
// Request for a .org domain should bypass proxy.
- rv = service.ResolveProxy(url1, &info[0], &callback[0], NULL, BoundNetLog());
+ rv = service.ResolveProxy(
+ url1, &info[0], callback[0].callback(), NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(info[0].is_direct());
// Request for a .com domain hits the proxy.
- rv = service.ResolveProxy(url2, &info[1], &callback[1], NULL, BoundNetLog());
+ rv = service.ResolveProxy(
+ url2, &info[1], callback[1].callback(), NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("foopy1:8080", info[1].proxy_server().ToURI());
}
@@ -972,8 +994,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("http://www.msn.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_FALSE(info.is_direct());
@@ -984,8 +1006,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("ftp://ftp.google.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(info.is_direct());
@@ -996,8 +1018,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("https://webbranch.techcu.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_FALSE(info.is_direct());
@@ -1009,8 +1031,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("http://www.microsoft.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_FALSE(info.is_direct());
@@ -1032,8 +1054,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("http://www.msn.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_FALSE(info.is_direct());
@@ -1044,8 +1066,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("ftp://ftp.google.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_FALSE(info.is_direct());
@@ -1056,8 +1078,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("https://webbranch.techcu.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_FALSE(info.is_direct());
@@ -1068,8 +1090,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
GURL test_url("unknown://www.microsoft.com");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, &info, &callback, NULL,
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_FALSE(info.is_direct());
@@ -1089,9 +1111,9 @@ TEST(ProxyServiceTest, CancelInProgressRequest) {
// Start 3 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Nothing has been sent to the proxy resolver yet, since the proxy
@@ -1107,18 +1129,18 @@ TEST(ProxyServiceTest, CancelInProgressRequest) {
EXPECT_EQ(GURL("http://request1"), resolver->pending_requests()[0]->url());
ProxyInfo info2;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, &request2, BoundNetLog());
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), &request2, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(2u, resolver->pending_requests().size());
EXPECT_EQ(GURL("http://request2"), resolver->pending_requests()[1]->url());
ProxyInfo info3;
- TestOldCompletionCallback callback3;
- rv = service.ResolveProxy(
- GURL("http://request3"), &info3, &callback3, NULL, BoundNetLog());
+ TestCompletionCallback callback3;
+ rv = service.ResolveProxy(GURL("http://request3"), &info3,
+ callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(3u, resolver->pending_requests().size());
EXPECT_EQ(GURL("http://request3"), resolver->pending_requests()[2]->url());
@@ -1167,9 +1189,9 @@ TEST(ProxyServiceTest, InitialPACScriptDownload) {
// Start 3 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// The first request should have triggered download of PAC script.
@@ -1177,15 +1199,15 @@ TEST(ProxyServiceTest, InitialPACScriptDownload) {
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
ProxyInfo info2;
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyInfo info3;
- TestOldCompletionCallback callback3;
- rv = service.ResolveProxy(
- GURL("http://request3"), &info3, &callback3, NULL, BoundNetLog());
+ TestCompletionCallback callback3;
+ rv = service.ResolveProxy(GURL("http://request3"), &info3,
+ callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Nothing has been sent to the resolver yet.
@@ -1247,9 +1269,9 @@ TEST(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) {
// Start 2 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// The first request should have triggered download of PAC script.
@@ -1257,9 +1279,9 @@ TEST(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) {
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
ProxyInfo info2;
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// At this point the ProxyService should be waiting for the
@@ -1305,11 +1327,11 @@ TEST(ProxyServiceTest, CancelWhilePACFetching) {
// Start 3 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
+ TestCompletionCallback callback1;
ProxyService::PacRequest* request1;
CapturingBoundNetLog log1(CapturingNetLog::kUnbounded);
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, &request1, log1.bound());
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), &request1, log1.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// The first request should have triggered download of PAC script.
@@ -1317,16 +1339,16 @@ TEST(ProxyServiceTest, CancelWhilePACFetching) {
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
ProxyInfo info2;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, &request2, BoundNetLog());
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), &request2, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyInfo info3;
- TestOldCompletionCallback callback3;
- rv = service.ResolveProxy(
- GURL("http://request3"), &info3, &callback3, NULL, BoundNetLog());
+ TestCompletionCallback callback3;
+ rv = service.ResolveProxy(GURL("http://request3"), &info3,
+ callback3.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Nothing has been sent to the resolver yet.
@@ -1398,16 +1420,16 @@ TEST(ProxyServiceTest, FallbackFromAutodetectToCustomPac) {
// Start 2 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyInfo info2;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, &request2, BoundNetLog());
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), &request2, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Check that nothing has been sent to the proxy resolver yet.
@@ -1469,16 +1491,16 @@ TEST(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) {
// Start 2 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyInfo info2;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, &request2, BoundNetLog());
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), &request2, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Check that nothing has been sent to the proxy resolver yet.
@@ -1542,16 +1564,16 @@ TEST(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) {
// Start 2 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyInfo info2;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, &request2, BoundNetLog());
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), &request2, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Check that nothing has been sent to the proxy resolver yet.
@@ -1600,9 +1622,9 @@ TEST(ProxyServiceTest, BypassDoesntApplyToPac) {
// Start 1 requests.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
+ TestCompletionCallback callback1;
int rv = service.ResolveProxy(
- GURL("http://www.google.com"), &info1, &callback1, NULL, BoundNetLog());
+ GURL("http://www.google.com"), &info1, callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Check that nothing has been sent to the proxy resolver yet.
@@ -1631,9 +1653,9 @@ TEST(ProxyServiceTest, BypassDoesntApplyToPac) {
// Start another request, it should pickup the bypass item.
ProxyInfo info2;
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(
- GURL("http://www.google.com"), &info2, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(GURL("http://www.google.com"), &info2,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
ASSERT_EQ(1u, resolver->pending_requests().size());
@@ -1668,9 +1690,9 @@ TEST(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) {
// Start 1 request.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://www.google.com"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://www.google.com"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Check that nothing has been sent to the proxy resolver yet.
@@ -1697,8 +1719,9 @@ TEST(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingSet) {
GURL url("http://www.google.com/");
ProxyInfo info;
- TestOldCompletionCallback callback;
- int rv = service.ResolveProxy(url, &info, &callback, NULL, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(
+ url, &info, callback.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
@@ -1714,9 +1737,9 @@ TEST(ProxyServiceTest, ResetProxyConfigService) {
new MockAsyncProxyResolverExpectsBytes, NULL);
ProxyInfo info;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
@@ -1724,9 +1747,9 @@ TEST(ProxyServiceTest, ResetProxyConfigService) {
config2.proxy_rules().ParseFromString("foopy2:8080");
config2.set_auto_detect(false);
service.ResetConfigService(new MockProxyConfigService(config2));
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(GURL("http://request2"), &info,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("foopy2:8080", info.proxy_server().ToURI());
}
@@ -1743,9 +1766,9 @@ TEST(ProxyServiceTest, UpdateConfigFromPACToDirect) {
// Start 1 request.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://www.google.com"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://www.google.com"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Check that nothing has been sent to the proxy resolver yet.
@@ -1774,9 +1797,9 @@ TEST(ProxyServiceTest, UpdateConfigFromPACToDirect) {
// Start another request -- the effective configuration has changed.
ProxyInfo info2;
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(
- GURL("http://www.google.com"), &info2, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(GURL("http://www.google.com"), &info2,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(info2.is_direct());
@@ -1804,9 +1827,9 @@ TEST(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
// Start 1 request.
ProxyInfo info1;
- TestOldCompletionCallback callback1;
- int rv = service.ResolveProxy(
- GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
+ TestCompletionCallback callback1;
+ int rv = service.ResolveProxy(GURL("http://request1"), &info1,
+ callback1.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// The first request should have triggered initial download of PAC script.
@@ -1846,9 +1869,9 @@ TEST(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
// Start a second request.
ProxyInfo info2;
- TestOldCompletionCallback callback2;
- rv = service.ResolveProxy(
- GURL("http://request2"), &info2, &callback2, NULL, BoundNetLog());
+ TestCompletionCallback callback2;
+ rv = service.ResolveProxy(GURL("http://request2"), &info2,
+ callback2.callback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// This second request should have triggered the re-download of the PAC
@@ -1880,10 +1903,9 @@ TEST(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
EXPECT_EQ(OK, callback2.WaitForResult());
EXPECT_EQ("request2:80", info2.proxy_server().ToURI());
- // Check that the expected events were outputted to the log stream.
- // In particular, PROXY_CONFIG_CHANGED should have only been emitted once
- // (for the initial setup), and NOT a second time when the IP address
- // changed.
+ // Check that the expected events were output to the log stream. In particular
+ // PROXY_CONFIG_CHANGED should have only been emitted once (for the initial
+ // setup), and NOT a second time when the IP address changed.
CapturingNetLog::EntryList entries;
log.GetEntries(&entries);
diff --git a/net/proxy/sync_host_resolver_bridge.cc b/net/proxy/sync_host_resolver_bridge.cc
index 69dce07..6ed00dd 100644
--- a/net/proxy/sync_host_resolver_bridge.cc
+++ b/net/proxy/sync_host_resolver_bridge.cc
@@ -86,8 +86,7 @@ int SyncHostResolverBridge::Core::ResolveSynchronously(
// Otherwise start an async resolve on the resolver's thread.
host_resolver_loop_->PostTask(
FROM_HERE,
- NewRunnableMethod(this, &Core::StartResolve,
- info, addresses));
+ base::Bind(&Core::StartResolve, this, info, addresses));
return WaitForResolveCompletion();
}
diff --git a/net/proxy/sync_host_resolver_bridge_unittest.cc b/net/proxy/sync_host_resolver_bridge_unittest.cc
index d862255..ed81e2c 100644
--- a/net/proxy/sync_host_resolver_bridge_unittest.cc
+++ b/net/proxy/sync_host_resolver_bridge_unittest.cc
@@ -83,10 +83,10 @@ class SyncProxyResolver : public ProxyResolver {
virtual int GetProxyForURL(const GURL& url,
ProxyInfo* results,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) {
- EXPECT_FALSE(callback);
+ EXPECT_FALSE(!callback.is_null());
EXPECT_FALSE(request);
// Do a synchronous host resolve.
@@ -124,7 +124,7 @@ class SyncProxyResolver : public ProxyResolver {
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
- OldCompletionCallback* callback) OVERRIDE {
+ const CompletionCallback& callback) OVERRIDE {
return OK;
}
@@ -178,15 +178,16 @@ class IOThread : public base::Thread {
1u));
// Initialize the resolver.
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
proxy_resolver_->SetPacScript(ProxyResolverScriptData::FromURL(GURL()),
- &callback);
+ callback.callback());
EXPECT_EQ(OK, callback.WaitForResult());
// Start an asynchronous request to the proxy resolver
// (note that it will never complete).
- proxy_resolver_->GetProxyForURL(GURL("http://test/"), &results_,
- &callback_, &request_, BoundNetLog());
+ proxy_resolver_->GetProxyForURL(
+ GURL("http://test/"), &results_, callback_.callback(), &request_,
+ BoundNetLog());
}
virtual void CleanUp() OVERRIDE {
@@ -214,7 +215,7 @@ class IOThread : public base::Thread {
scoped_ptr<ProxyResolver> proxy_resolver_;
// Data for the outstanding request to the single threaded proxy resolver.
- TestOldCompletionCallback callback_;
+ TestCompletionCallback callback_;
ProxyInfo results_;
ProxyResolver::RequestHandle request_;
};
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc
index 0e9f6b0..22600af 100644
--- a/net/socket_stream/socket_stream.cc
+++ b/net/socket_stream/socket_stream.cc
@@ -69,8 +69,6 @@ SocketStream::SocketStream(const GURL& url, Delegate* delegate)
ALLOW_THIS_IN_INITIALIZER_LIST(
io_callback_(base::Bind(&SocketStream::OnIOCompleted,
base::Unretained(this)))),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- io_callback_old_(this, &SocketStream::OnIOCompleted)),
read_buf_(NULL),
write_buf_(NULL),
current_write_buf_(NULL),
@@ -551,7 +549,7 @@ int SocketStream::DoResolveProxy() {
// Alternate-Protocol header here for ws:// or TLS NPN extension for wss:// .
return proxy_service()->ResolveProxy(
- proxy_url_, &proxy_info_, &io_callback_old_, &pac_request_, net_log_);
+ proxy_url_, &proxy_info_, io_callback_, &pac_request_, net_log_);
}
int SocketStream::DoResolveProxyComplete(int result) {
diff --git a/net/socket_stream/socket_stream.h b/net/socket_stream/socket_stream.h
index 663091a..1e0d6e4 100644
--- a/net/socket_stream/socket_stream.h
+++ b/net/socket_stream/socket_stream.h
@@ -336,8 +336,7 @@ class NET_EXPORT SocketStream
SSLConfig server_ssl_config_;
SSLConfig proxy_ssl_config_;
- const CompletionCallback io_callback_;
- OldCompletionCallbackImpl<SocketStream> io_callback_old_;
+ CompletionCallback io_callback_;
scoped_refptr<IOBuffer> read_buf_;
int read_buf_size_;