Index: content/browser/media/webrtc_identity_store.cc |
diff --git a/content/browser/media/webrtc_identity_store.cc b/content/browser/media/webrtc_identity_store.cc |
index 1c778624ccf2732ce039f33889ecacc905f590a2..67a25851fdeaf01de9c0611b6e892804e76ee771 100644 |
--- a/content/browser/media/webrtc_identity_store.cc |
+++ b/content/browser/media/webrtc_identity_store.cc |
@@ -187,30 +187,29 @@ base::Closure WebRTCIdentityStore::RequestIdentity( |
const std::string& common_name, |
const CompletionCallback& callback) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- |
- WebRTCIdentityRequestHandle* handle = |
- new WebRTCIdentityRequestHandle(this, callback); |
- |
WebRTCIdentityRequest* request = |
FindRequest(origin, identity_name, common_name); |
- |
// If there is no identical request in flight, create a new one, queue it, |
// and make the backend request. |
if (!request) { |
request = new WebRTCIdentityRequest(origin, identity_name, common_name); |
- |
+ // |request| will delete itself after the result is posted. |
if (!backend_->FindIdentity( |
origin, |
identity_name, |
common_name, |
base::Bind( |
&WebRTCIdentityStore::BackendFindCallback, this, request))) { |
+ // Bail out if the backend failed to start the task. |
delete request; |
return base::Closure(); |
} |
in_flight_requests_.push_back(request); |
} |
+ WebRTCIdentityRequestHandle* handle = |
+ new WebRTCIdentityRequestHandle(this, callback); |
+ |
request->AddCallback( |
handle, |
base::Bind(&WebRTCIdentityRequestHandle::OnRequestComplete, |