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

Side by Side Diff: webrtc/api/peerconnectionfactory.cc

Issue 1828463002: Adding comments about threading around CreatePeerConnectionFactory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | webrtc/api/peerconnectioninterface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 rtc::scoped_refptr<RefCountedDtlsIdentityStore> store_; 57 rtc::scoped_refptr<RefCountedDtlsIdentityStore> store_;
58 }; 58 };
59 59
60 } // anonymous namespace 60 } // anonymous namespace
61 61
62 rtc::scoped_refptr<PeerConnectionFactoryInterface> 62 rtc::scoped_refptr<PeerConnectionFactoryInterface>
63 CreatePeerConnectionFactory() { 63 CreatePeerConnectionFactory() {
64 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( 64 rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
65 new rtc::RefCountedObject<PeerConnectionFactory>()); 65 new rtc::RefCountedObject<PeerConnectionFactory>());
66 66
67 67 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread());
68 // Call Initialize synchronously but make sure its executed on 68 // The signaling thread is the current thread so we can
69 // |signaling_thread|. 69 // safely call Initialize directly.
70 MethodCall0<PeerConnectionFactory, bool> call( 70 if (!pc_factory->Initialize()) {
71 pc_factory.get(), 71 return nullptr;
72 &PeerConnectionFactory::Initialize);
73 bool result = call.Marshal(pc_factory->signaling_thread());
74
75 if (!result) {
76 return NULL;
77 } 72 }
78 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), 73 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
79 pc_factory); 74 pc_factory);
80 } 75 }
81 76
82 rtc::scoped_refptr<PeerConnectionFactoryInterface> 77 rtc::scoped_refptr<PeerConnectionFactoryInterface>
83 CreatePeerConnectionFactory( 78 CreatePeerConnectionFactory(
84 rtc::Thread* worker_thread, 79 rtc::Thread* worker_thread,
85 rtc::Thread* signaling_thread, 80 rtc::Thread* signaling_thread,
86 AudioDeviceModule* default_adm, 81 AudioDeviceModule* default_adm,
87 cricket::WebRtcVideoEncoderFactory* encoder_factory, 82 cricket::WebRtcVideoEncoderFactory* encoder_factory,
88 cricket::WebRtcVideoDecoderFactory* decoder_factory) { 83 cricket::WebRtcVideoDecoderFactory* decoder_factory) {
89 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( 84 rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
90 new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread, 85 new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread,
91 signaling_thread, 86 signaling_thread,
92 default_adm, 87 default_adm,
93 encoder_factory, 88 encoder_factory,
94 decoder_factory)); 89 decoder_factory));
95 90
96 // Call Initialize synchronously but make sure its executed on 91 // Call Initialize synchronously but make sure its executed on
97 // |signaling_thread|. 92 // |signaling_thread|.
98 MethodCall0<PeerConnectionFactory, bool> call( 93 MethodCall0<PeerConnectionFactory, bool> call(
99 pc_factory.get(), 94 pc_factory.get(),
100 &PeerConnectionFactory::Initialize); 95 &PeerConnectionFactory::Initialize);
101 bool result = call.Marshal(signaling_thread); 96 bool result = call.Marshal(signaling_thread);
102 97
103 if (!result) { 98 if (!result) {
104 return NULL; 99 return nullptr;
105 } 100 }
106 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); 101 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
107 } 102 }
108 103
109 PeerConnectionFactory::PeerConnectionFactory() 104 PeerConnectionFactory::PeerConnectionFactory()
110 : owns_ptrs_(true), 105 : owns_ptrs_(true),
111 wraps_current_thread_(false), 106 wraps_current_thread_(false),
112 signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()), 107 signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()),
113 worker_thread_(new rtc::Thread) { 108 worker_thread_(new rtc::Thread) {
114 if (!signaling_thread_) { 109 if (!signaling_thread_) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 351 }
357 352
358 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { 353 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
359 ASSERT(worker_thread_ == rtc::Thread::Current()); 354 ASSERT(worker_thread_ == rtc::Thread::Current());
360 return cricket::WebRtcMediaEngineFactory::Create( 355 return cricket::WebRtcMediaEngineFactory::Create(
361 default_adm_.get(), video_encoder_factory_.get(), 356 default_adm_.get(), video_encoder_factory_.get(),
362 video_decoder_factory_.get()); 357 video_decoder_factory_.get());
363 } 358 }
364 359
365 } // namespace webrtc 360 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/peerconnectioninterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698