diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 02:15:31 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 02:15:31 +0000 |
commit | 2357868189633f0e115648d744522b6063d2c440 (patch) | |
tree | 804b8784c016f8f03820cfd7d4deb3fdb76b0893 /net/proxy/proxy_script_fetcher_impl.cc | |
parent | 05769e3c62f9371a8aef06c810ac6767b410241d (diff) | |
download | chromium_src-2357868189633f0e115648d744522b6063d2c440.zip chromium_src-2357868189633f0e115648d744522b6063d2c440.tar.gz chromium_src-2357868189633f0e115648d744522b6063d2c440.tar.bz2 |
base::Bind: Convert net/proxy.
BUG=none
TEST=none
R=csilv
Review URL: http://codereview.chromium.org/8985012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115068 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_script_fetcher_impl.cc')
-rw-r--r-- | net/proxy/proxy_script_fetcher_impl.cc | 24 |
1 files changed, 11 insertions, 13 deletions
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; } |