OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 namespace internal { | 100 namespace internal { |
101 | 101 |
102 class SynchronousMethodCall | 102 class SynchronousMethodCall |
103 : public rtc::MessageData, | 103 : public rtc::MessageData, |
104 public rtc::MessageHandler { | 104 public rtc::MessageHandler { |
105 public: | 105 public: |
106 explicit SynchronousMethodCall(rtc::MessageHandler* proxy) | 106 explicit SynchronousMethodCall(rtc::MessageHandler* proxy) |
107 : e_(), proxy_(proxy) {} | 107 : e_(), proxy_(proxy) {} |
108 ~SynchronousMethodCall() {} | 108 ~SynchronousMethodCall() {} |
109 | 109 |
110 void Invoke(rtc::Thread* t) { | 110 void Invoke(const rtc::Location& posted_from, rtc::Thread* t) { |
111 if (t->IsCurrent()) { | 111 if (t->IsCurrent()) { |
112 proxy_->OnMessage(NULL); | 112 proxy_->OnMessage(NULL); |
113 } else { | 113 } else { |
114 e_.reset(new rtc::Event(false, false)); | 114 e_.reset(new rtc::Event(false, false)); |
115 t->Post(this, 0); | 115 t->Post(posted_from, this, 0); |
116 e_->Wait(rtc::Event::kForever); | 116 e_->Wait(rtc::Event::kForever); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 void OnMessage(rtc::Message*) { proxy_->OnMessage(NULL); e_->Set(); } | 121 void OnMessage(rtc::Message*) { proxy_->OnMessage(NULL); e_->Set(); } |
122 std::unique_ptr<rtc::Event> e_; | 122 std::unique_ptr<rtc::Event> e_; |
123 rtc::MessageHandler* proxy_; | 123 rtc::MessageHandler* proxy_; |
124 }; | 124 }; |
125 | 125 |
126 } // namespace internal | 126 } // namespace internal |
127 | 127 |
128 template <typename C, typename R> | 128 template <typename C, typename R> |
129 class MethodCall0 : public rtc::Message, | 129 class MethodCall0 : public rtc::Message, |
130 public rtc::MessageHandler { | 130 public rtc::MessageHandler { |
131 public: | 131 public: |
132 typedef R (C::*Method)(); | 132 typedef R (C::*Method)(); |
133 MethodCall0(C* c, Method m) : c_(c), m_(m) {} | 133 MethodCall0(C* c, Method m) : c_(c), m_(m) {} |
134 | 134 |
135 R Marshal(rtc::Thread* t) { | 135 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
136 internal::SynchronousMethodCall(this).Invoke(t); | 136 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
137 return r_.value(); | 137 return r_.value(); |
138 } | 138 } |
139 | 139 |
140 private: | 140 private: |
141 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } | 141 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } |
142 | 142 |
143 C* c_; | 143 C* c_; |
144 Method m_; | 144 Method m_; |
145 ReturnType<R> r_; | 145 ReturnType<R> r_; |
146 }; | 146 }; |
147 | 147 |
148 template <typename C, typename R> | 148 template <typename C, typename R> |
149 class ConstMethodCall0 : public rtc::Message, | 149 class ConstMethodCall0 : public rtc::Message, |
150 public rtc::MessageHandler { | 150 public rtc::MessageHandler { |
151 public: | 151 public: |
152 typedef R (C::*Method)() const; | 152 typedef R (C::*Method)() const; |
153 ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {} | 153 ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {} |
154 | 154 |
155 R Marshal(rtc::Thread* t) { | 155 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
156 internal::SynchronousMethodCall(this).Invoke(t); | 156 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
157 return r_.value(); | 157 return r_.value(); |
158 } | 158 } |
159 | 159 |
160 private: | 160 private: |
161 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } | 161 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } |
162 | 162 |
163 C* c_; | 163 C* c_; |
164 Method m_; | 164 Method m_; |
165 ReturnType<R> r_; | 165 ReturnType<R> r_; |
166 }; | 166 }; |
167 | 167 |
168 template <typename C, typename R, typename T1> | 168 template <typename C, typename R, typename T1> |
169 class MethodCall1 : public rtc::Message, | 169 class MethodCall1 : public rtc::Message, |
170 public rtc::MessageHandler { | 170 public rtc::MessageHandler { |
171 public: | 171 public: |
172 typedef R (C::*Method)(T1 a1); | 172 typedef R (C::*Method)(T1 a1); |
173 MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} | 173 MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} |
174 | 174 |
175 R Marshal(rtc::Thread* t) { | 175 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
176 internal::SynchronousMethodCall(this).Invoke(t); | 176 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
177 return r_.value(); | 177 return r_.value(); |
178 } | 178 } |
179 | 179 |
180 private: | 180 private: |
181 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } | 181 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } |
182 | 182 |
183 C* c_; | 183 C* c_; |
184 Method m_; | 184 Method m_; |
185 ReturnType<R> r_; | 185 ReturnType<R> r_; |
186 T1 a1_; | 186 T1 a1_; |
187 }; | 187 }; |
188 | 188 |
189 template <typename C, typename R, typename T1> | 189 template <typename C, typename R, typename T1> |
190 class ConstMethodCall1 : public rtc::Message, | 190 class ConstMethodCall1 : public rtc::Message, |
191 public rtc::MessageHandler { | 191 public rtc::MessageHandler { |
192 public: | 192 public: |
193 typedef R (C::*Method)(T1 a1) const; | 193 typedef R (C::*Method)(T1 a1) const; |
194 ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} | 194 ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} |
195 | 195 |
196 R Marshal(rtc::Thread* t) { | 196 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
197 internal::SynchronousMethodCall(this).Invoke(t); | 197 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
198 return r_.value(); | 198 return r_.value(); |
199 } | 199 } |
200 | 200 |
201 private: | 201 private: |
202 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } | 202 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } |
203 | 203 |
204 C* c_; | 204 C* c_; |
205 Method m_; | 205 Method m_; |
206 ReturnType<R> r_; | 206 ReturnType<R> r_; |
207 T1 a1_; | 207 T1 a1_; |
208 }; | 208 }; |
209 | 209 |
210 template <typename C, typename R, typename T1, typename T2> | 210 template <typename C, typename R, typename T1, typename T2> |
211 class MethodCall2 : public rtc::Message, | 211 class MethodCall2 : public rtc::Message, |
212 public rtc::MessageHandler { | 212 public rtc::MessageHandler { |
213 public: | 213 public: |
214 typedef R (C::*Method)(T1 a1, T2 a2); | 214 typedef R (C::*Method)(T1 a1, T2 a2); |
215 MethodCall2(C* c, Method m, T1 a1, T2 a2) : c_(c), m_(m), a1_(a1), a2_(a2) {} | 215 MethodCall2(C* c, Method m, T1 a1, T2 a2) : c_(c), m_(m), a1_(a1), a2_(a2) {} |
216 | 216 |
217 R Marshal(rtc::Thread* t) { | 217 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
218 internal::SynchronousMethodCall(this).Invoke(t); | 218 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
219 return r_.value(); | 219 return r_.value(); |
220 } | 220 } |
221 | 221 |
222 private: | 222 private: |
223 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_); } | 223 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_); } |
224 | 224 |
225 C* c_; | 225 C* c_; |
226 Method m_; | 226 Method m_; |
227 ReturnType<R> r_; | 227 ReturnType<R> r_; |
228 T1 a1_; | 228 T1 a1_; |
229 T2 a2_; | 229 T2 a2_; |
230 }; | 230 }; |
231 | 231 |
232 template <typename C, typename R, typename T1, typename T2, typename T3> | 232 template <typename C, typename R, typename T1, typename T2, typename T3> |
233 class MethodCall3 : public rtc::Message, | 233 class MethodCall3 : public rtc::Message, |
234 public rtc::MessageHandler { | 234 public rtc::MessageHandler { |
235 public: | 235 public: |
236 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3); | 236 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3); |
237 MethodCall3(C* c, Method m, T1 a1, T2 a2, T3 a3) | 237 MethodCall3(C* c, Method m, T1 a1, T2 a2, T3 a3) |
238 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3) {} | 238 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3) {} |
239 | 239 |
240 R Marshal(rtc::Thread* t) { | 240 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
241 internal::SynchronousMethodCall(this).Invoke(t); | 241 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
242 return r_.value(); | 242 return r_.value(); |
243 } | 243 } |
244 | 244 |
245 private: | 245 private: |
246 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_); } | 246 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_); } |
247 | 247 |
248 C* c_; | 248 C* c_; |
249 Method m_; | 249 Method m_; |
250 ReturnType<R> r_; | 250 ReturnType<R> r_; |
251 T1 a1_; | 251 T1 a1_; |
252 T2 a2_; | 252 T2 a2_; |
253 T3 a3_; | 253 T3 a3_; |
254 }; | 254 }; |
255 | 255 |
256 template <typename C, typename R, typename T1, typename T2, typename T3, | 256 template <typename C, typename R, typename T1, typename T2, typename T3, |
257 typename T4> | 257 typename T4> |
258 class MethodCall4 : public rtc::Message, | 258 class MethodCall4 : public rtc::Message, |
259 public rtc::MessageHandler { | 259 public rtc::MessageHandler { |
260 public: | 260 public: |
261 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4); | 261 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4); |
262 MethodCall4(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4) | 262 MethodCall4(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4) |
263 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4) {} | 263 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4) {} |
264 | 264 |
265 R Marshal(rtc::Thread* t) { | 265 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
266 internal::SynchronousMethodCall(this).Invoke(t); | 266 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
267 return r_.value(); | 267 return r_.value(); |
268 } | 268 } |
269 | 269 |
270 private: | 270 private: |
271 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_); } | 271 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_); } |
272 | 272 |
273 C* c_; | 273 C* c_; |
274 Method m_; | 274 Method m_; |
275 ReturnType<R> r_; | 275 ReturnType<R> r_; |
276 T1 a1_; | 276 T1 a1_; |
277 T2 a2_; | 277 T2 a2_; |
278 T3 a3_; | 278 T3 a3_; |
279 T4 a4_; | 279 T4 a4_; |
280 }; | 280 }; |
281 | 281 |
282 template <typename C, typename R, typename T1, typename T2, typename T3, | 282 template <typename C, typename R, typename T1, typename T2, typename T3, |
283 typename T4, typename T5> | 283 typename T4, typename T5> |
284 class MethodCall5 : public rtc::Message, | 284 class MethodCall5 : public rtc::Message, |
285 public rtc::MessageHandler { | 285 public rtc::MessageHandler { |
286 public: | 286 public: |
287 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); | 287 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
288 MethodCall5(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) | 288 MethodCall5(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
289 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5) {} | 289 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5) {} |
290 | 290 |
291 R Marshal(rtc::Thread* t) { | 291 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
292 internal::SynchronousMethodCall(this).Invoke(t); | 292 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
293 return r_.value(); | 293 return r_.value(); |
294 } | 294 } |
295 | 295 |
296 private: | 296 private: |
297 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_, a5_); } | 297 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_, a5_); } |
298 | 298 |
299 C* c_; | 299 C* c_; |
300 Method m_; | 300 Method m_; |
301 ReturnType<R> r_; | 301 ReturnType<R> r_; |
302 T1 a1_; | 302 T1 a1_; |
303 T2 a2_; | 303 T2 a2_; |
304 T3 a3_; | 304 T3 a3_; |
305 T4 a4_; | 305 T4 a4_; |
306 T5 a5_; | 306 T5 a5_; |
307 }; | 307 }; |
308 | 308 |
309 #define BEGIN_SIGNALING_PROXY_MAP(c) \ | 309 #define BEGIN_SIGNALING_PROXY_MAP(c) \ |
310 template <class INTERNAL_CLASS> \ | 310 template <class INTERNAL_CLASS> \ |
311 class c##ProxyWithInternal; \ | 311 class c##ProxyWithInternal; \ |
312 typedef c##ProxyWithInternal<c##Interface> c##Proxy; \ | 312 typedef c##ProxyWithInternal<c##Interface> c##Proxy; \ |
313 template <class INTERNAL_CLASS> \ | 313 template <class INTERNAL_CLASS> \ |
314 class c##ProxyWithInternal : public c##Interface { \ | 314 class c##ProxyWithInternal : public c##Interface { \ |
315 protected: \ | 315 protected: \ |
316 typedef c##Interface C; \ | 316 typedef c##Interface C; \ |
317 c##ProxyWithInternal(rtc::Thread* signaling_thread, INTERNAL_CLASS* c) \ | 317 c##ProxyWithInternal(rtc::Thread* signaling_thread, INTERNAL_CLASS* c) \ |
318 : signaling_thread_(signaling_thread), c_(c) {} \ | 318 : signaling_thread_(signaling_thread), c_(c) {} \ |
319 ~c##ProxyWithInternal() { \ | 319 ~c##ProxyWithInternal() { \ |
320 MethodCall0<c##ProxyWithInternal, void> call( \ | 320 MethodCall0<c##ProxyWithInternal, void> call( \ |
321 this, &c##ProxyWithInternal::Release_s); \ | 321 this, &c##ProxyWithInternal::Release_s); \ |
322 call.Marshal(signaling_thread_); \ | 322 call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
323 } \ | 323 } \ |
324 \ | 324 \ |
325 public: \ | 325 public: \ |
326 static rtc::scoped_refptr<c##ProxyWithInternal> Create( \ | 326 static rtc::scoped_refptr<c##ProxyWithInternal> Create( \ |
327 rtc::Thread* signaling_thread, \ | 327 rtc::Thread* signaling_thread, \ |
328 INTERNAL_CLASS* c) { \ | 328 INTERNAL_CLASS* c) { \ |
329 return new rtc::RefCountedObject<c##ProxyWithInternal>(signaling_thread, \ | 329 return new rtc::RefCountedObject<c##ProxyWithInternal>(signaling_thread, \ |
330 c); \ | 330 c); \ |
331 } \ | 331 } \ |
332 const INTERNAL_CLASS* internal() const { return c_.get(); } \ | 332 const INTERNAL_CLASS* internal() const { return c_.get(); } \ |
333 INTERNAL_CLASS* internal() { return c_.get(); } | 333 INTERNAL_CLASS* internal() { return c_.get(); } |
334 | 334 |
335 #define BEGIN_PROXY_MAP(c) \ | 335 #define BEGIN_PROXY_MAP(c) \ |
336 template <class INTERNAL_CLASS> \ | 336 template <class INTERNAL_CLASS> \ |
337 class c##ProxyWithInternal; \ | 337 class c##ProxyWithInternal; \ |
338 typedef c##ProxyWithInternal<c##Interface> c##Proxy; \ | 338 typedef c##ProxyWithInternal<c##Interface> c##Proxy; \ |
339 template <class INTERNAL_CLASS> \ | 339 template <class INTERNAL_CLASS> \ |
340 class c##ProxyWithInternal : public c##Interface { \ | 340 class c##ProxyWithInternal : public c##Interface { \ |
341 protected: \ | 341 protected: \ |
342 typedef c##Interface C; \ | 342 typedef c##Interface C; \ |
343 c##ProxyWithInternal(rtc::Thread* signaling_thread, \ | 343 c##ProxyWithInternal(rtc::Thread* signaling_thread, \ |
344 rtc::Thread* worker_thread, \ | 344 rtc::Thread* worker_thread, \ |
345 INTERNAL_CLASS* c) \ | 345 INTERNAL_CLASS* c) \ |
346 : signaling_thread_(signaling_thread), \ | 346 : signaling_thread_(signaling_thread), \ |
347 worker_thread_(worker_thread), \ | 347 worker_thread_(worker_thread), \ |
348 c_(c) {} \ | 348 c_(c) {} \ |
349 ~c##ProxyWithInternal() { \ | 349 ~c##ProxyWithInternal() { \ |
350 MethodCall0<c##ProxyWithInternal, void> call( \ | 350 MethodCall0<c##ProxyWithInternal, void> call( \ |
351 this, &c##ProxyWithInternal::Release_s); \ | 351 this, &c##ProxyWithInternal::Release_s); \ |
352 call.Marshal(signaling_thread_); \ | 352 call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
353 } \ | 353 } \ |
354 \ | 354 \ |
355 public: \ | 355 public: \ |
356 static rtc::scoped_refptr<c##ProxyWithInternal> Create( \ | 356 static rtc::scoped_refptr<c##ProxyWithInternal> Create( \ |
357 rtc::Thread* signaling_thread, \ | 357 rtc::Thread* signaling_thread, \ |
358 rtc::Thread* worker_thread, \ | 358 rtc::Thread* worker_thread, \ |
359 INTERNAL_CLASS* c) { \ | 359 INTERNAL_CLASS* c) { \ |
360 return new rtc::RefCountedObject<c##ProxyWithInternal>( \ | 360 return new rtc::RefCountedObject<c##ProxyWithInternal>( \ |
361 signaling_thread, worker_thread, c); \ | 361 signaling_thread, worker_thread, c); \ |
362 } \ | 362 } \ |
363 const INTERNAL_CLASS* internal() const { return c_.get(); } \ | 363 const INTERNAL_CLASS* internal() const { return c_.get(); } \ |
364 INTERNAL_CLASS* internal() { return c_.get(); } | 364 INTERNAL_CLASS* internal() { return c_.get(); } |
365 | 365 |
366 #define PROXY_METHOD0(r, method) \ | 366 #define PROXY_METHOD0(r, method) \ |
367 r method() override { \ | 367 r method() override { \ |
368 MethodCall0<C, r> call(c_.get(), &C::method); \ | 368 MethodCall0<C, r> call(c_.get(), &C::method); \ |
369 return call.Marshal(signaling_thread_); \ | 369 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
370 } | 370 } |
371 | 371 |
372 #define PROXY_CONSTMETHOD0(r, method) \ | 372 #define PROXY_CONSTMETHOD0(r, method) \ |
373 r method() const override { \ | 373 r method() const override { \ |
374 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ | 374 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ |
375 return call.Marshal(signaling_thread_); \ | 375 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
376 } | 376 } |
377 | 377 |
378 #define PROXY_METHOD1(r, method, t1) \ | 378 #define PROXY_METHOD1(r, method, t1) \ |
379 r method(t1 a1) override { \ | 379 r method(t1 a1) override { \ |
380 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 380 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
381 return call.Marshal(signaling_thread_); \ | 381 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
382 } | 382 } |
383 | 383 |
384 #define PROXY_CONSTMETHOD1(r, method, t1) \ | 384 #define PROXY_CONSTMETHOD1(r, method, t1) \ |
385 r method(t1 a1) const override { \ | 385 r method(t1 a1) const override { \ |
386 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 386 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
387 return call.Marshal(signaling_thread_); \ | 387 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
388 } | 388 } |
389 | 389 |
390 #define PROXY_METHOD2(r, method, t1, t2) \ | 390 #define PROXY_METHOD2(r, method, t1, t2) \ |
391 r method(t1 a1, t2 a2) override { \ | 391 r method(t1 a1, t2 a2) override { \ |
392 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 392 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
393 return call.Marshal(signaling_thread_); \ | 393 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
394 } | 394 } |
395 | 395 |
396 #define PROXY_METHOD3(r, method, t1, t2, t3) \ | 396 #define PROXY_METHOD3(r, method, t1, t2, t3) \ |
397 r method(t1 a1, t2 a2, t3 a3) override { \ | 397 r method(t1 a1, t2 a2, t3 a3) override { \ |
398 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ | 398 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ |
399 return call.Marshal(signaling_thread_); \ | 399 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
400 } | 400 } |
401 | 401 |
402 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ | 402 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ |
403 r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \ | 403 r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \ |
404 MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \ | 404 MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \ |
405 a4); \ | 405 a4); \ |
406 return call.Marshal(signaling_thread_); \ | 406 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
407 } | 407 } |
408 | 408 |
409 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ | 409 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ |
410 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ | 410 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ |
411 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ | 411 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ |
412 a3, a4, a5); \ | 412 a3, a4, a5); \ |
413 return call.Marshal(signaling_thread_); \ | 413 return call.Marshal(RTC_FROM_HERE, signaling_thread_); \ |
414 } | 414 } |
415 | 415 |
416 // Define methods which should be invoked on the worker thread. | 416 // Define methods which should be invoked on the worker thread. |
417 #define PROXY_WORKER_METHOD1(r, method, t1) \ | 417 #define PROXY_WORKER_METHOD1(r, method, t1) \ |
418 r method(t1 a1) override { \ | 418 r method(t1 a1) override { \ |
419 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 419 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
420 return call.Marshal(worker_thread_); \ | 420 return call.Marshal(RTC_FROM_HERE, worker_thread_); \ |
421 } | 421 } |
422 | 422 |
423 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ | 423 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ |
424 r method(t1 a1, t2 a2) override { \ | 424 r method(t1 a1, t2 a2) override { \ |
425 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 425 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
426 return call.Marshal(worker_thread_); \ | 426 return call.Marshal(RTC_FROM_HERE, worker_thread_); \ |
427 } | 427 } |
428 | 428 |
429 #define END_SIGNALING_PROXY() \ | 429 #define END_SIGNALING_PROXY() \ |
430 private: \ | 430 private: \ |
431 void Release_s() { c_ = NULL; } \ | 431 void Release_s() { c_ = NULL; } \ |
432 mutable rtc::Thread* signaling_thread_; \ | 432 mutable rtc::Thread* signaling_thread_; \ |
433 rtc::scoped_refptr<INTERNAL_CLASS> c_; \ | 433 rtc::scoped_refptr<INTERNAL_CLASS> c_; \ |
434 } \ | 434 } \ |
435 ; | 435 ; |
436 | 436 |
437 #define END_PROXY() \ | 437 #define END_PROXY() \ |
438 private: \ | 438 private: \ |
439 void Release_s() { c_ = NULL; } \ | 439 void Release_s() { c_ = NULL; } \ |
440 mutable rtc::Thread* signaling_thread_; \ | 440 mutable rtc::Thread* signaling_thread_; \ |
441 mutable rtc::Thread* worker_thread_; \ | 441 mutable rtc::Thread* worker_thread_; \ |
442 rtc::scoped_refptr<INTERNAL_CLASS> c_; \ | 442 rtc::scoped_refptr<INTERNAL_CLASS> c_; \ |
443 } \ | 443 } \ |
444 ; | 444 ; |
445 | 445 |
446 } // namespace webrtc | 446 } // namespace webrtc |
447 | 447 |
448 #endif // WEBRTC_API_PROXY_H_ | 448 #endif // WEBRTC_API_PROXY_H_ |
OLD | NEW |