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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 T2 a2_; | 292 T2 a2_; |
| 293 T3 a3_; | 293 T3 a3_; |
| 294 T4 a4_; | 294 T4 a4_; |
| 295 T5 a5_; | 295 T5 a5_; |
| 296 }; | 296 }; |
| 297 | 297 |
| 298 #define BEGIN_PROXY_MAP(c) \ | 298 #define BEGIN_PROXY_MAP(c) \ |
| 299 class c##Proxy : public c##Interface { \ | 299 class c##Proxy : public c##Interface { \ |
| 300 protected: \ | 300 protected: \ |
| 301 typedef c##Interface C; \ | 301 typedef c##Interface C; \ |
| 302 c##Proxy(rtc::Thread* thread, C* c) : owner_thread_(thread), c_(c) {} \ | 302 c##Proxy(rtc::Thread* signal_thread, C* c) \ |
| 303 : signal_thread_(signal_thread), c_(c) {} \ | |
|
perkj_webrtc
2016/04/05 11:02:37
name signaling_thread_
nisse-webrtc
2016/04/05 11:43:55
Done.
| |
| 303 ~c##Proxy() { \ | 304 ~c##Proxy() { \ |
| 304 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ | 305 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ |
| 305 call.Marshal(owner_thread_); \ | 306 call.Marshal(signal_thread_); \ |
| 306 } \ | 307 } \ |
| 307 \ | 308 \ |
| 308 public: \ | 309 public: \ |
| 309 static rtc::scoped_refptr<C> Create(rtc::Thread* thread, C* c) { \ | 310 static rtc::scoped_refptr<C> Create( \ |
| 310 return new rtc::RefCountedObject<c##Proxy>(thread, c); \ | 311 rtc::Thread* signal_thread, C* c) { \ |
| 312 return new rtc::RefCountedObject<c##Proxy>(signal_thread, c); \ | |
| 313 } | |
| 314 | |
| 315 #define BEGIN_WORKER_PROXY_MAP(c) \ | |
| 316 class c##Proxy : public c##Interface { \ | |
| 317 protected: \ | |
| 318 typedef c##Interface C; \ | |
| 319 c##Proxy(rtc::Thread* signal_thread, rtc::Thread* worker_thread, C* c) \ | |
| 320 : signal_thread_(signal_thread), worker_thread_(worker_thread), c_(c) {} \ | |
| 321 ~c##Proxy() { \ | |
| 322 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ | |
| 323 call.Marshal(signal_thread_); \ | |
| 324 } \ | |
| 325 \ | |
| 326 public: \ | |
| 327 static rtc::scoped_refptr<C> Create( \ | |
| 328 rtc::Thread* signal_thread, rtc::Thread* worker_thread, C* c) { \ | |
| 329 return new rtc::RefCountedObject<c##Proxy>( \ | |
| 330 signal_thread, worker_thread, c); \ | |
| 311 } | 331 } |
| 312 | 332 |
| 313 #define PROXY_METHOD0(r, method) \ | 333 #define PROXY_METHOD0(r, method) \ |
| 314 r method() override { \ | 334 r method() override { \ |
| 315 MethodCall0<C, r> call(c_.get(), &C::method); \ | 335 MethodCall0<C, r> call(c_.get(), &C::method); \ |
| 316 return call.Marshal(owner_thread_); \ | 336 return call.Marshal(signal_thread_); \ |
| 317 } | 337 } |
| 318 | 338 |
| 319 #define PROXY_CONSTMETHOD0(r, method) \ | 339 #define PROXY_CONSTMETHOD0(r, method) \ |
| 320 r method() const override { \ | 340 r method() const override { \ |
| 321 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ | 341 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ |
| 322 return call.Marshal(owner_thread_); \ | 342 return call.Marshal(signal_thread_); \ |
| 323 } | 343 } |
| 324 | 344 |
| 325 #define PROXY_METHOD1(r, method, t1) \ | 345 #define PROXY_METHOD1(r, method, t1) \ |
| 326 r method(t1 a1) override { \ | 346 r method(t1 a1) override { \ |
| 327 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 347 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
| 328 return call.Marshal(owner_thread_); \ | 348 return call.Marshal(signal_thread_); \ |
| 329 } | 349 } |
| 330 | 350 |
| 331 #define PROXY_CONSTMETHOD1(r, method, t1) \ | 351 #define PROXY_CONSTMETHOD1(r, method, t1) \ |
| 332 r method(t1 a1) const override { \ | 352 r method(t1 a1) const override { \ |
| 333 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 353 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
| 334 return call.Marshal(owner_thread_); \ | 354 return call.Marshal(signal_thread_); \ |
| 335 } | 355 } |
| 336 | 356 |
| 337 #define PROXY_METHOD2(r, method, t1, t2) \ | 357 #define PROXY_METHOD2(r, method, t1, t2) \ |
| 338 r method(t1 a1, t2 a2) override { \ | 358 r method(t1 a1, t2 a2) override { \ |
| 339 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 359 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
| 340 return call.Marshal(owner_thread_); \ | 360 return call.Marshal(signal_thread_); \ |
| 341 } | 361 } |
| 342 | 362 |
| 343 #define PROXY_METHOD3(r, method, t1, t2, t3) \ | 363 #define PROXY_METHOD3(r, method, t1, t2, t3) \ |
| 344 r method(t1 a1, t2 a2, t3 a3) override { \ | 364 r method(t1 a1, t2 a2, t3 a3) override { \ |
| 345 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ | 365 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ |
| 346 return call.Marshal(owner_thread_); \ | 366 return call.Marshal(signal_thread_); \ |
| 347 } | 367 } |
| 348 | 368 |
| 349 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ | 369 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ |
| 350 r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \ | 370 r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \ |
| 351 MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \ | 371 MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \ |
| 352 a4); \ | 372 a4); \ |
| 353 return call.Marshal(owner_thread_); \ | 373 return call.Marshal(signal_thread_); \ |
| 354 } | 374 } |
| 355 | 375 |
| 356 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ | 376 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ |
| 357 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ | 377 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ |
| 358 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ | 378 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ |
| 359 a3, a4, a5); \ | 379 a3, a4, a5); \ |
| 360 return call.Marshal(owner_thread_); \ | 380 return call.Marshal(signal_thread_); \ |
| 381 } | |
| 382 | |
| 383 // Define methods which should be invoked on the worker thread. | |
| 384 #define PROXY_WORKER_METHOD1(r, method, t1) \ | |
| 385 r method(t1 a1) override { \ | |
| 386 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | |
| 387 return call.Marshal(worker_thread_); \ | |
| 388 } | |
| 389 | |
| 390 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ | |
| 391 r method(t1 a1, t2 a2) override { \ | |
| 392 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | |
| 393 return call.Marshal(worker_thread_); \ | |
| 361 } | 394 } |
| 362 | 395 |
| 363 #define END_PROXY() \ | 396 #define END_PROXY() \ |
| 364 private:\ | 397 private:\ |
| 365 void Release_s() {\ | 398 void Release_s() {\ |
| 366 c_ = NULL;\ | 399 c_ = NULL;\ |
| 367 }\ | 400 }\ |
| 368 mutable rtc::Thread* owner_thread_;\ | 401 mutable rtc::Thread* signal_thread_;\ |
| 369 rtc::scoped_refptr<C> c_;\ | 402 rtc::scoped_refptr<C> c_;\ |
| 370 };\ | 403 };\ |
| 371 | 404 |
| 405 #define END_WORKER_PROXY() \ | |
| 406 private: \ | |
| 407 void Release_s() { \ | |
| 408 c_ = NULL; \ | |
| 409 } \ | |
| 410 mutable rtc::Thread* signal_thread_; \ | |
| 411 mutable rtc::Thread* worker_thread_; \ | |
| 412 rtc::scoped_refptr<C> c_; \ | |
| 413 }; \ | |
| 414 | |
| 372 } // namespace webrtc | 415 } // namespace webrtc |
| 373 | 416 |
| 374 #endif // WEBRTC_API_PROXY_H_ | 417 #endif // WEBRTC_API_PROXY_H_ |
| OLD | NEW |