Chromium Code Reviews| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 class c##Proxy : public c##Interface { \ | 310 template <class INNER_CLASS> \ |
| 311 class c##ProxyEx; \ | |
|
Taylor Brandstetter
2016/06/01 20:04:26
I know that "ProxyEx" is a terrible name; what do
| |
| 312 typedef c##ProxyEx<c##Interface> c##Proxy; \ | |
| 313 template <class INNER_CLASS> \ | |
| 314 class c##ProxyEx : public c##Interface { \ | |
| 311 protected: \ | 315 protected: \ |
| 312 typedef c##Interface C; \ | 316 typedef c##Interface C; \ |
| 313 c##Proxy(rtc::Thread* signaling_thread, C* c) \ | 317 c##ProxyEx(rtc::Thread* signaling_thread, INNER_CLASS* c) \ |
| 314 : signaling_thread_(signaling_thread), c_(c) {} \ | 318 : signaling_thread_(signaling_thread), c_(c) {} \ |
| 315 ~c##Proxy() { \ | 319 ~c##ProxyEx() { \ |
| 316 MethodCall0<c##Proxy, void> call( \ | 320 MethodCall0<c##ProxyEx, void> call( \ |
| 317 this, &c##Proxy::Release_s); \ | 321 this, &c##ProxyEx::Release_s); \ |
| 318 call.Marshal(signaling_thread_); \ | 322 call.Marshal(signaling_thread_); \ |
| 319 } \ | 323 } \ |
| 320 \ | 324 \ |
| 321 public: \ | 325 public: \ |
| 322 static rtc::scoped_refptr<C> Create(rtc::Thread* signaling_thread, C* c) { \ | 326 static rtc::scoped_refptr<c##ProxyEx> Create(rtc::Thread* signaling_thread, INNER_CLASS* c) { \ |
| 323 return new rtc::RefCountedObject<c##Proxy>( \ | 327 return new rtc::RefCountedObject<c##ProxyEx>( \ |
| 324 signaling_thread, c); \ | 328 signaling_thread, c); \ |
| 325 } | 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> \ |
| 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, rtc::Thread* worker_thread, \ |
| 342 INNER_CLASS* c) \ | |
| 332 : signaling_thread_(signaling_thread), \ | 343 : signaling_thread_(signaling_thread), \ |
| 333 worker_thread_(worker_thread), \ | 344 worker_thread_(worker_thread), \ |
| 334 c_(c) {} \ | 345 c_(c) {} \ |
| 335 ~c##Proxy() { \ | 346 ~c##ProxyEx() { \ |
| 336 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ | 347 MethodCall0<c##ProxyEx, void> call(this, &c##ProxyEx::Release_s); \ |
| 337 call.Marshal(signaling_thread_); \ | 348 call.Marshal(signaling_thread_); \ |
| 338 } \ | 349 } \ |
| 339 \ | 350 \ |
| 340 public: \ | 351 public: \ |
| 341 static rtc::scoped_refptr<C> Create( \ | 352 static rtc::scoped_refptr<c##ProxyEx> Create( \ |
| 342 rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) { \ | 353 rtc::Thread* signaling_thread, rtc::Thread* worker_thread, INNER_CLASS* c) { \ |
| 343 return new rtc::RefCountedObject<c##Proxy>( \ | 354 return new rtc::RefCountedObject<c##ProxyEx>( \ |
| 344 signaling_thread, worker_thread, c); \ | 355 signaling_thread, worker_thread, c); \ |
| 345 } | 356 } \ |
| 357 const INNER_CLASS* get() const { return c_.get(); } \ | |
| 358 INNER_CLASS* get() { return c_.get(); } \ | |
| 346 | 359 |
| 347 #define PROXY_METHOD0(r, method) \ | 360 #define PROXY_METHOD0(r, method) \ |
| 348 r method() override { \ | 361 r method() override { \ |
| 349 MethodCall0<C, r> call(c_.get(), &C::method); \ | 362 MethodCall0<C, r> call(c_.get(), &C::method); \ |
| 350 return call.Marshal(signaling_thread_); \ | 363 return call.Marshal(signaling_thread_); \ |
| 351 } | 364 } |
| 352 | 365 |
| 353 #define PROXY_CONSTMETHOD0(r, method) \ | 366 #define PROXY_CONSTMETHOD0(r, method) \ |
| 354 r method() const override { \ | 367 r method() const override { \ |
| 355 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ | 368 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 419 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
| 407 return call.Marshal(worker_thread_); \ | 420 return call.Marshal(worker_thread_); \ |
| 408 } | 421 } |
| 409 | 422 |
| 410 #define END_SIGNALING_PROXY() \ | 423 #define END_SIGNALING_PROXY() \ |
| 411 private:\ | 424 private:\ |
| 412 void Release_s() {\ | 425 void Release_s() {\ |
| 413 c_ = NULL;\ | 426 c_ = NULL;\ |
| 414 }\ | 427 }\ |
| 415 mutable rtc::Thread* signaling_thread_;\ | 428 mutable rtc::Thread* signaling_thread_;\ |
| 416 rtc::scoped_refptr<C> c_;\ | 429 rtc::scoped_refptr<INNER_CLASS> c_;\ |
| 417 }; | 430 }; |
| 418 | 431 |
| 419 #define END_PROXY() \ | 432 #define END_PROXY() \ |
| 420 private: \ | 433 private: \ |
| 421 void Release_s() { \ | 434 void Release_s() { \ |
| 422 c_ = NULL; \ | 435 c_ = NULL; \ |
| 423 } \ | 436 } \ |
| 424 mutable rtc::Thread* signaling_thread_; \ | 437 mutable rtc::Thread* signaling_thread_; \ |
| 425 mutable rtc::Thread* worker_thread_; \ | 438 mutable rtc::Thread* worker_thread_; \ |
| 426 rtc::scoped_refptr<C> c_; \ | 439 rtc::scoped_refptr<INNER_CLASS> c_; \ |
| 427 }; \ | 440 }; \ |
| 428 | 441 |
| 429 } // namespace webrtc | 442 } // namespace webrtc |
| 430 | 443 |
| 431 #endif // WEBRTC_API_PROXY_H_ | 444 #endif // WEBRTC_API_PROXY_H_ |
| OLD | NEW |