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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 Method m_; | 289 Method m_; |
| 290 ReturnType<R> r_; | 290 ReturnType<R> r_; |
| 291 T1 a1_; | 291 T1 a1_; |
| 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 { \ |
|
tommi
2016/04/07 11:50:03
nit: Could change this to:
class c##SignalingProxy
nisse-webrtc
2016/04/07 12:51:29
It changes the name of the constructor. I think I'
| |
| 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* signaling_thread, C* c) \ |
| 303 : signaling_thread_(signaling_thread), c_(c) {} \ | |
| 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(signaling_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(rtc::Thread* signaling_thread, C* c) { \ |
| 310 return new rtc::RefCountedObject<c##Proxy>(thread, c); \ | 311 return new rtc::RefCountedObject<c##Proxy>(signaling_thread, c); \ |
| 312 } | |
| 313 | |
| 314 #define BEGIN_WORKER_PROXY_MAP(c) \ | |
| 315 class c##Proxy : public c##Interface { \ | |
| 316 protected: \ | |
| 317 typedef c##Interface C; \ | |
| 318 c##Proxy(rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) \ | |
| 319 : signaling_thread_(signaling_thread), \ | |
|
tommi
2016/04/07 11:50:03
indent looks off... does "git cl format" ignore th
nisse-webrtc
2016/04/07 12:51:29
git cl format wants to change indentation in this
| |
| 320 worker_thread_(worker_thread), \ | |
| 321 c_(c) {} \ | |
| 322 ~c##Proxy() { \ | |
| 323 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ | |
| 324 call.Marshal(signaling_thread_); \ | |
| 325 } \ | |
| 326 \ | |
| 327 public: \ | |
| 328 static rtc::scoped_refptr<C> Create( \ | |
| 329 rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) { \ | |
| 330 return new rtc::RefCountedObject<c##Proxy>( \ | |
| 331 signaling_thread, worker_thread, c); \ | |
| 311 } | 332 } |
| 312 | 333 |
| 313 #define PROXY_METHOD0(r, method) \ | 334 #define PROXY_METHOD0(r, method) \ |
| 314 r method() override { \ | 335 r method() override { \ |
| 315 MethodCall0<C, r> call(c_.get(), &C::method); \ | 336 MethodCall0<C, r> call(c_.get(), &C::method); \ |
| 316 return call.Marshal(owner_thread_); \ | 337 return call.Marshal(signaling_thread_); \ |
| 317 } | 338 } |
| 318 | 339 |
| 319 #define PROXY_CONSTMETHOD0(r, method) \ | 340 #define PROXY_CONSTMETHOD0(r, method) \ |
| 320 r method() const override { \ | 341 r method() const override { \ |
| 321 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ | 342 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ |
| 322 return call.Marshal(owner_thread_); \ | 343 return call.Marshal(signaling_thread_); \ |
| 323 } | 344 } |
| 324 | 345 |
| 325 #define PROXY_METHOD1(r, method, t1) \ | 346 #define PROXY_METHOD1(r, method, t1) \ |
| 326 r method(t1 a1) override { \ | 347 r method(t1 a1) override { \ |
| 327 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 348 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
| 328 return call.Marshal(owner_thread_); \ | 349 return call.Marshal(signaling_thread_); \ |
| 329 } | 350 } |
| 330 | 351 |
| 331 #define PROXY_CONSTMETHOD1(r, method, t1) \ | 352 #define PROXY_CONSTMETHOD1(r, method, t1) \ |
| 332 r method(t1 a1) const override { \ | 353 r method(t1 a1) const override { \ |
| 333 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 354 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
| 334 return call.Marshal(owner_thread_); \ | 355 return call.Marshal(signaling_thread_); \ |
| 335 } | 356 } |
| 336 | 357 |
| 337 #define PROXY_METHOD2(r, method, t1, t2) \ | 358 #define PROXY_METHOD2(r, method, t1, t2) \ |
| 338 r method(t1 a1, t2 a2) override { \ | 359 r method(t1 a1, t2 a2) override { \ |
| 339 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 360 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
| 340 return call.Marshal(owner_thread_); \ | 361 return call.Marshal(signaling_thread_); \ |
| 341 } | 362 } |
| 342 | 363 |
| 343 #define PROXY_METHOD3(r, method, t1, t2, t3) \ | 364 #define PROXY_METHOD3(r, method, t1, t2, t3) \ |
| 344 r method(t1 a1, t2 a2, t3 a3) override { \ | 365 r method(t1 a1, t2 a2, t3 a3) override { \ |
| 345 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ | 366 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ |
| 346 return call.Marshal(owner_thread_); \ | 367 return call.Marshal(signaling_thread_); \ |
| 347 } | 368 } |
| 348 | 369 |
| 349 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ | 370 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ |
| 350 r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \ | 371 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, \ | 372 MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \ |
| 352 a4); \ | 373 a4); \ |
| 353 return call.Marshal(owner_thread_); \ | 374 return call.Marshal(signaling_thread_); \ |
| 354 } | 375 } |
| 355 | 376 |
| 356 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ | 377 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ |
| 357 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ | 378 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, \ | 379 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ |
| 359 a3, a4, a5); \ | 380 a3, a4, a5); \ |
| 360 return call.Marshal(owner_thread_); \ | 381 return call.Marshal(signaling_thread_); \ |
| 382 } | |
| 383 | |
| 384 // Define methods which should be invoked on the worker thread. | |
| 385 #define PROXY_WORKER_METHOD1(r, method, t1) \ | |
| 386 r method(t1 a1) override { \ | |
| 387 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | |
| 388 return call.Marshal(worker_thread_); \ | |
| 389 } | |
| 390 | |
| 391 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ | |
| 392 r method(t1 a1, t2 a2) override { \ | |
| 393 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | |
| 394 return call.Marshal(worker_thread_); \ | |
| 361 } | 395 } |
| 362 | 396 |
| 363 #define END_PROXY() \ | 397 #define END_PROXY() \ |
| 364 private:\ | 398 private:\ |
| 365 void Release_s() {\ | 399 void Release_s() {\ |
| 366 c_ = NULL;\ | 400 c_ = NULL;\ |
| 367 }\ | 401 }\ |
| 368 mutable rtc::Thread* owner_thread_;\ | 402 mutable rtc::Thread* signaling_thread_;\ |
| 369 rtc::scoped_refptr<C> c_;\ | 403 rtc::scoped_refptr<C> c_;\ |
| 370 };\ | 404 };\ |
| 371 | 405 |
| 406 #define END_WORKER_PROXY() \ | |
| 407 private: \ | |
| 408 void Release_s() { \ | |
| 409 c_ = NULL; \ | |
| 410 } \ | |
| 411 mutable rtc::Thread* signaling_thread_; \ | |
| 412 mutable rtc::Thread* worker_thread_; \ | |
| 413 rtc::scoped_refptr<C> c_; \ | |
| 414 }; \ | |
| 415 | |
| 372 } // namespace webrtc | 416 } // namespace webrtc |
| 373 | 417 |
| 374 #endif // WEBRTC_API_PROXY_H_ | 418 #endif // WEBRTC_API_PROXY_H_ |
| OLD | NEW |