Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 template<typename C, typename M, typename T1, typename T2, typename T3, | 74 template<typename C, typename M, typename T1, typename T2, typename T3, |
| 75 typename T4> | 75 typename T4> |
| 76 void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4) { | 76 void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4) { |
| 77 r_ = (c->*m)(a1, a2, a3, a4); | 77 r_ = (c->*m)(a1, a2, a3, a4); |
| 78 } | 78 } |
| 79 template<typename C, typename M, typename T1, typename T2, typename T3, | 79 template<typename C, typename M, typename T1, typename T2, typename T3, |
| 80 typename T4, typename T5> | 80 typename T4, typename T5> |
| 81 void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { | 81 void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { |
| 82 r_ = (c->*m)(a1, a2, a3, a4, a5); | 82 r_ = (c->*m)(a1, a2, a3, a4, a5); |
| 83 } | 83 } |
| 84 template<typename C, typename M, typename T1, typename T2, typename T3, | |
|
tommi (sloooow) - chröme
2015/08/18 14:49:35
do you want to land this change in a separate cl f
| |
| 85 typename T4, typename T5, typename T6> | |
| 86 void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) { | |
| 87 r_ = (c->*m)(a1, a2, a3, a4, a5, a6); | |
| 88 } | |
| 84 | 89 |
| 85 R value() { return r_; } | 90 R value() { return r_; } |
| 86 | 91 |
| 87 private: | 92 private: |
| 88 R r_; | 93 R r_; |
| 89 }; | 94 }; |
| 90 | 95 |
| 91 template <> | 96 template <> |
| 92 class ReturnType<void> { | 97 class ReturnType<void> { |
| 93 public: | 98 public: |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 C* c_; | 310 C* c_; |
| 306 Method m_; | 311 Method m_; |
| 307 ReturnType<R> r_; | 312 ReturnType<R> r_; |
| 308 T1 a1_; | 313 T1 a1_; |
| 309 T2 a2_; | 314 T2 a2_; |
| 310 T3 a3_; | 315 T3 a3_; |
| 311 T4 a4_; | 316 T4 a4_; |
| 312 T5 a5_; | 317 T5 a5_; |
| 313 }; | 318 }; |
| 314 | 319 |
| 320 template <typename C, typename R, typename T1, typename T2, typename T3, | |
| 321 typename T4, typename T5, typename T6> | |
| 322 class MethodCall6 : public rtc::Message, | |
| 323 public rtc::MessageHandler { | |
| 324 public: | |
| 325 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); | |
| 326 MethodCall6(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) | |
| 327 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5), a6_(a6) {} | |
| 328 | |
| 329 R Marshal(rtc::Thread* t) { | |
| 330 internal::SynchronousMethodCall(this).Invoke(t); | |
| 331 return r_.value(); | |
| 332 } | |
| 333 | |
| 334 private: | |
| 335 void OnMessage(rtc::Message*) { | |
| 336 r_.Invoke(c_, m_, a1_, a2_, a3_, a4_, a5_, a6_); | |
| 337 } | |
| 338 | |
| 339 C* c_; | |
| 340 Method m_; | |
| 341 ReturnType<R> r_; | |
| 342 T1 a1_; | |
| 343 T2 a2_; | |
| 344 T3 a3_; | |
| 345 T4 a4_; | |
| 346 T5 a5_; | |
| 347 T6 a6_; | |
| 348 }; | |
| 349 | |
| 315 #define BEGIN_PROXY_MAP(c) \ | 350 #define BEGIN_PROXY_MAP(c) \ |
| 316 class c##Proxy : public c##Interface { \ | 351 class c##Proxy : public c##Interface { \ |
| 317 protected: \ | 352 protected: \ |
| 318 typedef c##Interface C; \ | 353 typedef c##Interface C; \ |
| 319 c##Proxy(rtc::Thread* thread, C* c) : owner_thread_(thread), c_(c) {} \ | 354 c##Proxy(rtc::Thread* thread, C* c) : owner_thread_(thread), c_(c) {} \ |
| 320 ~c##Proxy() { \ | 355 ~c##Proxy() { \ |
| 321 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ | 356 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ |
| 322 call.Marshal(owner_thread_); \ | 357 call.Marshal(owner_thread_); \ |
| 323 } \ | 358 } \ |
| 324 \ | 359 \ |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 return call.Marshal(owner_thread_); \ | 405 return call.Marshal(owner_thread_); \ |
| 371 } | 406 } |
| 372 | 407 |
| 373 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ | 408 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ |
| 374 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ | 409 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ |
| 375 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ | 410 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ |
| 376 a3, a4, a5); \ | 411 a3, a4, a5); \ |
| 377 return call.Marshal(owner_thread_); \ | 412 return call.Marshal(owner_thread_); \ |
| 378 } | 413 } |
| 379 | 414 |
| 415 #define PROXY_METHOD6(r, method, t1, t2, t3, t4, t5, t6) \ | |
| 416 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) override { \ | |
| 417 MethodCall6<C, r, t1, t2, t3, t4, t5, t6> call(c_.get(), &C::method, a1, \ | |
| 418 a2, a3, a4, a5, a6); \ | |
| 419 return call.Marshal(owner_thread_); \ | |
| 420 } | |
| 421 | |
| 380 #define END_PROXY() \ | 422 #define END_PROXY() \ |
| 381 private:\ | 423 private:\ |
| 382 void Release_s() {\ | 424 void Release_s() {\ |
| 383 c_ = NULL;\ | 425 c_ = NULL;\ |
| 384 }\ | 426 }\ |
| 385 mutable rtc::Thread* owner_thread_;\ | 427 mutable rtc::Thread* owner_thread_;\ |
| 386 rtc::scoped_refptr<C> c_;\ | 428 rtc::scoped_refptr<C> c_;\ |
| 387 };\ | 429 };\ |
| 388 | 430 |
| 389 } // namespace webrtc | 431 } // namespace webrtc |
| 390 | 432 |
| 391 #endif // TALK_APP_WEBRTC_PROXY_H_ | 433 #endif // TALK_APP_WEBRTC_PROXY_H_ |
| OLD | NEW |