Steve Anton | f2737d2 | 2017-10-31 16:27:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "api/proxy.h" |
| 12 | |
| 13 | namespace webrtc { |
| 14 | namespace internal { |
| 15 | |
| 16 | SynchronousMethodCall::SynchronousMethodCall(rtc::MessageHandler* proxy) |
Niels Möller | 58376f3 | 2018-11-15 09:31:38 +0100 | [diff] [blame] | 17 | : proxy_(proxy) {} |
Steve Anton | f2737d2 | 2017-10-31 16:27:34 -0700 | [diff] [blame] | 18 | |
| 19 | SynchronousMethodCall::~SynchronousMethodCall() = default; |
| 20 | |
| 21 | void SynchronousMethodCall::Invoke(const rtc::Location& posted_from, |
| 22 | rtc::Thread* t) { |
| 23 | if (t->IsCurrent()) { |
| 24 | proxy_->OnMessage(nullptr); |
| 25 | } else { |
Steve Anton | f2737d2 | 2017-10-31 16:27:34 -0700 | [diff] [blame] | 26 | t->Post(posted_from, this, 0); |
Niels Möller | 58376f3 | 2018-11-15 09:31:38 +0100 | [diff] [blame] | 27 | e_.Wait(rtc::Event::kForever); |
Steve Anton | f2737d2 | 2017-10-31 16:27:34 -0700 | [diff] [blame] | 28 | } |
| 29 | } |
| 30 | |
| 31 | void SynchronousMethodCall::OnMessage(rtc::Message*) { |
| 32 | proxy_->OnMessage(nullptr); |
Niels Möller | 58376f3 | 2018-11-15 09:31:38 +0100 | [diff] [blame] | 33 | e_.Set(); |
Steve Anton | f2737d2 | 2017-10-31 16:27:34 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | } // namespace internal |
| 37 | } // namespace webrtc |