Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: content/browser/media/webrtc_identity_store.cc

Issue 22888002: Fixes a leak of WebRTCIdentityRequestHandle when WebRTCIdentityStoreBackend::FindIdentity returns f… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/webrtc_identity_store.h" 5 #include "content/browser/media/webrtc_identity_store.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 backend_(new WebRTCIdentityStoreBackend(path, policy)) {} 180 backend_(new WebRTCIdentityStoreBackend(path, policy)) {}
181 181
182 WebRTCIdentityStore::~WebRTCIdentityStore() { backend_->Close(); } 182 WebRTCIdentityStore::~WebRTCIdentityStore() { backend_->Close(); }
183 183
184 base::Closure WebRTCIdentityStore::RequestIdentity( 184 base::Closure WebRTCIdentityStore::RequestIdentity(
185 const GURL& origin, 185 const GURL& origin,
186 const std::string& identity_name, 186 const std::string& identity_name,
187 const std::string& common_name, 187 const std::string& common_name,
188 const CompletionCallback& callback) { 188 const CompletionCallback& callback) {
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
190
191 WebRTCIdentityRequestHandle* handle =
192 new WebRTCIdentityRequestHandle(this, callback);
193
194 WebRTCIdentityRequest* request = 190 WebRTCIdentityRequest* request =
195 FindRequest(origin, identity_name, common_name); 191 FindRequest(origin, identity_name, common_name);
196
197 // If there is no identical request in flight, create a new one, queue it, 192 // If there is no identical request in flight, create a new one, queue it,
198 // and make the backend request. 193 // and make the backend request.
199 if (!request) { 194 if (!request) {
200 request = new WebRTCIdentityRequest(origin, identity_name, common_name); 195 scoped_ptr<WebRTCIdentityRequest> new_request(
196 new WebRTCIdentityRequest(origin, identity_name, common_name));
201 197
202 if (!backend_->FindIdentity( 198 if (!backend_->FindIdentity(
203 origin, 199 origin,
204 identity_name, 200 identity_name,
205 common_name, 201 common_name,
206 base::Bind( 202 base::Bind(
207 &WebRTCIdentityStore::BackendFindCallback, this, request))) { 203 &WebRTCIdentityStore::BackendFindCallback,
208 delete request; 204 this, new_request.get()))) {
209 return base::Closure(); 205 return base::Closure();
210 } 206 }
207 // |request| will delete itself after the result is posted.
208 request = new_request.release();
Ami GONE FROM CHROMIUM 2013/08/12 17:56:34 TBH I think the old code made it easier to see how
211 in_flight_requests_.push_back(request); 209 in_flight_requests_.push_back(request);
212 } 210 }
213 211
212 WebRTCIdentityRequestHandle* handle =
213 new WebRTCIdentityRequestHandle(this, callback);
214 request->AddCallback( 214 request->AddCallback(
215 handle, 215 handle,
216 base::Bind(&WebRTCIdentityRequestHandle::OnRequestComplete, 216 base::Bind(&WebRTCIdentityRequestHandle::OnRequestComplete,
217 base::Owned(handle))); 217 base::Owned(handle)));
218 handle->OnRequestStarted(request); 218 handle->OnRequestStarted(request);
219 return base::Bind(&WebRTCIdentityRequestHandle::Cancel, 219 return base::Bind(&WebRTCIdentityRequestHandle::Cancel,
220 base::Unretained(handle)); 220 base::Unretained(handle));
221 } 221 }
222 222
223 void WebRTCIdentityStore::DeleteBetween(base::Time delete_begin, 223 void WebRTCIdentityStore::DeleteBetween(base::Time delete_begin,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (in_flight_requests_[i]->origin_ == origin && 299 if (in_flight_requests_[i]->origin_ == origin &&
300 in_flight_requests_[i]->identity_name_ == identity_name && 300 in_flight_requests_[i]->identity_name_ == identity_name &&
301 in_flight_requests_[i]->common_name_ == common_name) { 301 in_flight_requests_[i]->common_name_ == common_name) {
302 return in_flight_requests_[i]; 302 return in_flight_requests_[i];
303 } 303 }
304 } 304 }
305 return NULL; 305 return NULL;
306 } 306 }
307 307
308 } // namespace content 308 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698