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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 class c##Proxy : public c##Interface { \ | 310 template <class INNER_CLASS> \ |
311 protected: \ | 311 class c##ProxyEx; \ |
312 typedef c##Interface C; \ | 312 typedef c##ProxyEx<c##Interface> c##Proxy; \ |
313 c##Proxy(rtc::Thread* signaling_thread, C* c) \ | 313 template <class INNER_CLASS> \ |
314 : signaling_thread_(signaling_thread), c_(c) {} \ | 314 class c##ProxyEx : public c##Interface { \ |
315 ~c##Proxy() { \ | 315 protected: \ |
316 MethodCall0<c##Proxy, void> call( \ | 316 typedef c##Interface C; \ |
317 this, &c##Proxy::Release_s); \ | 317 c##ProxyEx(rtc::Thread* signaling_thread, INNER_CLASS* c) \ |
318 call.Marshal(signaling_thread_); \ | 318 : signaling_thread_(signaling_thread), c_(c) {} \ |
319 } \ | 319 ~c##ProxyEx() { \ |
320 \ | 320 MethodCall0<c##ProxyEx, void> call(this, &c##ProxyEx::Release_s); \ |
321 public: \ | 321 call.Marshal(signaling_thread_); \ |
322 static rtc::scoped_refptr<C> Create(rtc::Thread* signaling_thread, C* c) { \ | 322 } \ |
323 return new rtc::RefCountedObject<c##Proxy>( \ | 323 \ |
324 signaling_thread, c); \ | 324 public: \ |
325 } | 325 static rtc::scoped_refptr<c##ProxyEx> Create( \ |
326 rtc::Thread* signaling_thread, \ | |
327 INNER_CLASS* c) { \ | |
328 return new rtc::RefCountedObject<c##ProxyEx>(signaling_thread, c); \ | |
329 } \ | |
330 const INNER_CLASS* get() const { return c_.get(); } \ | |
331 INNER_CLASS* get() { return c_.get(); } | |
326 | 332 |
327 #define BEGIN_PROXY_MAP(c) \ | 333 #define BEGIN_PROXY_MAP(c) \ |
328 class c##Proxy : public c##Interface { \ | 334 template <class INNER_CLASS> \ |
pthatcher1
2016/06/03 00:23:50
Would it make sense to call this INTERNAL_CLASS?
Taylor Brandstetter
2016/06/03 22:48:39
Sure.
| |
335 class c##ProxyEx; \ | |
336 typedef c##ProxyEx<c##Interface> c##Proxy; \ | |
337 template <class INNER_CLASS> \ | |
338 class c##ProxyEx : public c##Interface { \ | |
329 protected: \ | 339 protected: \ |
330 typedef c##Interface C; \ | 340 typedef c##Interface C; \ |
331 c##Proxy(rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) \ | 341 c##ProxyEx(rtc::Thread* signaling_thread, \ |
pthatcher1
2016/06/03 00:23:50
Would it make senes for this to be InternalProxy?
Taylor Brandstetter
2016/06/03 22:48:39
See my other comment. That name implies to me that
pthatcher1
2016/06/03 23:05:49
I think it just implies that you can get to the "i
| |
332 : signaling_thread_(signaling_thread), \ | 342 rtc::Thread* worker_thread, \ |
333 worker_thread_(worker_thread), \ | 343 INNER_CLASS* c) \ |
334 c_(c) {} \ | 344 : signaling_thread_(signaling_thread), \ |
335 ~c##Proxy() { \ | 345 worker_thread_(worker_thread), \ |
336 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ | 346 c_(c) {} \ |
347 ~c##ProxyEx() { \ | |
348 MethodCall0<c##ProxyEx, void> call(this, &c##ProxyEx::Release_s); \ | |
337 call.Marshal(signaling_thread_); \ | 349 call.Marshal(signaling_thread_); \ |
338 } \ | 350 } \ |
339 \ | 351 \ |
340 public: \ | 352 public: \ |
341 static rtc::scoped_refptr<C> Create( \ | 353 static rtc::scoped_refptr<c##ProxyEx> Create( \ |
342 rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) { \ | 354 rtc::Thread* signaling_thread, \ |
343 return new rtc::RefCountedObject<c##Proxy>( \ | 355 rtc::Thread* worker_thread, \ |
344 signaling_thread, worker_thread, c); \ | 356 INNER_CLASS* c) { \ |
345 } | 357 return new rtc::RefCountedObject<c##ProxyEx>(signaling_thread, \ |
358 worker_thread, c); \ | |
359 } \ | |
360 const INNER_CLASS* get() const { return c_.get(); } \ | |
361 INNER_CLASS* get() { return c_.get(); } | |
346 | 362 |
347 #define PROXY_METHOD0(r, method) \ | 363 #define PROXY_METHOD0(r, method) \ |
348 r method() override { \ | 364 r method() override { \ |
349 MethodCall0<C, r> call(c_.get(), &C::method); \ | 365 MethodCall0<C, r> call(c_.get(), &C::method); \ |
350 return call.Marshal(signaling_thread_); \ | 366 return call.Marshal(signaling_thread_); \ |
351 } | 367 } |
352 | 368 |
353 #define PROXY_CONSTMETHOD0(r, method) \ | 369 #define PROXY_CONSTMETHOD0(r, method) \ |
354 r method() const override { \ | 370 r method() const override { \ |
355 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ | 371 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 416 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
401 return call.Marshal(worker_thread_); \ | 417 return call.Marshal(worker_thread_); \ |
402 } | 418 } |
403 | 419 |
404 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ | 420 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ |
405 r method(t1 a1, t2 a2) override { \ | 421 r method(t1 a1, t2 a2) override { \ |
406 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 422 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
407 return call.Marshal(worker_thread_); \ | 423 return call.Marshal(worker_thread_); \ |
408 } | 424 } |
409 | 425 |
410 #define END_SIGNALING_PROXY() \ | 426 #define END_SIGNALING_PROXY() \ |
411 private:\ | 427 private: \ |
412 void Release_s() {\ | 428 void Release_s() { c_ = NULL; } \ |
413 c_ = NULL;\ | 429 mutable rtc::Thread* signaling_thread_; \ |
414 }\ | 430 rtc::scoped_refptr<INNER_CLASS> c_; \ |
415 mutable rtc::Thread* signaling_thread_;\ | 431 } \ |
416 rtc::scoped_refptr<C> c_;\ | 432 ; |
417 }; | |
418 | 433 |
419 #define END_PROXY() \ | 434 #define END_PROXY() \ |
420 private: \ | 435 private: \ |
421 void Release_s() { \ | 436 void Release_s() { c_ = NULL; } \ |
422 c_ = NULL; \ | 437 mutable rtc::Thread* signaling_thread_; \ |
423 } \ | 438 mutable rtc::Thread* worker_thread_; \ |
424 mutable rtc::Thread* signaling_thread_; \ | 439 rtc::scoped_refptr<INNER_CLASS> c_; \ |
425 mutable rtc::Thread* worker_thread_; \ | 440 } \ |
426 rtc::scoped_refptr<C> c_; \ | 441 ; |
pthatcher1
2016/06/03 00:23:50
Should we undo the reformatting here?
Taylor Brandstetter
2016/06/03 22:48:39
This is just what "git cl format" did (yep, it's s
pthatcher1
2016/06/03 23:05:49
It looked better before, so please undo it.
| |
427 }; \ | |
428 | 442 |
429 } // namespace webrtc | 443 } // namespace webrtc |
430 | 444 |
431 #endif // WEBRTC_API_PROXY_H_ | 445 #endif // WEBRTC_API_PROXY_H_ |
OLD | NEW |