OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/rtc_certificate_generator.h" | 5 #include "content/renderer/media/rtc_certificate_generator.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "content/renderer/media/peer_connection_identity_store.h" | 10 #include "content/renderer/media/peer_connection_identity_store.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 } | 48 } |
49 ~RTCCertificateIdentityObserver() override {} | 49 ~RTCCertificateIdentityObserver() override {} |
50 | 50 |
51 // Perform |store|->RequestIdentity with this identity observer and ensure | 51 // Perform |store|->RequestIdentity with this identity observer and ensure |
52 // that this identity observer is not deleted until the request has completed | 52 // that this identity observer is not deleted until the request has completed |
53 // by holding on to a reference to itself for the duration of the request. | 53 // by holding on to a reference to itself for the duration of the request. |
54 void RequestIdentity( | 54 void RequestIdentity( |
55 const blink::WebRTCKeyParams& key_params, | 55 const blink::WebRTCKeyParams& key_params, |
56 const GURL& url, | 56 const GURL& url, |
57 const GURL& first_party_for_cookies, | 57 const GURL& first_party_for_cookies, |
58 const rtc::Optional<uint64_t>& expires_ms, | |
58 blink::WebCallbacks<blink::WebRTCCertificate*, void>* observer) { | 59 blink::WebCallbacks<blink::WebRTCCertificate*, void>* observer) { |
59 DCHECK(main_thread_->BelongsToCurrentThread()); | 60 DCHECK(main_thread_->BelongsToCurrentThread()); |
60 DCHECK(!observer_) << "Already have a RequestIdentity in progress."; | 61 DCHECK(!observer_) << "Already have a RequestIdentity in progress."; |
61 DCHECK(observer); | 62 DCHECK(observer); |
62 key_params_ = key_params; | 63 key_params_ = key_params; |
63 observer_ = observer; | 64 observer_ = observer; |
64 // Identity request must be performed on the WebRTC signaling thread. | 65 // Identity request must be performed on the WebRTC signaling thread. |
65 signaling_thread_->PostTask(FROM_HERE, base::Bind( | 66 signaling_thread_->PostTask(FROM_HERE, base::Bind( |
66 &RTCCertificateIdentityObserver::RequestIdentityOnWebRtcSignalingThread, | 67 &RTCCertificateIdentityObserver::RequestIdentityOnWebRtcSignalingThread, |
67 this, url, first_party_for_cookies)); | 68 this, url, first_party_for_cookies, expires_ms)); |
hbos_chromium
2016/03/08 15:02:10
(I'm purposefully using the copy constructor here
| |
68 } | 69 } |
69 | 70 |
70 private: | 71 private: |
71 void RequestIdentityOnWebRtcSignalingThread( | 72 void RequestIdentityOnWebRtcSignalingThread( |
72 GURL url, | 73 GURL url, |
73 GURL first_party_for_cookies) { | 74 GURL first_party_for_cookies, |
75 rtc::Optional<uint64_t> expires_ms) { | |
74 DCHECK(signaling_thread_->BelongsToCurrentThread()); | 76 DCHECK(signaling_thread_->BelongsToCurrentThread()); |
75 rtc::scoped_ptr<PeerConnectionIdentityStore> store( | 77 rtc::scoped_ptr<PeerConnectionIdentityStore> store( |
76 new PeerConnectionIdentityStore( | 78 new PeerConnectionIdentityStore( |
77 main_thread_, signaling_thread_, url, first_party_for_cookies)); | 79 main_thread_, signaling_thread_, url, first_party_for_cookies)); |
78 // Request identity with |this| as the observer. OnSuccess/OnFailure will be | 80 // Request identity with |this| as the observer. OnSuccess/OnFailure will be |
79 // called asynchronously. | 81 // called asynchronously. |
80 store->RequestIdentity(WebRTCKeyParamsToKeyParams(key_params_), this); | 82 store->RequestIdentity(WebRTCKeyParamsToKeyParams(key_params_), |
83 expires_ms, this); | |
81 } | 84 } |
82 | 85 |
83 // webrtc::DtlsIdentityRequestObserver implementation. | 86 // webrtc::DtlsIdentityRequestObserver implementation. |
84 void OnFailure(int error) override { | 87 void OnFailure(int error) override { |
85 DCHECK(signaling_thread_->BelongsToCurrentThread()); | 88 DCHECK(signaling_thread_->BelongsToCurrentThread()); |
86 DCHECK(observer_); | 89 DCHECK(observer_); |
87 main_thread_->PostTask(FROM_HERE, base::Bind( | 90 main_thread_->PostTask(FROM_HERE, base::Bind( |
88 &RTCCertificateIdentityObserver::DoCallbackOnMainThread, | 91 &RTCCertificateIdentityObserver::DoCallbackOnMainThread, |
89 this, nullptr)); | 92 this, nullptr)); |
90 } | 93 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 DISALLOW_COPY_AND_ASSIGN(RTCCertificateIdentityObserver); | 134 DISALLOW_COPY_AND_ASSIGN(RTCCertificateIdentityObserver); |
132 }; | 135 }; |
133 | 136 |
134 } // namespace | 137 } // namespace |
135 | 138 |
136 void RTCCertificateGenerator::generateCertificate( | 139 void RTCCertificateGenerator::generateCertificate( |
137 const blink::WebRTCKeyParams& key_params, | 140 const blink::WebRTCKeyParams& key_params, |
138 const blink::WebURL& url, | 141 const blink::WebURL& url, |
139 const blink::WebURL& first_party_for_cookies, | 142 const blink::WebURL& first_party_for_cookies, |
140 blink::WebCallbacks<blink::WebRTCCertificate*, void>* observer) { | 143 blink::WebCallbacks<blink::WebRTCCertificate*, void>* observer) { |
144 generateCertificateExpires(key_params, url, first_party_for_cookies, | |
145 rtc::Optional<uint64_t>(), observer); | |
146 } | |
147 | |
148 void RTCCertificateGenerator::generateCertificate( | |
149 const blink::WebRTCKeyParams& key_params, | |
150 const blink::WebURL& url, | |
151 const blink::WebURL& first_party_for_cookies, | |
152 uint64_t expires_ms, | |
153 blink::WebCallbacks<blink::WebRTCCertificate*, void>* observer) { | |
154 generateCertificateExpires(key_params, url, first_party_for_cookies, | |
155 rtc::Optional<uint64_t>(expires_ms), observer); | |
156 } | |
157 | |
158 void RTCCertificateGenerator::generateCertificateExpires( | |
Ryan Sleevi
2016/03/08 17:06:11
generateCertificateWithExpiration
hbos_chromium
2016/04/13 17:03:08
Done.
| |
159 const blink::WebRTCKeyParams& key_params, | |
160 const blink::WebURL& url, | |
161 const blink::WebURL& first_party_for_cookies, | |
162 const rtc::Optional<uint64_t>& expires_ms, | |
163 blink::WebCallbacks<blink::WebRTCCertificate*, void>* observer) { | |
141 DCHECK(isSupportedKeyParams(key_params)); | 164 DCHECK(isSupportedKeyParams(key_params)); |
142 | 165 |
143 #if defined(ENABLE_WEBRTC) | 166 #if defined(ENABLE_WEBRTC) |
144 const scoped_refptr<base::SingleThreadTaskRunner> main_thread = | 167 const scoped_refptr<base::SingleThreadTaskRunner> main_thread = |
145 base::ThreadTaskRunnerHandle::Get(); | 168 base::ThreadTaskRunnerHandle::Get(); |
146 | 169 |
147 PeerConnectionDependencyFactory* pc_dependency_factory = | 170 PeerConnectionDependencyFactory* pc_dependency_factory = |
148 RenderThreadImpl::current()->GetPeerConnectionDependencyFactory(); | 171 RenderThreadImpl::current()->GetPeerConnectionDependencyFactory(); |
149 pc_dependency_factory->EnsureInitialized(); | 172 pc_dependency_factory->EnsureInitialized(); |
150 const scoped_refptr<base::SingleThreadTaskRunner> signaling_thread = | 173 const scoped_refptr<base::SingleThreadTaskRunner> signaling_thread = |
151 pc_dependency_factory->GetWebRtcSignalingThread(); | 174 pc_dependency_factory->GetWebRtcSignalingThread(); |
152 | 175 |
153 rtc::scoped_refptr<RTCCertificateIdentityObserver> identity_observer( | 176 rtc::scoped_refptr<RTCCertificateIdentityObserver> identity_observer( |
154 new rtc::RefCountedObject<RTCCertificateIdentityObserver>( | 177 new rtc::RefCountedObject<RTCCertificateIdentityObserver>( |
155 main_thread, signaling_thread)); | 178 main_thread, signaling_thread)); |
156 // |identity_observer| lives until request has completed. | 179 // |identity_observer| lives until request has completed. |
157 identity_observer->RequestIdentity( | 180 identity_observer->RequestIdentity( |
158 key_params, url, first_party_for_cookies, observer); | 181 key_params, url, first_party_for_cookies, expires_ms, observer); |
159 #else | 182 #else |
160 observer->onError(); | 183 observer->onError(); |
161 #endif | 184 #endif |
162 } | 185 } |
163 | 186 |
164 bool RTCCertificateGenerator::isSupportedKeyParams( | 187 bool RTCCertificateGenerator::isSupportedKeyParams( |
165 const blink::WebRTCKeyParams& key_params) { | 188 const blink::WebRTCKeyParams& key_params) { |
166 return WebRTCKeyParamsToKeyParams(key_params).IsValid(); | 189 return WebRTCKeyParamsToKeyParams(key_params).IsValid(); |
167 } | 190 } |
168 | 191 |
169 } // namespace content | 192 } // namespace content |
OLD | NEW |