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

Side by Side Diff: talk/app/webrtc/webrtcsessiondescriptionfactory.cc

Issue 1350523003: TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing Mac test. Created 5 years, 3 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED); 158 SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED);
159 } 159 }
160 160
161 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( 161 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
162 rtc::Thread* signaling_thread, 162 rtc::Thread* signaling_thread,
163 cricket::ChannelManager* channel_manager, 163 cricket::ChannelManager* channel_manager,
164 MediaStreamSignaling* mediastream_signaling, 164 MediaStreamSignaling* mediastream_signaling,
165 WebRtcSession* session, 165 WebRtcSession* session,
166 const std::string& session_id, 166 const std::string& session_id,
167 cricket::DataChannelType dct) 167 cricket::DataChannelType dct)
168 : WebRtcSessionDescriptionFactory( 168 : WebRtcSessionDescriptionFactory(signaling_thread,
169 signaling_thread, channel_manager, mediastream_signaling, nullptr, 169 channel_manager,
170 nullptr, session, session_id, dct, false) { 170 mediastream_signaling,
171 nullptr,
172 nullptr,
173 session,
174 session_id,
175 dct,
176 false) {
171 LOG(LS_VERBOSE) << "DTLS-SRTP disabled."; 177 LOG(LS_VERBOSE) << "DTLS-SRTP disabled.";
172 } 178 }
173 179
174 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( 180 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
175 rtc::Thread* signaling_thread, 181 rtc::Thread* signaling_thread,
176 cricket::ChannelManager* channel_manager, 182 cricket::ChannelManager* channel_manager,
177 MediaStreamSignaling* mediastream_signaling, 183 MediaStreamSignaling* mediastream_signaling,
178 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 184 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
179 WebRtcSession* session, 185 WebRtcSession* session,
180 const std::string& session_id, 186 const std::string& session_id,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 signaling_thread, channel_manager, mediastream_signaling, nullptr, 225 signaling_thread, channel_manager, mediastream_signaling, nullptr,
220 nullptr, session, session_id, dct, true) { 226 nullptr, session, session_id, dct, true) {
221 RTC_DCHECK(certificate); 227 RTC_DCHECK(certificate);
222 228
223 certificate_request_state_ = CERTIFICATE_WAITING; 229 certificate_request_state_ = CERTIFICATE_WAITING;
224 230
225 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; has certificate parameter."; 231 LOG(LS_VERBOSE) << "DTLS-SRTP enabled; has certificate parameter.";
226 // We already have a certificate but we wait to do SetIdentity; if we do 232 // We already have a certificate but we wait to do SetIdentity; if we do
227 // it in the constructor then the caller has not had a chance to connect to 233 // it in the constructor then the caller has not had a chance to connect to
228 // SignalIdentityReady. 234 // SignalIdentityReady.
229 signaling_thread_->Post(this, MSG_USE_CONSTRUCTOR_CERTIFICATE, 235 signaling_thread_->Post(
230 new rtc::ScopedRefMessageData<rtc::RTCCertificate>( 236 this, MSG_USE_CONSTRUCTOR_CERTIFICATE,
231 certificate)); 237 new rtc::ScopedRefMessageData<rtc::RTCCertificate>(certificate));
232 } 238 }
233 239
234 WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() { 240 WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() {
235 ASSERT(signaling_thread_->IsCurrent()); 241 ASSERT(signaling_thread_->IsCurrent());
236 242
237 // Fail any requests that were asked for before identity generation completed. 243 // Fail any requests that were asked for before identity generation completed.
238 FailPendingRequests(kFailedDueToSessionShutdown); 244 FailPendingRequests(kFailedDueToSessionShutdown);
239 245
240 // Process all pending notifications in the message queue. If we don't do 246 // Process all pending notifications in the message queue. If we don't do
241 // this, requests will linger and not know they succeeded or failed. 247 // this, requests will linger and not know they succeeded or failed.
242 rtc::MessageList list; 248 rtc::MessageList list;
243 signaling_thread_->Clear(this, rtc::MQID_ANY, &list); 249 signaling_thread_->Clear(this, rtc::MQID_ANY, &list);
244 for (auto& msg : list) { 250 for (auto& msg : list) {
245 if (msg.message_id != MSG_USE_CONSTRUCTOR_CERTIFICATE) { 251 if (msg.message_id != MSG_USE_CONSTRUCTOR_CERTIFICATE) {
246 OnMessage(&msg); 252 OnMessage(&msg);
247 } else { 253 } else {
248 // Skip MSG_USE_CONSTRUCTOR_CERTIFICATE because we don't want to trigger 254 // Skip MSG_USE_CONSTRUCTOR_CERTIFICATE because we don't want to trigger
249 // SetIdentity-related callbacks in the destructor. This can be a problem 255 // SetIdentity-related callbacks in the destructor. This can be a problem
250 // when WebRtcSession listens to the callback but it was the WebRtcSession 256 // when WebRtcSession listens to the callback but it was the WebRtcSession
251 // destructor that caused WebRtcSessionDescriptionFactory's destruction. 257 // destructor that caused WebRtcSessionDescriptionFactory's destruction.
252 // The callback is then ignored, leaking memory allocated by OnMessage for 258 // The callback is then ignored, leaking memory allocated by OnMessage for
253 // MSG_USE_CONSTRUCTOR_CERTIFICATE. 259 // MSG_USE_CONSTRUCTOR_CERTIFICATE.
254 delete msg.pdata; 260 delete msg.pdata;
255 } 261 }
256 } 262 }
257
258 transport_desc_factory_.set_certificate(nullptr);
259 } 263 }
260 264
261 void WebRtcSessionDescriptionFactory::CreateOffer( 265 void WebRtcSessionDescriptionFactory::CreateOffer(
262 CreateSessionDescriptionObserver* observer, 266 CreateSessionDescriptionObserver* observer,
263 const PeerConnectionInterface::RTCOfferAnswerOptions& options) { 267 const PeerConnectionInterface::RTCOfferAnswerOptions& options) {
264 cricket::MediaSessionOptions session_options; 268 cricket::MediaSessionOptions session_options;
265 269
266 std::string error = "CreateOffer"; 270 std::string error = "CreateOffer";
267 if (certificate_request_state_ == CERTIFICATE_FAILED) { 271 if (certificate_request_state_ == CERTIFICATE_FAILED) {
268 error += kFailedDueToIdentityFailed; 272 error += kFailedDueToIdentityFailed;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (create_session_description_requests_.front().type == 533 if (create_session_description_requests_.front().type ==
530 CreateSessionDescriptionRequest::kOffer) { 534 CreateSessionDescriptionRequest::kOffer) {
531 InternalCreateOffer(create_session_description_requests_.front()); 535 InternalCreateOffer(create_session_description_requests_.front());
532 } else { 536 } else {
533 InternalCreateAnswer(create_session_description_requests_.front()); 537 InternalCreateAnswer(create_session_description_requests_.front());
534 } 538 }
535 create_session_description_requests_.pop(); 539 create_session_description_requests_.pop();
536 } 540 }
537 } 541 }
538 } // namespace webrtc 542 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsessiondescriptionfactory.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698