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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 namespace internal { | 100 namespace internal { |
101 | 101 |
102 class SynchronousMethodCall | 102 class SynchronousMethodCall |
103 : public rtc::MessageData, | 103 : public rtc::MessageData, |
104 public rtc::MessageHandler { | 104 public rtc::MessageHandler { |
105 public: | 105 public: |
106 explicit SynchronousMethodCall(rtc::MessageHandler* proxy) | 106 explicit SynchronousMethodCall(rtc::MessageHandler* proxy) |
107 : e_(), proxy_(proxy) {} | 107 : e_(), proxy_(proxy) {} |
108 ~SynchronousMethodCall() {} | 108 ~SynchronousMethodCall() {} |
109 | 109 |
110 void Invoke(rtc::Thread* t) { | 110 void Invoke(const rtc::Location& posted_from, rtc::Thread* t) { |
111 if (t->IsCurrent()) { | 111 if (t->IsCurrent()) { |
112 proxy_->OnMessage(NULL); | 112 proxy_->OnMessage(NULL); |
113 } else { | 113 } else { |
114 e_.reset(new rtc::Event(false, false)); | 114 e_.reset(new rtc::Event(false, false)); |
115 t->Post(this, 0); | 115 t->Post(posted_from, this, 0); |
116 e_->Wait(rtc::Event::kForever); | 116 e_->Wait(rtc::Event::kForever); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 void OnMessage(rtc::Message*) { proxy_->OnMessage(NULL); e_->Set(); } | 121 void OnMessage(rtc::Message*) { proxy_->OnMessage(NULL); e_->Set(); } |
122 std::unique_ptr<rtc::Event> e_; | 122 std::unique_ptr<rtc::Event> e_; |
123 rtc::MessageHandler* proxy_; | 123 rtc::MessageHandler* proxy_; |
124 }; | 124 }; |
125 | 125 |
126 } // namespace internal | 126 } // namespace internal |
127 | 127 |
128 template <typename C, typename R> | 128 template <typename C, typename R> |
129 class MethodCall0 : public rtc::Message, | 129 class MethodCall0 : public rtc::Message, |
130 public rtc::MessageHandler { | 130 public rtc::MessageHandler { |
131 public: | 131 public: |
132 typedef R (C::*Method)(); | 132 typedef R (C::*Method)(); |
133 MethodCall0(C* c, Method m) : c_(c), m_(m) {} | 133 MethodCall0(C* c, Method m) : c_(c), m_(m) {} |
134 | 134 |
135 R Marshal(rtc::Thread* t) { | 135 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
136 internal::SynchronousMethodCall(this).Invoke(t); | 136 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
137 return r_.value(); | 137 return r_.value(); |
138 } | 138 } |
139 | 139 |
140 private: | 140 private: |
141 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } | 141 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } |
142 | 142 |
143 C* c_; | 143 C* c_; |
144 Method m_; | 144 Method m_; |
145 ReturnType<R> r_; | 145 ReturnType<R> r_; |
146 }; | 146 }; |
147 | 147 |
148 template <typename C, typename R> | 148 template <typename C, typename R> |
149 class ConstMethodCall0 : public rtc::Message, | 149 class ConstMethodCall0 : public rtc::Message, |
150 public rtc::MessageHandler { | 150 public rtc::MessageHandler { |
151 public: | 151 public: |
152 typedef R (C::*Method)() const; | 152 typedef R (C::*Method)() const; |
153 ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {} | 153 ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {} |
154 | 154 |
155 R Marshal(rtc::Thread* t) { | 155 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
156 internal::SynchronousMethodCall(this).Invoke(t); | 156 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
157 return r_.value(); | 157 return r_.value(); |
158 } | 158 } |
159 | 159 |
160 private: | 160 private: |
161 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } | 161 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); } |
162 | 162 |
163 C* c_; | 163 C* c_; |
164 Method m_; | 164 Method m_; |
165 ReturnType<R> r_; | 165 ReturnType<R> r_; |
166 }; | 166 }; |
167 | 167 |
168 template <typename C, typename R, typename T1> | 168 template <typename C, typename R, typename T1> |
169 class MethodCall1 : public rtc::Message, | 169 class MethodCall1 : public rtc::Message, |
170 public rtc::MessageHandler { | 170 public rtc::MessageHandler { |
171 public: | 171 public: |
172 typedef R (C::*Method)(T1 a1); | 172 typedef R (C::*Method)(T1 a1); |
173 MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} | 173 MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} |
174 | 174 |
175 R Marshal(rtc::Thread* t) { | 175 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
176 internal::SynchronousMethodCall(this).Invoke(t); | 176 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
177 return r_.value(); | 177 return r_.value(); |
178 } | 178 } |
179 | 179 |
180 private: | 180 private: |
181 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } | 181 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } |
182 | 182 |
183 C* c_; | 183 C* c_; |
184 Method m_; | 184 Method m_; |
185 ReturnType<R> r_; | 185 ReturnType<R> r_; |
186 T1 a1_; | 186 T1 a1_; |
187 }; | 187 }; |
188 | 188 |
189 template <typename C, typename R, typename T1> | 189 template <typename C, typename R, typename T1> |
190 class ConstMethodCall1 : public rtc::Message, | 190 class ConstMethodCall1 : public rtc::Message, |
191 public rtc::MessageHandler { | 191 public rtc::MessageHandler { |
192 public: | 192 public: |
193 typedef R (C::*Method)(T1 a1) const; | 193 typedef R (C::*Method)(T1 a1) const; |
194 ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} | 194 ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {} |
195 | 195 |
196 R Marshal(rtc::Thread* t) { | 196 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
197 internal::SynchronousMethodCall(this).Invoke(t); | 197 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
198 return r_.value(); | 198 return r_.value(); |
199 } | 199 } |
200 | 200 |
201 private: | 201 private: |
202 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } | 202 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_); } |
203 | 203 |
204 C* c_; | 204 C* c_; |
205 Method m_; | 205 Method m_; |
206 ReturnType<R> r_; | 206 ReturnType<R> r_; |
207 T1 a1_; | 207 T1 a1_; |
208 }; | 208 }; |
209 | 209 |
210 template <typename C, typename R, typename T1, typename T2> | 210 template <typename C, typename R, typename T1, typename T2> |
211 class MethodCall2 : public rtc::Message, | 211 class MethodCall2 : public rtc::Message, |
212 public rtc::MessageHandler { | 212 public rtc::MessageHandler { |
213 public: | 213 public: |
214 typedef R (C::*Method)(T1 a1, T2 a2); | 214 typedef R (C::*Method)(T1 a1, T2 a2); |
215 MethodCall2(C* c, Method m, T1 a1, T2 a2) : c_(c), m_(m), a1_(a1), a2_(a2) {} | 215 MethodCall2(C* c, Method m, T1 a1, T2 a2) : c_(c), m_(m), a1_(a1), a2_(a2) {} |
216 | 216 |
217 R Marshal(rtc::Thread* t) { | 217 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
218 internal::SynchronousMethodCall(this).Invoke(t); | 218 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
219 return r_.value(); | 219 return r_.value(); |
220 } | 220 } |
221 | 221 |
222 private: | 222 private: |
223 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_); } | 223 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_); } |
224 | 224 |
225 C* c_; | 225 C* c_; |
226 Method m_; | 226 Method m_; |
227 ReturnType<R> r_; | 227 ReturnType<R> r_; |
228 T1 a1_; | 228 T1 a1_; |
229 T2 a2_; | 229 T2 a2_; |
230 }; | 230 }; |
231 | 231 |
232 template <typename C, typename R, typename T1, typename T2, typename T3> | 232 template <typename C, typename R, typename T1, typename T2, typename T3> |
233 class MethodCall3 : public rtc::Message, | 233 class MethodCall3 : public rtc::Message, |
234 public rtc::MessageHandler { | 234 public rtc::MessageHandler { |
235 public: | 235 public: |
236 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3); | 236 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3); |
237 MethodCall3(C* c, Method m, T1 a1, T2 a2, T3 a3) | 237 MethodCall3(C* c, Method m, T1 a1, T2 a2, T3 a3) |
238 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3) {} | 238 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3) {} |
239 | 239 |
240 R Marshal(rtc::Thread* t) { | 240 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
241 internal::SynchronousMethodCall(this).Invoke(t); | 241 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
242 return r_.value(); | 242 return r_.value(); |
243 } | 243 } |
244 | 244 |
245 private: | 245 private: |
246 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_); } | 246 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_); } |
247 | 247 |
248 C* c_; | 248 C* c_; |
249 Method m_; | 249 Method m_; |
250 ReturnType<R> r_; | 250 ReturnType<R> r_; |
251 T1 a1_; | 251 T1 a1_; |
252 T2 a2_; | 252 T2 a2_; |
253 T3 a3_; | 253 T3 a3_; |
254 }; | 254 }; |
255 | 255 |
256 template <typename C, typename R, typename T1, typename T2, typename T3, | 256 template <typename C, typename R, typename T1, typename T2, typename T3, |
257 typename T4> | 257 typename T4> |
258 class MethodCall4 : public rtc::Message, | 258 class MethodCall4 : public rtc::Message, |
259 public rtc::MessageHandler { | 259 public rtc::MessageHandler { |
260 public: | 260 public: |
261 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4); | 261 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4); |
262 MethodCall4(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4) | 262 MethodCall4(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4) |
263 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4) {} | 263 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4) {} |
264 | 264 |
265 R Marshal(rtc::Thread* t) { | 265 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
266 internal::SynchronousMethodCall(this).Invoke(t); | 266 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
267 return r_.value(); | 267 return r_.value(); |
268 } | 268 } |
269 | 269 |
270 private: | 270 private: |
271 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_); } | 271 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_); } |
272 | 272 |
273 C* c_; | 273 C* c_; |
274 Method m_; | 274 Method m_; |
275 ReturnType<R> r_; | 275 ReturnType<R> r_; |
276 T1 a1_; | 276 T1 a1_; |
277 T2 a2_; | 277 T2 a2_; |
278 T3 a3_; | 278 T3 a3_; |
279 T4 a4_; | 279 T4 a4_; |
280 }; | 280 }; |
281 | 281 |
282 template <typename C, typename R, typename T1, typename T2, typename T3, | 282 template <typename C, typename R, typename T1, typename T2, typename T3, |
283 typename T4, typename T5> | 283 typename T4, typename T5> |
284 class MethodCall5 : public rtc::Message, | 284 class MethodCall5 : public rtc::Message, |
285 public rtc::MessageHandler { | 285 public rtc::MessageHandler { |
286 public: | 286 public: |
287 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); | 287 typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
288 MethodCall5(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) | 288 MethodCall5(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
289 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5) {} | 289 : c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5) {} |
290 | 290 |
291 R Marshal(rtc::Thread* t) { | 291 R Marshal(const rtc::Location& posted_from, rtc::Thread* t) { |
292 internal::SynchronousMethodCall(this).Invoke(t); | 292 internal::SynchronousMethodCall(this).Invoke(posted_from, t); |
293 return r_.value(); | 293 return r_.value(); |
294 } | 294 } |
295 | 295 |
296 private: | 296 private: |
297 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_, a5_); } | 297 void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, a1_, a2_, a3_, a4_, a5_); } |
298 | 298 |
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 class c##Proxy : public c##Interface { \ |
311 protected: \ | 311 protected: \ |
312 typedef c##Interface C; \ | 312 typedef c##Interface C; \ |
313 c##Proxy(rtc::Thread* signaling_thread, C* c) \ | 313 c##Proxy(rtc::Thread* signaling_thread, C* c) \ |
314 : signaling_thread_(signaling_thread), c_(c) {} \ | 314 : signaling_thread_(signaling_thread), c_(c) {} \ |
315 ~c##Proxy() { \ | 315 ~c##Proxy() { \ |
316 MethodCall0<c##Proxy, void> call( \ | 316 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ |
317 this, &c##Proxy::Release_s); \ | 317 call.Marshal(FROM_HERE, signaling_thread_); \ |
318 call.Marshal(signaling_thread_); \ | 318 } \ |
319 } \ | 319 \ |
320 \ | 320 public: \ |
321 public: \ | |
322 static rtc::scoped_refptr<C> Create(rtc::Thread* signaling_thread, C* c) { \ | 321 static rtc::scoped_refptr<C> Create(rtc::Thread* signaling_thread, C* c) { \ |
323 return new rtc::RefCountedObject<c##Proxy>( \ | 322 return new rtc::RefCountedObject<c##Proxy>(signaling_thread, c); \ |
324 signaling_thread, c); \ | |
325 } | 323 } |
326 | 324 |
327 #define BEGIN_PROXY_MAP(c) \ | 325 #define BEGIN_PROXY_MAP(c) \ |
328 class c##Proxy : public c##Interface { \ | 326 class c##Proxy : public c##Interface { \ |
329 protected: \ | 327 protected: \ |
330 typedef c##Interface C; \ | 328 typedef c##Interface C; \ |
331 c##Proxy(rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) \ | 329 c##Proxy(rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) \ |
332 : signaling_thread_(signaling_thread), \ | 330 : signaling_thread_(signaling_thread), \ |
333 worker_thread_(worker_thread), \ | 331 worker_thread_(worker_thread), \ |
334 c_(c) {} \ | 332 c_(c) {} \ |
335 ~c##Proxy() { \ | 333 ~c##Proxy() { \ |
336 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ | 334 MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \ |
337 call.Marshal(signaling_thread_); \ | 335 call.Marshal(FROM_HERE, signaling_thread_); \ |
338 } \ | 336 } \ |
339 \ | 337 \ |
340 public: \ | 338 public: \ |
341 static rtc::scoped_refptr<C> Create( \ | 339 static rtc::scoped_refptr<C> Create(rtc::Thread* signaling_thread, \ |
342 rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) { \ | 340 rtc::Thread* worker_thread, \ |
343 return new rtc::RefCountedObject<c##Proxy>( \ | 341 C* c) { \ |
344 signaling_thread, worker_thread, c); \ | 342 return new rtc::RefCountedObject<c##Proxy>(signaling_thread, \ |
| 343 worker_thread, c); \ |
345 } | 344 } |
346 | 345 |
347 #define PROXY_METHOD0(r, method) \ | 346 #define PROXY_METHOD0(r, method) \ |
348 r method() override { \ | 347 r method() override { \ |
349 MethodCall0<C, r> call(c_.get(), &C::method); \ | 348 MethodCall0<C, r> call(c_.get(), &C::method); \ |
350 return call.Marshal(signaling_thread_); \ | 349 return call.Marshal(FROM_HERE, signaling_thread_); \ |
351 } | 350 } |
352 | 351 |
353 #define PROXY_CONSTMETHOD0(r, method) \ | 352 #define PROXY_CONSTMETHOD0(r, method) \ |
354 r method() const override { \ | 353 r method() const override { \ |
355 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ | 354 ConstMethodCall0<C, r> call(c_.get(), &C::method); \ |
356 return call.Marshal(signaling_thread_); \ | 355 return call.Marshal(FROM_HERE, signaling_thread_); \ |
357 } | 356 } |
358 | 357 |
359 #define PROXY_METHOD1(r, method, t1) \ | 358 #define PROXY_METHOD1(r, method, t1) \ |
360 r method(t1 a1) override { \ | 359 r method(t1 a1) override { \ |
361 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 360 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
362 return call.Marshal(signaling_thread_); \ | 361 return call.Marshal(FROM_HERE, signaling_thread_); \ |
363 } | 362 } |
364 | 363 |
365 #define PROXY_CONSTMETHOD1(r, method, t1) \ | 364 #define PROXY_CONSTMETHOD1(r, method, t1) \ |
366 r method(t1 a1) const override { \ | 365 r method(t1 a1) const override { \ |
367 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 366 ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
368 return call.Marshal(signaling_thread_); \ | 367 return call.Marshal(FROM_HERE, signaling_thread_); \ |
369 } | 368 } |
370 | 369 |
371 #define PROXY_METHOD2(r, method, t1, t2) \ | 370 #define PROXY_METHOD2(r, method, t1, t2) \ |
372 r method(t1 a1, t2 a2) override { \ | 371 r method(t1 a1, t2 a2) override { \ |
373 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 372 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
374 return call.Marshal(signaling_thread_); \ | 373 return call.Marshal(FROM_HERE, signaling_thread_); \ |
375 } | 374 } |
376 | 375 |
377 #define PROXY_METHOD3(r, method, t1, t2, t3) \ | 376 #define PROXY_METHOD3(r, method, t1, t2, t3) \ |
378 r method(t1 a1, t2 a2, t3 a3) override { \ | 377 r method(t1 a1, t2 a2, t3 a3) override { \ |
379 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ | 378 MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \ |
380 return call.Marshal(signaling_thread_); \ | 379 return call.Marshal(FROM_HERE, signaling_thread_); \ |
381 } | 380 } |
382 | 381 |
383 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ | 382 #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \ |
384 r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \ | 383 r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \ |
385 MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \ | 384 MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \ |
386 a4); \ | 385 a4); \ |
387 return call.Marshal(signaling_thread_); \ | 386 return call.Marshal(FROM_HERE, signaling_thread_); \ |
388 } | 387 } |
389 | 388 |
390 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ | 389 #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \ |
391 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ | 390 r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \ |
392 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ | 391 MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \ |
393 a3, a4, a5); \ | 392 a3, a4, a5); \ |
394 return call.Marshal(signaling_thread_); \ | 393 return call.Marshal(FROM_HERE, signaling_thread_); \ |
395 } | 394 } |
396 | 395 |
397 // Define methods which should be invoked on the worker thread. | 396 // Define methods which should be invoked on the worker thread. |
398 #define PROXY_WORKER_METHOD1(r, method, t1) \ | 397 #define PROXY_WORKER_METHOD1(r, method, t1) \ |
399 r method(t1 a1) override { \ | 398 r method(t1 a1) override { \ |
400 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ | 399 MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \ |
401 return call.Marshal(worker_thread_); \ | 400 return call.Marshal(FROM_HERE, worker_thread_); \ |
402 } | 401 } |
403 | 402 |
404 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ | 403 #define PROXY_WORKER_METHOD2(r, method, t1, t2) \ |
405 r method(t1 a1, t2 a2) override { \ | 404 r method(t1 a1, t2 a2) override { \ |
406 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ | 405 MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \ |
407 return call.Marshal(worker_thread_); \ | 406 return call.Marshal(FROM_HERE, worker_thread_); \ |
408 } | 407 } |
409 | 408 |
410 #define END_SIGNALING_PROXY() \ | 409 #define END_SIGNALING_PROXY() \ |
411 private:\ | 410 private:\ |
412 void Release_s() {\ | 411 void Release_s() {\ |
413 c_ = NULL;\ | 412 c_ = NULL;\ |
414 }\ | 413 }\ |
415 mutable rtc::Thread* signaling_thread_;\ | 414 mutable rtc::Thread* signaling_thread_;\ |
416 rtc::scoped_refptr<C> c_;\ | 415 rtc::scoped_refptr<C> c_;\ |
417 }; | 416 }; |
418 | 417 |
419 #define END_PROXY() \ | 418 #define END_PROXY() \ |
420 private: \ | 419 private: \ |
421 void Release_s() { \ | 420 void Release_s() { \ |
422 c_ = NULL; \ | 421 c_ = NULL; \ |
423 } \ | 422 } \ |
424 mutable rtc::Thread* signaling_thread_; \ | 423 mutable rtc::Thread* signaling_thread_; \ |
425 mutable rtc::Thread* worker_thread_; \ | 424 mutable rtc::Thread* worker_thread_; \ |
426 rtc::scoped_refptr<C> c_; \ | 425 rtc::scoped_refptr<C> c_; \ |
427 }; \ | 426 }; \ |
428 | 427 |
429 } // namespace webrtc | 428 } // namespace webrtc |
430 | 429 |
431 #endif // WEBRTC_API_PROXY_H_ | 430 #endif // WEBRTC_API_PROXY_H_ |
OLD | NEW |