| OLD | NEW |
| 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 Loading... |
| 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 request = new WebRTCIdentityRequest(origin, identity_name, common_name); |
| 201 | 196 // |request| will delete itself after the result is posted. |
| 202 if (!backend_->FindIdentity( | 197 if (!backend_->FindIdentity( |
| 203 origin, | 198 origin, |
| 204 identity_name, | 199 identity_name, |
| 205 common_name, | 200 common_name, |
| 206 base::Bind( | 201 base::Bind( |
| 207 &WebRTCIdentityStore::BackendFindCallback, this, request))) { | 202 &WebRTCIdentityStore::BackendFindCallback, this, request))) { |
| 203 // Bail out if the backend failed to start the task. |
| 208 delete request; | 204 delete request; |
| 209 return base::Closure(); | 205 return base::Closure(); |
| 210 } | 206 } |
| 211 in_flight_requests_.push_back(request); | 207 in_flight_requests_.push_back(request); |
| 212 } | 208 } |
| 213 | 209 |
| 210 WebRTCIdentityRequestHandle* handle = |
| 211 new WebRTCIdentityRequestHandle(this, callback); |
| 212 |
| 214 request->AddCallback( | 213 request->AddCallback( |
| 215 handle, | 214 handle, |
| 216 base::Bind(&WebRTCIdentityRequestHandle::OnRequestComplete, | 215 base::Bind(&WebRTCIdentityRequestHandle::OnRequestComplete, |
| 217 base::Owned(handle))); | 216 base::Owned(handle))); |
| 218 handle->OnRequestStarted(request); | 217 handle->OnRequestStarted(request); |
| 219 return base::Bind(&WebRTCIdentityRequestHandle::Cancel, | 218 return base::Bind(&WebRTCIdentityRequestHandle::Cancel, |
| 220 base::Unretained(handle)); | 219 base::Unretained(handle)); |
| 221 } | 220 } |
| 222 | 221 |
| 223 void WebRTCIdentityStore::DeleteBetween(base::Time delete_begin, | 222 void WebRTCIdentityStore::DeleteBetween(base::Time delete_begin, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 if (in_flight_requests_[i]->origin_ == origin && | 298 if (in_flight_requests_[i]->origin_ == origin && |
| 300 in_flight_requests_[i]->identity_name_ == identity_name && | 299 in_flight_requests_[i]->identity_name_ == identity_name && |
| 301 in_flight_requests_[i]->common_name_ == common_name) { | 300 in_flight_requests_[i]->common_name_ == common_name) { |
| 302 return in_flight_requests_[i]; | 301 return in_flight_requests_[i]; |
| 303 } | 302 } |
| 304 } | 303 } |
| 305 return NULL; | 304 return NULL; |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace content | 307 } // namespace content |
| OLD | NEW |