OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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/peer_connection_identity_store.h" | 5 #include "content/renderer/media/peer_connection_identity_store.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | 87 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
88 const scoped_refptr<base::SingleThreadTaskRunner> signaling_thread_; | 88 const scoped_refptr<base::SingleThreadTaskRunner> signaling_thread_; |
89 scoped_refptr<webrtc::DtlsIdentityRequestObserver> observer_; | 89 scoped_refptr<webrtc::DtlsIdentityRequestObserver> observer_; |
90 }; | 90 }; |
91 | 91 |
92 // Helper function for PeerConnectionIdentityStore::RequestIdentity. | 92 // Helper function for PeerConnectionIdentityStore::RequestIdentity. |
93 // Used to invoke |observer|->OnSuccess in a PostTask. | 93 // Used to invoke |observer|->OnSuccess in a PostTask. |
94 void ObserverOnSuccess( | 94 void ObserverOnSuccess( |
95 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& observer, | 95 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& observer, |
96 std::unique_ptr<rtc::SSLIdentity> identity) { | 96 std::unique_ptr<rtc::SSLIdentity> identity) { |
97 observer->OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity>(identity.release())); | 97 observer->OnSuccess(std::move(identity)); |
98 } | 98 } |
99 | 99 |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 PeerConnectionIdentityStore::PeerConnectionIdentityStore( | 102 PeerConnectionIdentityStore::PeerConnectionIdentityStore( |
103 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, | 103 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread, |
104 const scoped_refptr<base::SingleThreadTaskRunner>& signaling_thread, | 104 const scoped_refptr<base::SingleThreadTaskRunner>& signaling_thread, |
105 const GURL& url, | 105 const GURL& url, |
106 const GURL& first_party_for_cookies) | 106 const GURL& first_party_for_cookies) |
107 : main_thread_(main_thread), | 107 : main_thread_(main_thread), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // to use |time_t| and stop using |time_t| here, its type is unspecified | 157 // to use |time_t| and stop using |time_t| here, its type is unspecified |
158 // and shouldn't be used if we have a choice. bugs.webrtc.org/5720. | 158 // and shouldn't be used if we have a choice. bugs.webrtc.org/5720. |
159 identity.reset(rtc::SSLIdentity::GenerateWithExpiration( | 159 identity.reset(rtc::SSLIdentity::GenerateWithExpiration( |
160 kIdentityName, key_params, static_cast<time_t>(expires_s))); | 160 kIdentityName, key_params, static_cast<time_t>(expires_s))); |
161 } | 161 } |
162 | 162 |
163 // Invoke |observer| callbacks asynchronously. The callbacks of | 163 // Invoke |observer| callbacks asynchronously. The callbacks of |
164 // DtlsIdentityStoreInterface implementations have to be async. | 164 // DtlsIdentityStoreInterface implementations have to be async. |
165 if (identity) { | 165 if (identity) { |
166 // Async call to |observer|->OnSuccess. | 166 // Async call to |observer|->OnSuccess. |
167 // Helper function necessary because OnSuccess takes an rtc::scoped_ptr | |
168 // argument which has to be Pass()-ed. base::Passed gets around this for | |
169 // scoped_ptr (without rtc namespace), but not for rtc::scoped_ptr. | |
170 signaling_thread_->PostTask(FROM_HERE, | 167 signaling_thread_->PostTask(FROM_HERE, |
171 base::Bind(&ObserverOnSuccess, observer, base::Passed(&identity))); | 168 base::Bind(&ObserverOnSuccess, observer, base::Passed(&identity))); |
172 } else { | 169 } else { |
173 // Async call to |observer|->OnFailure. | 170 // Async call to |observer|->OnFailure. |
174 signaling_thread_->PostTask(FROM_HERE, | 171 signaling_thread_->PostTask(FROM_HERE, |
175 base::Bind(&webrtc::DtlsIdentityRequestObserver::OnFailure, | 172 base::Bind(&webrtc::DtlsIdentityRequestObserver::OnFailure, |
176 observer, 0)); | 173 observer, 0)); |
177 } | 174 } |
178 } | 175 } |
179 } | 176 } |
180 | 177 |
181 } // namespace content | 178 } // namespace content |
OLD | NEW |