Chromium Code Reviews| 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/renderer/media/peer_connection_identity_service.h" | 5 #include "content/renderer/media/peer_connection_identity_service.h" |
| 6 | 6 |
| 7 #include "content/renderer/media/webrtc_identity_service.h" | 7 #include "content/renderer/media/webrtc_identity_service.h" |
| 8 #include "content/renderer/render_thread_impl.h" | 8 #include "content/renderer/render_thread_impl.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 PeerConnectionIdentityService* PeerConnectionIdentityService::Create( | 12 PeerConnectionIdentityService::PeerConnectionIdentityService(const GURL& origin) |
| 13 const GURL& origin) { | 13 : origin_(origin), pending_observer_(NULL), pending_request_id_(0) {} |
| 14 // The crypto APIs needed for generating identities are not implenented for | |
| 15 // OPENSSL yet (crbug/91512). So returning NULL in that case. | |
|
Ami GONE FROM CHROMIUM
2013/10/18 22:20:52
Usually when you delete a crbug # in a CL that's a
| |
| 16 // TODO(jiayl): remove the #if once the crypto APIs are implemented for OPENSSL. | |
| 17 #if defined(USE_OPENSSL) | |
| 18 return NULL; | |
| 19 #else | |
| 20 return new PeerConnectionIdentityService(origin); | |
| 21 #endif // defined(USE_OPENSSL) | |
| 22 } | |
| 23 | 14 |
| 24 PeerConnectionIdentityService::~PeerConnectionIdentityService() { | 15 PeerConnectionIdentityService::~PeerConnectionIdentityService() { |
| 25 if (pending_observer_) | 16 if (pending_observer_) |
| 26 RenderThreadImpl::current()->get_webrtc_identity_service() | 17 RenderThreadImpl::current()->get_webrtc_identity_service() |
| 27 ->CancelRequest(pending_request_id_); | 18 ->CancelRequest(pending_request_id_); |
| 28 } | 19 } |
| 29 | 20 |
| 30 bool PeerConnectionIdentityService::RequestIdentity( | 21 bool PeerConnectionIdentityService::RequestIdentity( |
| 31 const std::string& identity_name, | 22 const std::string& identity_name, |
| 32 const std::string& common_name, | 23 const std::string& common_name, |
| 33 webrtc::DTLSIdentityRequestObserver* observer) { | 24 webrtc::DTLSIdentityRequestObserver* observer) { |
| 34 DCHECK(observer); | 25 DCHECK(observer); |
| 35 if (pending_observer_) | 26 if (pending_observer_) |
| 36 return false; | 27 return false; |
| 37 | 28 |
| 38 pending_observer_ = observer; | 29 pending_observer_ = observer; |
| 39 pending_request_id_ = RenderThreadImpl::current() | 30 pending_request_id_ = RenderThreadImpl::current() |
| 40 ->get_webrtc_identity_service()->RequestIdentity( | 31 ->get_webrtc_identity_service()->RequestIdentity( |
| 41 origin_, | 32 origin_, |
| 42 identity_name, | 33 identity_name, |
| 43 common_name, | 34 common_name, |
| 44 base::Bind(&PeerConnectionIdentityService::OnIdentityReady, | 35 base::Bind(&PeerConnectionIdentityService::OnIdentityReady, |
| 45 base::Unretained(this)), | 36 base::Unretained(this)), |
| 46 base::Bind(&PeerConnectionIdentityService::OnRequestFailed, | 37 base::Bind(&PeerConnectionIdentityService::OnRequestFailed, |
| 47 base::Unretained(this))); | 38 base::Unretained(this))); |
| 48 return true; | 39 return true; |
| 49 } | 40 } |
| 50 | 41 |
| 51 PeerConnectionIdentityService::PeerConnectionIdentityService(const GURL& origin) | |
| 52 : origin_(origin), pending_observer_(NULL), pending_request_id_(0) {} | |
| 53 | |
| 54 void PeerConnectionIdentityService::OnIdentityReady( | 42 void PeerConnectionIdentityService::OnIdentityReady( |
| 55 const std::string& certificate, | 43 const std::string& certificate, |
| 56 const std::string& private_key) { | 44 const std::string& private_key) { |
| 57 pending_observer_->OnSuccess(certificate, private_key); | 45 pending_observer_->OnSuccess(certificate, private_key); |
| 58 ResetPendingRequest(); | 46 ResetPendingRequest(); |
| 59 } | 47 } |
| 60 | 48 |
| 61 void PeerConnectionIdentityService::OnRequestFailed(int error) { | 49 void PeerConnectionIdentityService::OnRequestFailed(int error) { |
| 62 pending_observer_->OnFailure(error); | 50 pending_observer_->OnFailure(error); |
| 63 ResetPendingRequest(); | 51 ResetPendingRequest(); |
| 64 } | 52 } |
| 65 | 53 |
| 66 void PeerConnectionIdentityService::ResetPendingRequest() { | 54 void PeerConnectionIdentityService::ResetPendingRequest() { |
| 67 pending_observer_ = NULL; | 55 pending_observer_ = NULL; |
| 68 pending_request_id_ = 0; | 56 pending_request_id_ = 0; |
| 69 } | 57 } |
| 70 | 58 |
| 71 } // namespace content | 59 } // namespace content |
| OLD | NEW |