Commit ef37ad03 authored by jiayl@chromium.org's avatar jiayl@chromium.org

Fixes a leak of WebRTCIdentityRequestHandle when...

Fixes a leak of WebRTCIdentityRequestHandle when WebRTCIdentityStoreBackend::FindIdentity returns false.

BUG=

Review URL: https://chromiumcodereview.appspot.com/22888002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217108 0039d316-1c4b-4281-b951-d872f2087c98
parent 4f517124
...@@ -187,30 +187,29 @@ base::Closure WebRTCIdentityStore::RequestIdentity( ...@@ -187,30 +187,29 @@ base::Closure WebRTCIdentityStore::RequestIdentity(
const std::string& common_name, const std::string& common_name,
const CompletionCallback& callback) { const CompletionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
WebRTCIdentityRequestHandle* handle =
new WebRTCIdentityRequestHandle(this, callback);
WebRTCIdentityRequest* request = WebRTCIdentityRequest* request =
FindRequest(origin, identity_name, common_name); FindRequest(origin, identity_name, common_name);
// If there is no identical request in flight, create a new one, queue it, // If there is no identical request in flight, create a new one, queue it,
// and make the backend request. // and make the backend request.
if (!request) { if (!request) {
request = new WebRTCIdentityRequest(origin, identity_name, common_name); request = new WebRTCIdentityRequest(origin, identity_name, common_name);
// |request| will delete itself after the result is posted.
if (!backend_->FindIdentity( if (!backend_->FindIdentity(
origin, origin,
identity_name, identity_name,
common_name, common_name,
base::Bind( base::Bind(
&WebRTCIdentityStore::BackendFindCallback, this, request))) { &WebRTCIdentityStore::BackendFindCallback, this, request))) {
// Bail out if the backend failed to start the task.
delete request; delete request;
return base::Closure(); return base::Closure();
} }
in_flight_requests_.push_back(request); in_flight_requests_.push_back(request);
} }
WebRTCIdentityRequestHandle* handle =
new WebRTCIdentityRequestHandle(this, callback);
request->AddCallback( request->AddCallback(
handle, handle,
base::Bind(&WebRTCIdentityRequestHandle::OnRequestComplete, base::Bind(&WebRTCIdentityRequestHandle::OnRequestComplete,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment