No need to use weak reference

Ref-counting manages everything.
This commit is contained in:
Cheng Zhao 2015-11-17 19:00:33 +08:00
parent 24f573eceb
commit 217311ef21
3 changed files with 5 additions and 13 deletions

View file

@ -241,10 +241,7 @@ void SetProxyInIO(net::URLRequestContextGetter* getter,
void PassVerificationResult( void PassVerificationResult(
scoped_refptr<AtomCertVerifier::CertVerifyRequest> request, scoped_refptr<AtomCertVerifier::CertVerifyRequest> request,
bool success) { bool success) {
int result = net::OK; request->ContinueWithResult(success ? net::OK : net::ERR_FAILED);
if (!success)
result = net::ERR_FAILED;
request->ContinueWithResult(result);
} }
} // namespace } // namespace

View file

@ -66,8 +66,7 @@ void AtomCertVerifier::CertVerifyRequest::DelegateToDefaultVerifier() {
key_.flags, key_.flags,
crl_set_.get(), crl_set_.get(),
verify_result_, verify_result_,
base::Bind(&CertVerifyRequest::RunResult, base::Bind(&CertVerifyRequest::RunResult, this),
weak_ptr_factory_.GetWeakPtr()),
out_req_, out_req_,
net_log_); net_log_);
@ -86,15 +85,14 @@ void AtomCertVerifier::CertVerifyRequest::ContinueWithResult(int result) {
if (result != net::ERR_IO_PENDING) { if (result != net::ERR_IO_PENDING) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&CertVerifyRequest::RunResult, base::Bind(&CertVerifyRequest::RunResult,
weak_ptr_factory_.GetWeakPtr(), this,
result)); result));
return; return;
} }
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(&CertVerifyRequest::DelegateToDefaultVerifier, base::Bind(&CertVerifyRequest::DelegateToDefaultVerifier, this));
weak_ptr_factory_.GetWeakPtr()));
} }
AtomCertVerifier::AtomCertVerifier() AtomCertVerifier::AtomCertVerifier()

View file

@ -55,8 +55,7 @@ class AtomCertVerifier : public net::CertVerifier {
verify_result_(verify_result), verify_result_(verify_result),
out_req_(out_req), out_req_(out_req),
net_log_(net_log), net_log_(net_log),
handled_(false), handled_(false) {
weak_ptr_factory_(this) {
} }
void RunResult(int result); void RunResult(int result);
@ -91,8 +90,6 @@ class AtomCertVerifier : public net::CertVerifier {
std::vector<net::CompletionCallback> callbacks_; std::vector<net::CompletionCallback> callbacks_;
bool handled_; bool handled_;
base::WeakPtrFactory<CertVerifyRequest> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CertVerifyRequest); DISALLOW_COPY_AND_ASSIGN(CertVerifyRequest);
}; };