Adding more detail to MessageQueue::Dispatch logging.
Every message will now be traced with the location from which it was
posted, including function name, file and line number.
This CL also writes a normal LOG message when the dispatch took more
than a certain amount of time (currently 50ms).
This logging should help us identify messages that are taking
longer than expected to be dispatched.
R=pthatcher@webrtc.org, tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2019423006 .
Cr-Commit-Position: refs/heads/master@{#13104}
diff --git a/webrtc/api/datachannel.cc b/webrtc/api/datachannel.cc
index 452e4b3..5a18e6f 100644
--- a/webrtc/api/datachannel.cc
+++ b/webrtc/api/datachannel.cc
@@ -187,7 +187,7 @@
// Chrome glue and WebKit) are not wired up properly until after this
// function returns.
if (provider_->ReadyToSendData()) {
- rtc::Thread::Current()->Post(this, MSG_CHANNELREADY, NULL);
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_CHANNELREADY, NULL);
}
}
diff --git a/webrtc/api/dtmfsender.cc b/webrtc/api/dtmfsender.cc
index 78a73c4..bd4340e 100644
--- a/webrtc/api/dtmfsender.cc
+++ b/webrtc/api/dtmfsender.cc
@@ -137,7 +137,7 @@
// Clear the previous queue.
signaling_thread_->Clear(this, MSG_DO_INSERT_DTMF);
// Kick off a new DTMF task queue.
- signaling_thread_->Post(this, MSG_DO_INSERT_DTMF);
+ signaling_thread_->Post(RTC_FROM_HERE, this, MSG_DO_INSERT_DTMF);
return true;
}
@@ -222,7 +222,8 @@
tones_.erase(0, first_tone_pos + 1);
// Continue with the next tone.
- signaling_thread_->PostDelayed(tone_gap, this, MSG_DO_INSERT_DTMF);
+ signaling_thread_->PostDelayed(RTC_FROM_HERE, tone_gap, this,
+ MSG_DO_INSERT_DTMF);
}
void DtmfSender::OnProviderDestroyed() {
diff --git a/webrtc/api/java/jni/androidmediadecoder_jni.cc b/webrtc/api/java/jni/androidmediadecoder_jni.cc
index 831b68d..3793756 100644
--- a/webrtc/api/java/jni/androidmediadecoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediadecoder_jni.cc
@@ -307,6 +307,7 @@
// Call Java init.
return codec_thread_->Invoke<int32_t>(
+ RTC_FROM_HERE,
Bind(&MediaCodecVideoDecoder::InitDecodeOnCodecThread, this));
}
@@ -399,7 +400,7 @@
}
}
- codec_thread_->PostDelayed(kMediaCodecPollMs, this);
+ codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
return WEBRTC_VIDEO_CODEC_OK;
}
@@ -430,7 +431,7 @@
}
inited_ = true;
- codec_thread_->PostDelayed(kMediaCodecPollMs, this);
+ codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
return WEBRTC_VIDEO_CODEC_OK;
}
@@ -438,7 +439,7 @@
int32_t MediaCodecVideoDecoder::Release() {
ALOGD << "DecoderRelease request";
return codec_thread_->Invoke<int32_t>(
- Bind(&MediaCodecVideoDecoder::ReleaseOnCodecThread, this));
+ RTC_FROM_HERE, Bind(&MediaCodecVideoDecoder::ReleaseOnCodecThread, this));
}
int32_t MediaCodecVideoDecoder::ReleaseOnCodecThread() {
@@ -539,8 +540,9 @@
if (use_surface_ &&
(codecType_ == kVideoCodecVP8 || codecType_ == kVideoCodecH264)) {
// Soft codec reset - only for surface decoding.
- ret = codec_thread_->Invoke<int32_t>(Bind(
- &MediaCodecVideoDecoder::ResetDecodeOnCodecThread, this));
+ ret = codec_thread_->Invoke<int32_t>(
+ RTC_FROM_HERE,
+ Bind(&MediaCodecVideoDecoder::ResetDecodeOnCodecThread, this));
} else {
// Hard codec reset.
ret = InitDecode(&codec_, 1);
@@ -568,8 +570,9 @@
return WEBRTC_VIDEO_CODEC_ERROR;
}
- return codec_thread_->Invoke<int32_t>(Bind(
- &MediaCodecVideoDecoder::DecodeOnCodecThread, this, inputImage));
+ return codec_thread_->Invoke<int32_t>(
+ RTC_FROM_HERE,
+ Bind(&MediaCodecVideoDecoder::DecodeOnCodecThread, this, inputImage));
}
int32_t MediaCodecVideoDecoder::DecodeOnCodecThread(
@@ -896,7 +899,7 @@
ProcessHWErrorOnCodecThread();
return;
}
- codec_thread_->PostDelayed(kMediaCodecPollMs, this);
+ codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
}
MediaCodecVideoDecoderFactory::MediaCodecVideoDecoderFactory()
diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc
index 0e36aa1..a240b25 100644
--- a/webrtc/api/java/jni/androidmediaencoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc
@@ -413,35 +413,33 @@
}
return codec_thread_->Invoke<int32_t>(
- Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread,
- this,
- init_width,
- init_height,
- codec_settings->startBitrate,
- codec_settings->maxFramerate,
- false /* use_surface */));
+ RTC_FROM_HERE,
+ Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, this, init_width,
+ init_height, codec_settings->startBitrate,
+ codec_settings->maxFramerate, false /* use_surface */));
}
int32_t MediaCodecVideoEncoder::Encode(
const webrtc::VideoFrame& frame,
const webrtc::CodecSpecificInfo* /* codec_specific_info */,
const std::vector<webrtc::FrameType>* frame_types) {
- return codec_thread_->Invoke<int32_t>(Bind(
- &MediaCodecVideoEncoder::EncodeOnCodecThread, this, frame, frame_types));
+ return codec_thread_->Invoke<int32_t>(
+ RTC_FROM_HERE, Bind(&MediaCodecVideoEncoder::EncodeOnCodecThread, this,
+ frame, frame_types));
}
int32_t MediaCodecVideoEncoder::RegisterEncodeCompleteCallback(
webrtc::EncodedImageCallback* callback) {
return codec_thread_->Invoke<int32_t>(
+ RTC_FROM_HERE,
Bind(&MediaCodecVideoEncoder::RegisterEncodeCompleteCallbackOnCodecThread,
- this,
- callback));
+ this, callback));
}
int32_t MediaCodecVideoEncoder::Release() {
ALOGD << "EncoderRelease request";
return codec_thread_->Invoke<int32_t>(
- Bind(&MediaCodecVideoEncoder::ReleaseOnCodecThread, this));
+ RTC_FROM_HERE, Bind(&MediaCodecVideoEncoder::ReleaseOnCodecThread, this));
}
int32_t MediaCodecVideoEncoder::SetChannelParameters(uint32_t /* packet_loss */,
@@ -452,10 +450,8 @@
int32_t MediaCodecVideoEncoder::SetRates(uint32_t new_bit_rate,
uint32_t frame_rate) {
return codec_thread_->Invoke<int32_t>(
- Bind(&MediaCodecVideoEncoder::SetRatesOnCodecThread,
- this,
- new_bit_rate,
- frame_rate));
+ RTC_FROM_HERE, Bind(&MediaCodecVideoEncoder::SetRatesOnCodecThread, this,
+ new_bit_rate, frame_rate));
}
void MediaCodecVideoEncoder::OnMessage(rtc::Message* msg) {
@@ -478,7 +474,7 @@
// If there aren't more frames to deliver, we can stop the loop
if (!input_frame_infos_.empty()) {
- codec_thread_->PostDelayed(kMediaCodecPollMs, this);
+ codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
} else {
output_delivery_loop_running_ = false;
}
@@ -742,7 +738,7 @@
if (!output_delivery_loop_running_) {
output_delivery_loop_running_ = true;
- codec_thread_->PostDelayed(kMediaCodecPollMs, this);
+ codec_thread_->PostDelayed(RTC_FROM_HERE, kMediaCodecPollMs, this);
}
if (!DeliverPendingOutputs(jni)) {
@@ -1178,6 +1174,7 @@
// directly.
RTC_DCHECK(!codec_thread_checker_.CalledOnValidThread());
codec_thread_->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&MediaCodecVideoEncoder::OnDroppedFrameOnCodecThread, this));
}
diff --git a/webrtc/api/java/jni/androidnetworkmonitor_jni.cc b/webrtc/api/java/jni/androidnetworkmonitor_jni.cc
index b7857e2..a815e27 100644
--- a/webrtc/api/java/jni/androidnetworkmonitor_jni.cc
+++ b/webrtc/api/java/jni/androidnetworkmonitor_jni.cc
@@ -268,8 +268,9 @@
void AndroidNetworkMonitor::OnNetworkConnected(
const NetworkInformation& network_info) {
- worker_thread()->Invoke<void>(rtc::Bind(
- &AndroidNetworkMonitor::OnNetworkConnected_w, this, network_info));
+ worker_thread()->Invoke<void>(
+ RTC_FROM_HERE, rtc::Bind(&AndroidNetworkMonitor::OnNetworkConnected_w,
+ this, network_info));
// Fire SignalNetworksChanged to update the list of networks.
OnNetworksChanged();
}
@@ -288,6 +289,7 @@
void AndroidNetworkMonitor::OnNetworkDisconnected(NetworkHandle handle) {
LOG(LS_INFO) << "Network disconnected for handle " << handle;
worker_thread()->Invoke<void>(
+ RTC_FROM_HERE,
rtc::Bind(&AndroidNetworkMonitor::OnNetworkDisconnected_w, this, handle));
}
diff --git a/webrtc/api/java/jni/androidvideocapturer_jni.cc b/webrtc/api/java/jni/androidvideocapturer_jni.cc
index 58f4d74..82d8c8e 100644
--- a/webrtc/api/java/jni/androidvideocapturer_jni.cc
+++ b/webrtc/api/java/jni/androidvideocapturer_jni.cc
@@ -107,15 +107,17 @@
template <typename... Args>
void AndroidVideoCapturerJni::AsyncCapturerInvoke(
- const char* method_name,
+ const rtc::Location& posted_from,
void (webrtc::AndroidVideoCapturer::*method)(Args...),
typename Identity<Args>::type... args) {
rtc::CritScope cs(&capturer_lock_);
if (!invoker_) {
- LOG(LS_WARNING) << method_name << "() called for closed capturer.";
+ LOG(LS_WARNING) << posted_from.function_name()
+ << "() called for closed capturer.";
return;
}
- invoker_->AsyncInvoke<void>(rtc::Bind(method, capturer_, args...));
+ invoker_->AsyncInvoke<void>(posted_from,
+ rtc::Bind(method, capturer_, args...));
}
std::vector<cricket::VideoFormat>
@@ -162,9 +164,8 @@
void AndroidVideoCapturerJni::OnCapturerStarted(bool success) {
LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success;
- AsyncCapturerInvoke("OnCapturerStarted",
- &webrtc::AndroidVideoCapturer::OnCapturerStarted,
- success);
+ AsyncCapturerInvoke(
+ RTC_FROM_HERE, &webrtc::AndroidVideoCapturer::OnCapturerStarted, success);
}
void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame,
@@ -308,7 +309,7 @@
void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,
int height,
int fps) {
- AsyncCapturerInvoke("OnOutputFormatRequest",
+ AsyncCapturerInvoke(RTC_FROM_HERE,
&webrtc::AndroidVideoCapturer::OnOutputFormatRequest,
width, height, fps);
}
diff --git a/webrtc/api/java/jni/androidvideocapturer_jni.h b/webrtc/api/java/jni/androidvideocapturer_jni.h
index 4a803d9..00c7d91 100644
--- a/webrtc/api/java/jni/androidvideocapturer_jni.h
+++ b/webrtc/api/java/jni/androidvideocapturer_jni.h
@@ -68,7 +68,7 @@
// are not guaranteed to be delivered.
template <typename... Args>
void AsyncCapturerInvoke(
- const char* method_name,
+ const rtc::Location& posted_from,
void (webrtc::AndroidVideoCapturer::*method)(Args...),
typename Identity<Args>::type... args);
diff --git a/webrtc/api/java/jni/peerconnection_jni.cc b/webrtc/api/java/jni/peerconnection_jni.cc
index 0dc9b5e..a5ba254 100644
--- a/webrtc/api/java/jni/peerconnection_jni.cc
+++ b/webrtc/api/java/jni/peerconnection_jni.cc
@@ -1119,9 +1119,12 @@
void OwnedFactoryAndThreads::InvokeJavaCallbacksOnFactoryThreads() {
LOG(LS_INFO) << "InvokeJavaCallbacksOnFactoryThreads.";
- network_thread_->Invoke<void>([this] { JavaCallbackOnFactoryThreads(); });
- worker_thread_->Invoke<void>([this] { JavaCallbackOnFactoryThreads(); });
- signaling_thread_->Invoke<void>([this] { JavaCallbackOnFactoryThreads(); });
+ network_thread_->Invoke<void>(RTC_FROM_HERE,
+ [this] { JavaCallbackOnFactoryThreads(); });
+ worker_thread_->Invoke<void>(RTC_FROM_HERE,
+ [this] { JavaCallbackOnFactoryThreads(); });
+ signaling_thread_->Invoke<void>(RTC_FROM_HERE,
+ [this] { JavaCallbackOnFactoryThreads(); });
}
PeerConnectionFactoryInterface::Options ParseOptionsFromJava(JNIEnv* jni,
diff --git a/webrtc/api/mediacontroller.cc b/webrtc/api/mediacontroller.cc
index 2e4501b..e688e39 100644
--- a/webrtc/api/mediacontroller.cc
+++ b/webrtc/api/mediacontroller.cc
@@ -35,9 +35,9 @@
media_config_(media_config),
channel_manager_(channel_manager) {
RTC_DCHECK(worker_thread);
- worker_thread_->Invoke<void>(
- rtc::Bind(&MediaController::Construct_w, this,
- channel_manager_->media_engine()));
+ worker_thread_->Invoke<void>(RTC_FROM_HERE,
+ rtc::Bind(&MediaController::Construct_w, this,
+ channel_manager_->media_engine()));
}
~MediaController() override {
Close();
@@ -45,7 +45,8 @@
// webrtc::MediaControllerInterface implementation.
void Close() override {
- worker_thread_->Invoke<void>(rtc::Bind(&MediaController::Close_w, this));
+ worker_thread_->Invoke<void>(RTC_FROM_HERE,
+ rtc::Bind(&MediaController::Close_w, this));
}
webrtc::Call* call_w() override {
RTC_DCHECK(worker_thread_->IsCurrent());
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index 6b5cc69b..b9cb83e 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -563,7 +563,8 @@
// which will trigger some final actions in PeerConnection...
session_.reset(nullptr);
// port_allocator_ lives on the network thread and should be destroyed there.
- network_thread()->Invoke<void>([this] { port_allocator_.reset(nullptr); });
+ network_thread()->Invoke<void>(RTC_FROM_HERE,
+ [this] { port_allocator_.reset(nullptr); });
}
bool PeerConnection::Initialize(
@@ -582,8 +583,9 @@
// The port allocator lives on the network thread and should be initialized
// there.
- if (!network_thread()->Invoke<bool>(rtc::Bind(
- &PeerConnection::InitializePortAllocator_n, this, configuration))) {
+ if (!network_thread()->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&PeerConnection::InitializePortAllocator_n,
+ this, configuration))) {
return false;
}
@@ -833,7 +835,7 @@
}
stats_->UpdateStats(level);
- signaling_thread()->Post(this, MSG_GETSTATS,
+ signaling_thread()->Post(RTC_FROM_HERE, this, MSG_GETSTATS,
new GetStatsMsg(observer, track));
return true;
}
@@ -1062,7 +1064,8 @@
}
SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer);
- signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg);
+ signaling_thread()->Post(RTC_FROM_HERE, this,
+ MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg);
// MaybeStartGathering needs to be called after posting
// MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates
@@ -1173,13 +1176,15 @@
UpdateEndedRemoteMediaStreams();
SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer);
- signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg);
+ signaling_thread()->Post(RTC_FROM_HERE, this,
+ MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg);
}
bool PeerConnection::SetConfiguration(const RTCConfiguration& configuration) {
TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration");
if (port_allocator_) {
if (!network_thread()->Invoke<bool>(
+ RTC_FROM_HERE,
rtc::Bind(&PeerConnection::ReconfigurePortAllocator_n, this,
configuration))) {
return false;
@@ -1492,7 +1497,8 @@
const std::string& error) {
SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer);
msg->error = error;
- signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_FAILED, msg);
+ signaling_thread()->Post(RTC_FROM_HERE, this,
+ MSG_SET_SESSIONDESCRIPTION_FAILED, msg);
}
void PeerConnection::PostCreateSessionDescriptionFailure(
@@ -1500,7 +1506,8 @@
const std::string& error) {
CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer);
msg->error = error;
- signaling_thread()->Post(this, MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg);
+ signaling_thread()->Post(RTC_FROM_HERE, this,
+ MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg);
}
bool PeerConnection::GetOptionsForOffer(
@@ -1999,7 +2006,8 @@
// we can't free it directly here; we need to free it asynchronously.
sctp_data_channels_to_free_.push_back(*it);
sctp_data_channels_.erase(it);
- signaling_thread()->Post(this, MSG_FREE_DATACHANNELS, nullptr);
+ signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FREE_DATACHANNELS,
+ nullptr);
return;
}
}
diff --git a/webrtc/api/peerconnectionfactory.cc b/webrtc/api/peerconnectionfactory.cc
index 178c59b..8500422 100644
--- a/webrtc/api/peerconnectionfactory.cc
+++ b/webrtc/api/peerconnectionfactory.cc
@@ -66,7 +66,7 @@
MethodCall0<PeerConnectionFactory, bool> call(
pc_factory.get(),
&PeerConnectionFactory::Initialize);
- bool result = call.Marshal(signaling_thread);
+ bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
if (!result) {
return nullptr;
@@ -146,8 +146,9 @@
// TODO: Need to make sure only one VoE is created inside
// WebRtcMediaEngine.
cricket::MediaEngineInterface* media_engine =
- worker_thread_->Invoke<cricket::MediaEngineInterface*>(rtc::Bind(
- &PeerConnectionFactory::CreateMediaEngine_w, this));
+ worker_thread_->Invoke<cricket::MediaEngineInterface*>(
+ RTC_FROM_HERE,
+ rtc::Bind(&PeerConnectionFactory::CreateMediaEngine_w, this));
channel_manager_.reset(new cricket::ChannelManager(
media_engine, worker_thread_, network_thread_));
@@ -256,8 +257,8 @@
default_network_manager_.get(), default_socket_factory_.get()));
}
network_thread_->Invoke<void>(
- rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask, allocator.get(),
- options_.network_ignore_mask));
+ RTC_FROM_HERE, rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask,
+ allocator.get(), options_.network_ignore_mask));
rtc::scoped_refptr<PeerConnection> pc(
new rtc::RefCountedObject<PeerConnection>(this));
diff --git a/webrtc/api/peerconnectionfactoryproxy.h b/webrtc/api/peerconnectionfactoryproxy.h
index f0dea42..aad97e8 100644
--- a/webrtc/api/peerconnectionfactoryproxy.h
+++ b/webrtc/api/peerconnectionfactoryproxy.h
@@ -33,6 +33,7 @@
PeerConnectionObserver* a5) override {
return signaling_thread_
->Invoke<rtc::scoped_refptr<PeerConnectionInterface>>(
+ RTC_FROM_HERE,
rtc::Bind(&PeerConnectionFactoryProxy::CreatePeerConnection_ot,
this, a1, a2, a3.release(), a4.release(), a5));
}
@@ -43,6 +44,7 @@
PeerConnectionObserver* a5) override {
return signaling_thread_
->Invoke<rtc::scoped_refptr<PeerConnectionInterface>>(
+ RTC_FROM_HERE,
rtc::Bind(&PeerConnectionFactoryProxy::CreatePeerConnection_ot,
this, a1, a3.release(), a4.release(), a5));
}
diff --git a/webrtc/api/proxy.h b/webrtc/api/proxy.h
index 20a5b49..746a758 100644
--- a/webrtc/api/proxy.h
+++ b/webrtc/api/proxy.h
@@ -107,12 +107,12 @@
: e_(), proxy_(proxy) {}
~SynchronousMethodCall() {}
- void Invoke(rtc::Thread* t) {
+ void Invoke(const rtc::Location& posted_from, rtc::Thread* t) {
if (t->IsCurrent()) {
proxy_->OnMessage(NULL);
} else {
e_.reset(new rtc::Event(false, false));
- t->Post(this, 0);
+ t->Post(posted_from, this, 0);
e_->Wait(rtc::Event::kForever);
}
}
@@ -132,8 +132,8 @@
typedef R (C::*Method)();
MethodCall0(C* c, Method m) : c_(c), m_(m) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -152,8 +152,8 @@
typedef R (C::*Method)() const;
ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -172,8 +172,8 @@
typedef R (C::*Method)(T1 a1);
MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -193,8 +193,8 @@
typedef R (C::*Method)(T1 a1) const;
ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(a1) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -214,8 +214,8 @@
typedef R (C::*Method)(T1 a1, T2 a2);
MethodCall2(C* c, Method m, T1 a1, T2 a2) : c_(c), m_(m), a1_(a1), a2_(a2) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -237,8 +237,8 @@
MethodCall3(C* c, Method m, T1 a1, T2 a2, T3 a3)
: c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -262,8 +262,8 @@
MethodCall4(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4)
: c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -288,8 +288,8 @@
MethodCall5(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
: c_(c), m_(m), a1_(a1), a2_(a2), a3_(a3), a4_(a4), a5_(a5) {}
- R Marshal(rtc::Thread* t) {
- internal::SynchronousMethodCall(this).Invoke(t);
+ R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
+ internal::SynchronousMethodCall(this).Invoke(posted_from, t);
return r_.value();
}
@@ -319,7 +319,7 @@
~c##ProxyWithInternal() { \
MethodCall0<c##ProxyWithInternal, void> call( \
this, &c##ProxyWithInternal::Release_s); \
- call.Marshal(signaling_thread_); \
+ call.Marshal(RTC_FROM_HERE, signaling_thread_); \
} \
\
public: \
@@ -349,7 +349,7 @@
~c##ProxyWithInternal() { \
MethodCall0<c##ProxyWithInternal, void> call( \
this, &c##ProxyWithInternal::Release_s); \
- call.Marshal(signaling_thread_); \
+ call.Marshal(RTC_FROM_HERE, signaling_thread_); \
} \
\
public: \
@@ -363,67 +363,67 @@
const INTERNAL_CLASS* internal() const { return c_.get(); } \
INTERNAL_CLASS* internal() { return c_.get(); }
-#define PROXY_METHOD0(r, method) \
- r method() override { \
- MethodCall0<C, r> call(c_.get(), &C::method); \
- return call.Marshal(signaling_thread_); \
+#define PROXY_METHOD0(r, method) \
+ r method() override { \
+ MethodCall0<C, r> call(c_.get(), &C::method); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
-#define PROXY_CONSTMETHOD0(r, method) \
- r method() const override { \
- ConstMethodCall0<C, r> call(c_.get(), &C::method); \
- return call.Marshal(signaling_thread_); \
+#define PROXY_CONSTMETHOD0(r, method) \
+ r method() const override { \
+ ConstMethodCall0<C, r> call(c_.get(), &C::method); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
-#define PROXY_METHOD1(r, method, t1) \
- r method(t1 a1) override { \
- MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \
- return call.Marshal(signaling_thread_); \
+#define PROXY_METHOD1(r, method, t1) \
+ r method(t1 a1) override { \
+ MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
#define PROXY_CONSTMETHOD1(r, method, t1) \
r method(t1 a1) const override { \
ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \
- return call.Marshal(signaling_thread_); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
#define PROXY_METHOD2(r, method, t1, t2) \
r method(t1 a1, t2 a2) override { \
MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \
- return call.Marshal(signaling_thread_); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
#define PROXY_METHOD3(r, method, t1, t2, t3) \
r method(t1 a1, t2 a2, t3 a3) override { \
MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \
- return call.Marshal(signaling_thread_); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
#define PROXY_METHOD4(r, method, t1, t2, t3, t4) \
r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \
MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \
a4); \
- return call.Marshal(signaling_thread_); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
#define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \
r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \
MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \
a3, a4, a5); \
- return call.Marshal(signaling_thread_); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
// Define methods which should be invoked on the worker thread.
#define PROXY_WORKER_METHOD1(r, method, t1) \
r method(t1 a1) override { \
MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \
- return call.Marshal(worker_thread_); \
+ return call.Marshal(RTC_FROM_HERE, worker_thread_); \
}
#define PROXY_WORKER_METHOD2(r, method, t1, t2) \
r method(t1 a1, t2 a2) override { \
MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \
- return call.Marshal(worker_thread_); \
+ return call.Marshal(RTC_FROM_HERE, worker_thread_); \
}
#define END_SIGNALING_PROXY() \
diff --git a/webrtc/api/quicdatachannel.cc b/webrtc/api/quicdatachannel.cc
index 5420da1..f4f5732 100644
--- a/webrtc/api/quicdatachannel.cc
+++ b/webrtc/api/quicdatachannel.cc
@@ -92,7 +92,7 @@
return false;
}
return worker_thread_->Invoke<bool>(
- rtc::Bind(&QuicDataChannel::Send_w, this, buffer));
+ RTC_FROM_HERE, rtc::Bind(&QuicDataChannel::Send_w, this, buffer));
}
bool QuicDataChannel::Send_w(const DataBuffer& buffer) {
@@ -187,8 +187,9 @@
RTC_DCHECK(worker_thread_->IsCurrent());
buffered_amount_ = buffered_amount;
invoker_.AsyncInvoke<void>(
- signaling_thread_, rtc::Bind(&QuicDataChannel::OnBufferedAmountChange_s,
- this, buffered_amount));
+ RTC_FROM_HERE, signaling_thread_,
+ rtc::Bind(&QuicDataChannel::OnBufferedAmountChange_s, this,
+ buffered_amount));
}
void QuicDataChannel::Close() {
@@ -198,7 +199,8 @@
}
LOG(LS_INFO) << "Closing QUIC data channel.";
SetState_s(kClosing);
- worker_thread_->Invoke<void>(rtc::Bind(&QuicDataChannel::Close_w, this));
+ worker_thread_->Invoke<void>(RTC_FROM_HERE,
+ rtc::Bind(&QuicDataChannel::Close_w, this));
SetState_s(kClosed);
}
@@ -236,7 +238,7 @@
quic_transport_channel_ = channel;
LOG(LS_INFO) << "Setting QuicTransportChannel for QUIC data channel " << id_;
DataState data_channel_state = worker_thread_->Invoke<DataState>(
- rtc::Bind(&QuicDataChannel::SetTransportChannel_w, this));
+ RTC_FROM_HERE, rtc::Bind(&QuicDataChannel::SetTransportChannel_w, this));
SetState_s(data_channel_state);
return true;
}
@@ -269,7 +271,7 @@
<< " has finished receiving data for QUIC data channel "
<< id_;
DataBuffer final_message(message.buffer, false);
- invoker_.AsyncInvoke<void>(signaling_thread_,
+ invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_,
rtc::Bind(&QuicDataChannel::OnMessage_s, this,
std::move(final_message)));
message.stream->Close();
@@ -316,7 +318,7 @@
received_data.AppendData(data, len);
DataBuffer final_message(std::move(received_data), false);
invoker_.AsyncInvoke<void>(
- signaling_thread_,
+ RTC_FROM_HERE, signaling_thread_,
rtc::Bind(&QuicDataChannel::OnMessage_s, this, std::move(final_message)));
// Once the stream is closed, OnDataReceived will not fire for the stream.
stream->Close();
@@ -327,7 +329,8 @@
RTC_DCHECK(channel == quic_transport_channel_);
LOG(LS_INFO) << "QuicTransportChannel is ready to send";
invoker_.AsyncInvoke<void>(
- signaling_thread_, rtc::Bind(&QuicDataChannel::SetState_s, this, kOpen));
+ RTC_FROM_HERE, signaling_thread_,
+ rtc::Bind(&QuicDataChannel::SetState_s, this, kOpen));
}
void QuicDataChannel::OnWriteBlockedStreamClosed(net::QuicStreamId stream_id,
@@ -346,7 +349,7 @@
void QuicDataChannel::OnConnectionClosed() {
RTC_DCHECK(worker_thread_->IsCurrent());
- invoker_.AsyncInvoke<void>(signaling_thread_,
+ invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_,
rtc::Bind(&QuicDataChannel::Close, this));
}
diff --git a/webrtc/api/remoteaudiosource.cc b/webrtc/api/remoteaudiosource.cc
index 2d0785a..14eb82b 100644
--- a/webrtc/api/remoteaudiosource.cc
+++ b/webrtc/api/remoteaudiosource.cc
@@ -148,7 +148,7 @@
void RemoteAudioSource::OnAudioProviderGone() {
// Called when the data provider is deleted. It may be the worker thread
// in libjingle or may be a different worker thread.
- main_thread_->Post(new MessageHandler(this));
+ main_thread_->Post(RTC_FROM_HERE, new MessageHandler(this));
}
void RemoteAudioSource::OnMessage(rtc::Message* msg) {
diff --git a/webrtc/api/test/fakeaudiocapturemodule.cc b/webrtc/api/test/fakeaudiocapturemodule.cc
index a32ef64..43ff664 100644
--- a/webrtc/api/test/fakeaudiocapturemodule.cc
+++ b/webrtc/api/test/fakeaudiocapturemodule.cc
@@ -627,7 +627,7 @@
process_thread_.reset(new rtc::Thread());
process_thread_->Start();
}
- process_thread_->Post(this, MSG_START_PROCESS);
+ process_thread_->Post(RTC_FROM_HERE, this, MSG_START_PROCESS);
} else {
if (process_thread_) {
process_thread_->Stop();
@@ -668,7 +668,7 @@
const int64_t current_time = rtc::TimeMillis();
const int64_t wait_time =
(next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0;
- process_thread_->PostDelayed(wait_time, this, MSG_RUN_PROCESS);
+ process_thread_->PostDelayed(RTC_FROM_HERE, wait_time, this, MSG_RUN_PROCESS);
}
void FakeAudioCaptureModule::ReceiveFrameP() {
diff --git a/webrtc/api/test/fakeperiodicvideocapturer.h b/webrtc/api/test/fakeperiodicvideocapturer.h
index ab98855..2c16195 100644
--- a/webrtc/api/test/fakeperiodicvideocapturer.h
+++ b/webrtc/api/test/fakeperiodicvideocapturer.h
@@ -42,7 +42,7 @@
virtual cricket::CaptureState Start(const cricket::VideoFormat& format) {
cricket::CaptureState state = FakeVideoCapturer::Start(format);
if (state != cricket::CS_FAILED) {
- rtc::Thread::Current()->Post(this, MSG_CREATEFRAME);
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_CREATEFRAME);
}
return state;
}
@@ -54,8 +54,9 @@
if (msg->message_id == MSG_CREATEFRAME) {
if (IsRunning()) {
CaptureFrame();
- rtc::Thread::Current()->PostDelayed(static_cast<int>(
- GetCaptureFormat()->interval / rtc::kNumNanosecsPerMillisec),
+ rtc::Thread::Current()->PostDelayed(
+ RTC_FROM_HERE, static_cast<int>(GetCaptureFormat()->interval /
+ rtc::kNumNanosecsPerMillisec),
this, MSG_CREATEFRAME);
}
}
diff --git a/webrtc/api/test/fakertccertificategenerator.h b/webrtc/api/test/fakertccertificategenerator.h
index eaef737..77ff9dc 100644
--- a/webrtc/api/test/fakertccertificategenerator.h
+++ b/webrtc/api/test/fakertccertificategenerator.h
@@ -157,7 +157,7 @@
key_params.ec_curve() == rtc::EC_NIST_P256);
msg_id = MSG_SUCCESS_ECDSA;
}
- rtc::Thread::Current()->Post(this, msg_id, msg);
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this, msg_id, msg);
}
static rtc::scoped_refptr<rtc::RTCCertificate> GenerateCertificate() {
diff --git a/webrtc/api/videocapturertracksource.cc b/webrtc/api/videocapturertracksource.cc
index b99a2d1..2321d83 100644
--- a/webrtc/api/videocapturertracksource.cc
+++ b/webrtc/api/videocapturertracksource.cc
@@ -352,8 +352,8 @@
format_ = GetBestCaptureFormat(formats);
// Start the camera with our best guess.
if (!worker_thread_->Invoke<bool>(
- rtc::Bind(&cricket::VideoCapturer::StartCapturing,
- video_capturer_.get(), format_))) {
+ RTC_FROM_HERE, rtc::Bind(&cricket::VideoCapturer::StartCapturing,
+ video_capturer_.get(), format_))) {
SetState(kEnded);
return;
}
@@ -372,6 +372,7 @@
}
started_ = false;
worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
rtc::Bind(&cricket::VideoCapturer::Stop, video_capturer_.get()));
}
@@ -380,8 +381,8 @@
return;
}
if (!worker_thread_->Invoke<bool>(
- rtc::Bind(&cricket::VideoCapturer::StartCapturing,
- video_capturer_.get(), format_))) {
+ RTC_FROM_HERE, rtc::Bind(&cricket::VideoCapturer::StartCapturing,
+ video_capturer_.get(), format_))) {
SetState(kEnded);
return;
}
@@ -394,8 +395,9 @@
cricket::CaptureState capture_state) {
if (rtc::Thread::Current() != signaling_thread_) {
invoker_.AsyncInvoke<void>(
- signaling_thread_, rtc::Bind(&VideoCapturerTrackSource::OnStateChange,
- this, capturer, capture_state));
+ RTC_FROM_HERE, signaling_thread_,
+ rtc::Bind(&VideoCapturerTrackSource::OnStateChange, this, capturer,
+ capture_state));
return;
}
diff --git a/webrtc/api/webrtcsessiondescriptionfactory.cc b/webrtc/api/webrtcsessiondescriptionfactory.cc
index 08392e5..29da6f2 100644
--- a/webrtc/api/webrtcsessiondescriptionfactory.cc
+++ b/webrtc/api/webrtcsessiondescriptionfactory.cc
@@ -145,7 +145,7 @@
// it in the constructor then the caller has not had a chance to connect to
// |SignalCertificateReady|.
signaling_thread_->Post(
- this, MSG_USE_CONSTRUCTOR_CERTIFICATE,
+ RTC_FROM_HERE, this, MSG_USE_CONSTRUCTOR_CERTIFICATE,
new rtc::ScopedRefMessageData<rtc::RTCCertificate>(certificate));
} else {
// Generate certificate.
@@ -450,7 +450,8 @@
CreateSessionDescriptionObserver* observer, const std::string& error) {
CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer);
msg->error = error;
- signaling_thread_->Post(this, MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg);
+ signaling_thread_->Post(RTC_FROM_HERE, this,
+ MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg);
LOG(LS_ERROR) << "Create SDP failed: " << error;
}
@@ -459,7 +460,8 @@
SessionDescriptionInterface* description) {
CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer);
msg->description.reset(description);
- signaling_thread_->Post(this, MSG_CREATE_SESSIONDESCRIPTION_SUCCESS, msg);
+ signaling_thread_->Post(RTC_FROM_HERE, this,
+ MSG_CREATE_SESSIONDESCRIPTION_SUCCESS, msg);
}
void WebRtcSessionDescriptionFactory::OnCertificateRequestFailed() {
diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn
index 8d3aed6..46c66a1 100644
--- a/webrtc/base/BUILD.gn
+++ b/webrtc/base/BUILD.gn
@@ -118,6 +118,8 @@
"event_tracer.h",
"exp_filter.cc",
"exp_filter.h",
+ "location.cc",
+ "location.h",
"md5.cc",
"md5.h",
"md5digest.cc",
diff --git a/webrtc/base/asyncinvoker-inl.h b/webrtc/base/asyncinvoker-inl.h
index f615f83..15fafa8 100644
--- a/webrtc/base/asyncinvoker-inl.h
+++ b/webrtc/base/asyncinvoker-inl.h
@@ -58,7 +58,9 @@
~NotifyingAsyncClosureBase() override;
protected:
- NotifyingAsyncClosureBase(AsyncInvoker* invoker, Thread* calling_thread);
+ NotifyingAsyncClosureBase(AsyncInvoker* invoker,
+ const Location& callback_posted_from,
+ Thread* calling_thread);
void TriggerCallback();
void SetCallback(const Callback0<void>& callback) {
CritScope cs(&crit_);
@@ -67,9 +69,10 @@
bool CallbackCanceled() const { return calling_thread_ == NULL; }
private:
+ AsyncInvoker* invoker_;
+ Location callback_posted_from_;
Callback0<void> callback_;
CriticalSection crit_;
- AsyncInvoker* invoker_;
Thread* calling_thread_;
void CancelCallback();
@@ -80,14 +83,17 @@
class NotifyingAsyncClosure : public NotifyingAsyncClosureBase {
public:
NotifyingAsyncClosure(AsyncInvoker* invoker,
+ const Location& callback_posted_from,
Thread* calling_thread,
const FunctorT& functor,
void (HostT::*callback)(ReturnT),
HostT* callback_host)
- : NotifyingAsyncClosureBase(invoker, calling_thread),
- functor_(functor),
- callback_(callback),
- callback_host_(callback_host) {}
+ : NotifyingAsyncClosureBase(invoker,
+ callback_posted_from,
+ calling_thread),
+ functor_(functor),
+ callback_(callback),
+ callback_host_(callback_host) {}
virtual void Execute() {
ReturnT result = functor_();
if (!CallbackCanceled()) {
@@ -108,11 +114,14 @@
: public NotifyingAsyncClosureBase {
public:
NotifyingAsyncClosure(AsyncInvoker* invoker,
+ const Location& callback_posted_from,
Thread* calling_thread,
const FunctorT& functor,
void (HostT::*callback)(),
HostT* callback_host)
- : NotifyingAsyncClosureBase(invoker, calling_thread),
+ : NotifyingAsyncClosureBase(invoker,
+ callback_posted_from,
+ calling_thread),
functor_(functor) {
SetCallback(Callback0<void>(Bind(callback, callback_host)));
}
diff --git a/webrtc/base/asyncinvoker.cc b/webrtc/base/asyncinvoker.cc
index 8285d55..83a8738 100644
--- a/webrtc/base/asyncinvoker.cc
+++ b/webrtc/base/asyncinvoker.cc
@@ -41,7 +41,8 @@
// Run this on |thread| to reduce the number of context switches.
if (Thread::Current() != thread) {
- thread->Invoke<void>(Bind(&AsyncInvoker::Flush, this, thread, id));
+ thread->Invoke<void>(RTC_FROM_HERE,
+ Bind(&AsyncInvoker::Flush, this, thread, id));
return;
}
@@ -49,23 +50,24 @@
thread->Clear(this, id, &removed);
for (MessageList::iterator it = removed.begin(); it != removed.end(); ++it) {
// This message was pending on this thread, so run it now.
- thread->Send(it->phandler,
- it->message_id,
- it->pdata);
+ thread->Send(it->posted_from, it->phandler, it->message_id, it->pdata);
}
}
-void AsyncInvoker::DoInvoke(Thread* thread,
+void AsyncInvoker::DoInvoke(const Location& posted_from,
+ Thread* thread,
const scoped_refptr<AsyncClosure>& closure,
uint32_t id) {
if (destroying_) {
LOG(LS_WARNING) << "Tried to invoke while destroying the invoker.";
return;
}
- thread->Post(this, id, new ScopedRefMessageData<AsyncClosure>(closure));
+ thread->Post(posted_from, this, id,
+ new ScopedRefMessageData<AsyncClosure>(closure));
}
-void AsyncInvoker::DoInvokeDelayed(Thread* thread,
+void AsyncInvoker::DoInvokeDelayed(const Location& posted_from,
+ Thread* thread,
const scoped_refptr<AsyncClosure>& closure,
uint32_t delay_ms,
uint32_t id) {
@@ -73,7 +75,7 @@
LOG(LS_WARNING) << "Tried to invoke while destroying the invoker.";
return;
}
- thread->PostDelayed(delay_ms, this, id,
+ thread->PostDelayed(posted_from, delay_ms, this, id,
new ScopedRefMessageData<AsyncClosure>(closure));
}
@@ -100,9 +102,13 @@
thread_ = nullptr;
}
-NotifyingAsyncClosureBase::NotifyingAsyncClosureBase(AsyncInvoker* invoker,
- Thread* calling_thread)
- : invoker_(invoker), calling_thread_(calling_thread) {
+NotifyingAsyncClosureBase::NotifyingAsyncClosureBase(
+ AsyncInvoker* invoker,
+ const Location& callback_posted_from,
+ Thread* calling_thread)
+ : invoker_(invoker),
+ callback_posted_from_(callback_posted_from),
+ calling_thread_(calling_thread) {
calling_thread->SignalQueueDestroyed.connect(
this, &NotifyingAsyncClosureBase::CancelCallback);
invoker->SignalInvokerDestroyed.connect(
@@ -116,7 +122,8 @@
void NotifyingAsyncClosureBase::TriggerCallback() {
CritScope cs(&crit_);
if (!CallbackCanceled() && !callback_.empty()) {
- invoker_->AsyncInvoke<void>(calling_thread_, callback_);
+ invoker_->AsyncInvoke<void>(callback_posted_from_, calling_thread_,
+ callback_);
}
}
diff --git a/webrtc/base/asyncinvoker.h b/webrtc/base/asyncinvoker.h
index 76e5d92..d91e306 100644
--- a/webrtc/base/asyncinvoker.h
+++ b/webrtc/base/asyncinvoker.h
@@ -45,13 +45,13 @@
// public:
// void FireAsyncTaskWithResult(Thread* thread, int x) {
// // Specify a callback to get the result upon completion.
-// invoker_.AsyncInvoke<int>(
+// invoker_.AsyncInvoke<int>(RTC_FROM_HERE,
// thread, Bind(&MyClass::AsyncTaskWithResult, this, x),
// &MyClass::OnTaskComplete, this);
// }
// void FireAnotherAsyncTask(Thread* thread) {
// // No callback specified means fire-and-forget.
-// invoker_.AsyncInvoke<void>(
+// invoker_.AsyncInvoke<void>(RTC_FROM_HERE,
// thread, Bind(&MyClass::AnotherAsyncTask, this));
//
// private:
@@ -75,49 +75,63 @@
// Call |functor| asynchronously on |thread|, with no callback upon
// completion. Returns immediately.
template <class ReturnT, class FunctorT>
- void AsyncInvoke(Thread* thread, const FunctorT& functor, uint32_t id = 0) {
+ void AsyncInvoke(const Location& posted_from,
+ Thread* thread,
+ const FunctorT& functor,
+ uint32_t id = 0) {
scoped_refptr<AsyncClosure> closure(
new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(functor));
- DoInvoke(thread, closure, id);
+ DoInvoke(posted_from, thread, closure, id);
}
// Call |functor| asynchronously on |thread| with |delay_ms|, with no callback
// upon completion. Returns immediately.
template <class ReturnT, class FunctorT>
- void AsyncInvokeDelayed(Thread* thread,
+ void AsyncInvokeDelayed(const Location& posted_from,
+ Thread* thread,
const FunctorT& functor,
uint32_t delay_ms,
uint32_t id = 0) {
scoped_refptr<AsyncClosure> closure(
new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(functor));
- DoInvokeDelayed(thread, closure, delay_ms, id);
+ DoInvokeDelayed(posted_from, thread, closure, delay_ms, id);
}
// Call |functor| asynchronously on |thread|, calling |callback| when done.
+ // Uses a separate Location for |callback_posted_from| so that the functor
+ // invoke and the callback invoke can be differentiated.
template <class ReturnT, class FunctorT, class HostT>
- void AsyncInvoke(Thread* thread,
+ void AsyncInvoke(const Location& posted_from,
+ const Location& callback_posted_from,
+ Thread* thread,
const FunctorT& functor,
void (HostT::*callback)(ReturnT),
HostT* callback_host,
uint32_t id = 0) {
scoped_refptr<AsyncClosure> closure(
new RefCountedObject<NotifyingAsyncClosure<ReturnT, FunctorT, HostT> >(
- this, Thread::Current(), functor, callback, callback_host));
- DoInvoke(thread, closure, id);
+ this, callback_posted_from, Thread::Current(), functor, callback,
+ callback_host));
+ DoInvoke(posted_from, thread, closure, id);
}
// Call |functor| asynchronously on |thread|, calling |callback| when done.
+ // Uses a separate Location for |callback_posted_from| so that the functor
+ // invoke and the callback invoke can be differentiated.
// Overloaded for void return.
template <class ReturnT, class FunctorT, class HostT>
- void AsyncInvoke(Thread* thread,
+ void AsyncInvoke(const Location& posted_from,
+ const Location& callback_posted_from,
+ Thread* thread,
const FunctorT& functor,
void (HostT::*callback)(),
HostT* callback_host,
uint32_t id = 0) {
scoped_refptr<AsyncClosure> closure(
new RefCountedObject<NotifyingAsyncClosure<void, FunctorT, HostT> >(
- this, Thread::Current(), functor, callback, callback_host));
- DoInvoke(thread, closure, id);
+ this, callback_posted_from, Thread::Current(), functor, callback,
+ callback_host));
+ DoInvoke(posted_from, thread, closure, id);
}
// Synchronously execute on |thread| all outstanding calls we own
@@ -132,10 +146,12 @@
private:
void OnMessage(Message* msg) override;
- void DoInvoke(Thread* thread,
+ void DoInvoke(const Location& posted_from,
+ Thread* thread,
const scoped_refptr<AsyncClosure>& closure,
uint32_t id);
- void DoInvokeDelayed(Thread* thread,
+ void DoInvokeDelayed(const Location& posted_from,
+ Thread* thread,
const scoped_refptr<AsyncClosure>& closure,
uint32_t delay_ms,
uint32_t id);
@@ -164,55 +180,64 @@
// Call |functor| asynchronously with no callback upon completion. Returns
// immediately. Returns false if the thread has died.
template <class ReturnT, class FunctorT>
- bool AsyncInvoke(const FunctorT& functor, uint32_t id = 0) {
+ bool AsyncInvoke(const Location& posted_from,
+ const FunctorT& functor,
+ uint32_t id = 0) {
rtc::CritScope cs(&crit_);
if (thread_ == nullptr)
return false;
- invoker_.AsyncInvoke<ReturnT, FunctorT>(thread_, functor, id);
+ invoker_.AsyncInvoke<ReturnT, FunctorT>(posted_from, thread_, functor, id);
return true;
}
// Call |functor| asynchronously with |delay_ms|, with no callback upon
// completion. Returns immediately. Returns false if the thread has died.
template <class ReturnT, class FunctorT>
- bool AsyncInvokeDelayed(const FunctorT& functor,
+ bool AsyncInvokeDelayed(const Location& posted_from,
+ const FunctorT& functor,
uint32_t delay_ms,
uint32_t id = 0) {
rtc::CritScope cs(&crit_);
if (thread_ == nullptr)
return false;
- invoker_.AsyncInvokeDelayed<ReturnT, FunctorT>(thread_, functor, delay_ms,
- id);
+ invoker_.AsyncInvokeDelayed<ReturnT, FunctorT>(posted_from, thread_,
+ functor, delay_ms, id);
return true;
}
// Call |functor| asynchronously, calling |callback| when done. Returns false
// if the thread has died.
template <class ReturnT, class FunctorT, class HostT>
- bool AsyncInvoke(const FunctorT& functor,
+ bool AsyncInvoke(const Location& posted_from,
+ const Location& callback_posted_from,
+ const FunctorT& functor,
void (HostT::*callback)(ReturnT),
HostT* callback_host,
uint32_t id = 0) {
rtc::CritScope cs(&crit_);
if (thread_ == nullptr)
return false;
- invoker_.AsyncInvoke<ReturnT, FunctorT, HostT>(thread_, functor, callback,
- callback_host, id);
+ invoker_.AsyncInvoke<ReturnT, FunctorT, HostT>(
+ posted_from, callback_posted_from, thread_, functor, callback,
+ callback_host, id);
return true;
}
// Call |functor| asynchronously calling |callback| when done. Overloaded for
// void return. Returns false if the thread has died.
template <class ReturnT, class FunctorT, class HostT>
- bool AsyncInvoke(const FunctorT& functor,
+ bool AsyncInvoke(const Location& posted_from,
+ const Location& callback_posted_from,
+ const FunctorT& functor,
void (HostT::*callback)(),
HostT* callback_host,
uint32_t id = 0) {
rtc::CritScope cs(&crit_);
if (thread_ == nullptr)
return false;
- invoker_.AsyncInvoke<ReturnT, FunctorT, HostT>(thread_, functor, callback,
- callback_host, id);
+ invoker_.AsyncInvoke<ReturnT, FunctorT, HostT>(
+ posted_from, callback_posted_from, thread_, functor, callback,
+ callback_host, id);
return true;
}
diff --git a/webrtc/base/autodetectproxy.cc b/webrtc/base/autodetectproxy.cc
index e6174ec..e563304 100644
--- a/webrtc/base/autodetectproxy.cc
+++ b/webrtc/base/autodetectproxy.cc
@@ -138,14 +138,14 @@
<< resolver_->address();
proxy_.address = resolver_->address();
if (!DoConnect()) {
- Thread::Current()->Post(this, MSG_TIMEOUT);
+ Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TIMEOUT);
}
} else {
LOG(LS_INFO) << "Failed to resolve " << resolver_->address();
resolver_->Destroy(false);
resolver_ = NULL;
proxy_.address = SocketAddress();
- Thread::Current()->Post(this, MSG_UNRESOLVABLE);
+ Thread::Current()->Post(RTC_FROM_HERE, this, MSG_UNRESOLVABLE);
}
}
@@ -176,11 +176,11 @@
resolver_->Start(proxy_.address);
} else {
if (!DoConnect()) {
- Thread::Current()->Post(this, MSG_TIMEOUT);
+ Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TIMEOUT);
return;
}
}
- Thread::Current()->PostDelayed(timeout, this, MSG_TIMEOUT);
+ Thread::Current()->PostDelayed(RTC_FROM_HERE, timeout, this, MSG_TIMEOUT);
}
bool AutoDetectProxy::DoConnect() {
diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp
index 7026599..66035df 100644
--- a/webrtc/base/base.gyp
+++ b/webrtc/base/base.gyp
@@ -54,6 +54,8 @@
'event_tracer.h',
'exp_filter.cc',
'exp_filter.h',
+ 'location.h',
+ 'location.cc',
'md5.cc',
'md5.h',
'md5digest.cc',
diff --git a/webrtc/base/bind.h b/webrtc/base/bind.h
index b50afc2..e8c1ab5 100644
--- a/webrtc/base/bind.h
+++ b/webrtc/base/bind.h
@@ -48,7 +48,7 @@
// void Test() {}
// void BindThis() {
// // The functor passed to AsyncInvoke() will keep this object alive.
-// invoker.AsyncInvoke(rtc::Bind(&Bar::Test, this));
+// invoker.AsyncInvoke(RTC_FROM_HERE,rtc::Bind(&Bar::Test, this));
// }
// };
//
diff --git a/webrtc/base/bind.h.pump b/webrtc/base/bind.h.pump
index 6fb8490..2a1a55c 100644
--- a/webrtc/base/bind.h.pump
+++ b/webrtc/base/bind.h.pump
@@ -44,7 +44,7 @@
// void Test() {}
// void BindThis() {
// // The functor passed to AsyncInvoke() will keep this object alive.
-// invoker.AsyncInvoke(rtc::Bind(&Bar::Test, this));
+// invoker.AsyncInvoke(RTC_FROM_HERE,rtc::Bind(&Bar::Test, this));
// }
// };
//
diff --git a/webrtc/base/criticalsection_unittest.cc b/webrtc/base/criticalsection_unittest.cc
index d33afac..fb38737 100644
--- a/webrtc/base/criticalsection_unittest.cc
+++ b/webrtc/base/criticalsection_unittest.cc
@@ -204,7 +204,7 @@
for (int i = 0; i < kNumThreads; ++i) {
Thread* thread = new Thread();
thread->Start();
- thread->Post(handler);
+ thread->Post(RTC_FROM_HERE, handler);
threads->PushBack(thread);
}
}
diff --git a/webrtc/base/dbus.cc b/webrtc/base/dbus.cc
index 312bad0..d4fb536 100644
--- a/webrtc/base/dbus.cc
+++ b/webrtc/base/dbus.cc
@@ -101,7 +101,8 @@
// Posts a message to caller thread.
DBusHandlerResult DBusSigFilter::Callback(DBusMessage *message) {
if (caller_thread_) {
- caller_thread_->Post(this, DSM_SIGNAL, new DBusSigMessageData(message));
+ caller_thread_->Post(RTC_FROM_HERE, this, DSM_SIGNAL,
+ new DBusSigMessageData(message));
}
// Don't "eat" the message here. Let it pop up.
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
diff --git a/webrtc/base/fakenetwork.h b/webrtc/base/fakenetwork.h
index 2dd2137..1912dd0 100644
--- a/webrtc/base/fakenetwork.h
+++ b/webrtc/base/fakenetwork.h
@@ -68,7 +68,7 @@
++start_count_;
if (start_count_ == 1) {
sent_first_update_ = false;
- thread_->Post(this);
+ thread_->Post(RTC_FROM_HERE, this);
} else {
if (sent_first_update_) {
SignalNetworksChanged();
diff --git a/webrtc/base/location.cc b/webrtc/base/location.cc
new file mode 100644
index 0000000..c3dfe77
--- /dev/null
+++ b/webrtc/base/location.cc
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/base/location.h"
+
+#include "webrtc/base/stringutils.h"
+
+namespace rtc {
+
+Location::Location(const char* function_name, const char* file_and_line)
+ : function_name_(function_name), file_and_line_(file_and_line) {}
+
+Location::Location() : function_name_("Unknown"), file_and_line_("Unknown") {}
+
+Location::Location(const Location& other)
+ : function_name_(other.function_name_),
+ file_and_line_(other.file_and_line_) {}
+
+Location& Location::operator=(const Location& other) {
+ function_name_ = other.function_name_;
+ file_and_line_ = other.file_and_line_;
+ return *this;
+}
+
+std::string Location::ToString() const {
+ char buf[256];
+ sprintfn(buf, sizeof(buf), "%s@%s", function_name_, file_and_line_);
+ return buf;
+}
+
+} // namespace rtc
diff --git a/webrtc/base/location.h b/webrtc/base/location.h
new file mode 100644
index 0000000..a541bbe
--- /dev/null
+++ b/webrtc/base/location.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_BASE_LOCATION_H_
+#define WEBRTC_BASE_LOCATION_H_
+
+#include <string>
+
+#include "webrtc/system_wrappers/include/stringize_macros.h"
+
+namespace rtc {
+
+// Location provides basic info where of an object was constructed, or was
+// significantly brought to life.
+// This is a stripped down version of:
+// https://code.google.com/p/chromium/codesearch#chromium/src/base/location.h
+class Location {
+ public:
+ // Constructor should be called with a long-lived char*, such as __FILE__.
+ // It assumes the provided value will persist as a global constant, and it
+ // will not make a copy of it.
+ //
+ // TODO(deadbeef): Tracing is currently limited to 2 arguments, which is
+ // why the file name and line number are combined into one argument.
+ //
+ // Once TracingV2 is available, separate the file name and line number.
+ Location(const char* function_name, const char* file_and_line);
+ Location();
+ Location(const Location& other);
+ Location& operator=(const Location& other);
+
+ const char* function_name() const { return function_name_; }
+ const char* file_and_line() const { return file_and_line_; }
+
+ std::string ToString() const;
+
+ private:
+ const char* function_name_;
+ const char* file_and_line_;
+};
+
+// Define a macro to record the current source location.
+#define RTC_FROM_HERE RTC_FROM_HERE_WITH_FUNCTION(__FUNCTION__)
+
+#define RTC_FROM_HERE_WITH_FUNCTION(function_name) \
+ ::rtc::Location(function_name, __FILE__ ":" STRINGIZE(__LINE__))
+
+} // namespace rtc
+
+#endif // WEBRTC_BASE_LOCATION_H_
diff --git a/webrtc/base/messagequeue.cc b/webrtc/base/messagequeue.cc
index 4c2331b..c407870 100644
--- a/webrtc/base/messagequeue.cc
+++ b/webrtc/base/messagequeue.cc
@@ -14,12 +14,14 @@
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/messagequeue.h"
+#include "webrtc/base/stringencode.h"
#include "webrtc/base/thread.h"
#include "webrtc/base/trace_event.h"
namespace rtc {
const int kMaxMsgLatency = 150; // 150 ms
+const int kSlowDispatchLoggingThreshold = 50; // 50 ms
//------------------------------------------------------------------
// MessageQueueManager
@@ -125,7 +127,7 @@
CritScope cs(&crit_);
queues_not_done = static_cast<int>(message_queues_.size());
for (MessageQueue* queue : message_queues_) {
- queue->PostDelayed(0, &handler);
+ queue->PostDelayed(RTC_FROM_HERE, 0, &handler);
}
}
// Note: One of the message queues may have been on this thread, which is why
@@ -341,7 +343,8 @@
void MessageQueue::ReceiveSends() {
}
-void MessageQueue::Post(MessageHandler* phandler,
+void MessageQueue::Post(const Location& posted_from,
+ MessageHandler* phandler,
uint32_t id,
MessageData* pdata,
bool time_sensitive) {
@@ -355,6 +358,7 @@
{
CritScope cs(&crit_);
Message msg;
+ msg.posted_from = posted_from;
msg.phandler = phandler;
msg.message_id = id;
msg.pdata = pdata;
@@ -366,30 +370,36 @@
WakeUpSocketServer();
}
-void MessageQueue::PostDelayed(int cmsDelay,
+void MessageQueue::PostDelayed(const Location& posted_from,
+ int cmsDelay,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata) {
- return DoDelayPost(cmsDelay, TimeAfter(cmsDelay), phandler, id, pdata);
+ return DoDelayPost(posted_from, cmsDelay, TimeAfter(cmsDelay), phandler, id,
+ pdata);
}
-void MessageQueue::PostAt(uint32_t tstamp,
+void MessageQueue::PostAt(const Location& posted_from,
+ uint32_t tstamp,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata) {
// This should work even if it is used (unexpectedly).
int64_t delay = static_cast<uint32_t>(TimeMillis()) - tstamp;
- return DoDelayPost(delay, tstamp, phandler, id, pdata);
+ return DoDelayPost(posted_from, delay, tstamp, phandler, id, pdata);
}
-void MessageQueue::PostAt(int64_t tstamp,
+void MessageQueue::PostAt(const Location& posted_from,
+ int64_t tstamp,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata) {
- return DoDelayPost(TimeUntil(tstamp), tstamp, phandler, id, pdata);
+ return DoDelayPost(posted_from, TimeUntil(tstamp), tstamp, phandler, id,
+ pdata);
}
-void MessageQueue::DoDelayPost(int64_t cmsDelay,
+void MessageQueue::DoDelayPost(const Location& posted_from,
+ int64_t cmsDelay,
int64_t tstamp,
MessageHandler* phandler,
uint32_t id,
@@ -405,6 +415,7 @@
{
CritScope cs(&crit_);
Message msg;
+ msg.posted_from = posted_from;
msg.phandler = phandler;
msg.message_id = id;
msg.pdata = pdata;
@@ -485,8 +496,17 @@
}
void MessageQueue::Dispatch(Message *pmsg) {
- TRACE_EVENT0("webrtc", "MessageQueue::Dispatch");
+ TRACE_EVENT2("webrtc", "MessageQueue::Dispatch", "src_file_and_line",
+ pmsg->posted_from.file_and_line(), "src_func",
+ pmsg->posted_from.function_name());
+ int64_t start_time = TimeMillis();
pmsg->phandler->OnMessage(pmsg);
+ int64_t end_time = TimeMillis();
+ int64_t diff = TimeDiff(end_time, start_time);
+ if (diff >= kSlowDispatchLoggingThreshold) {
+ LOG(LS_INFO) << "Message took " << diff << "ms to dispatch. Posted from: "
+ << pmsg->posted_from.ToString();
+ }
}
} // namespace rtc
diff --git a/webrtc/base/messagequeue.h b/webrtc/base/messagequeue.h
index bf11037..15b9856 100644
--- a/webrtc/base/messagequeue.h
+++ b/webrtc/base/messagequeue.h
@@ -22,6 +22,7 @@
#include "webrtc/base/basictypes.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/location.h"
#include "webrtc/base/messagehandler.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/sharedexclusivelock.h"
@@ -138,13 +139,13 @@
// No destructor
struct Message {
- Message() {
- memset(this, 0, sizeof(*this));
- }
+ Message()
+ : phandler(nullptr), message_id(0), pdata(nullptr), ts_sensitive(0) {}
inline bool Match(MessageHandler* handler, uint32_t id) const {
return (handler == NULL || handler == phandler)
&& (id == MQID_ANY || id == message_id);
}
+ Location posted_from;
MessageHandler *phandler;
uint32_t message_id;
MessageData *pdata;
@@ -213,20 +214,24 @@
virtual bool Get(Message *pmsg, int cmsWait = kForever,
bool process_io = true);
virtual bool Peek(Message *pmsg, int cmsWait = 0);
- virtual void Post(MessageHandler* phandler,
+ virtual void Post(const Location& posted_from,
+ MessageHandler* phandler,
uint32_t id = 0,
MessageData* pdata = NULL,
bool time_sensitive = false);
- virtual void PostDelayed(int cmsDelay,
+ virtual void PostDelayed(const Location& posted_from,
+ int cmsDelay,
MessageHandler* phandler,
uint32_t id = 0,
MessageData* pdata = NULL);
- virtual void PostAt(int64_t tstamp,
+ virtual void PostAt(const Location& posted_from,
+ int64_t tstamp,
MessageHandler* phandler,
uint32_t id = 0,
MessageData* pdata = NULL);
// TODO(honghaiz): Remove this when all the dependencies are removed.
- virtual void PostAt(uint32_t tstamp,
+ virtual void PostAt(const Location& posted_from,
+ uint32_t tstamp,
MessageHandler* phandler,
uint32_t id = 0,
MessageData* pdata = NULL);
@@ -248,7 +253,7 @@
// Internally posts a message which causes the doomed object to be deleted
template<class T> void Dispose(T* doomed) {
if (doomed) {
- Post(NULL, MQID_DISPOSE, new DisposeData<T>(doomed));
+ Post(RTC_FROM_HERE, NULL, MQID_DISPOSE, new DisposeData<T>(doomed));
}
}
@@ -263,7 +268,8 @@
void reheap() { make_heap(c.begin(), c.end(), comp); }
};
- void DoDelayPost(int64_t cmsDelay,
+ void DoDelayPost(const Location& posted_from,
+ int64_t cmsDelay,
int64_t tstamp,
MessageHandler* phandler,
uint32_t id,
diff --git a/webrtc/base/messagequeue_unittest.cc b/webrtc/base/messagequeue_unittest.cc
index 50c2ad0..fc3a8f7 100644
--- a/webrtc/base/messagequeue_unittest.cc
+++ b/webrtc/base/messagequeue_unittest.cc
@@ -35,7 +35,7 @@
Thread worker;
worker.Start();
return worker.Invoke<bool>(
- rtc::Bind(&MessageQueueTest::IsLocked_Worker, this));
+ RTC_FROM_HERE, rtc::Bind(&MessageQueueTest::IsLocked_Worker, this));
}
};
@@ -55,11 +55,11 @@
MessageQueue* q) {
EXPECT_TRUE(q != NULL);
int64_t now = TimeMillis();
- q->PostAt(now, NULL, 3);
- q->PostAt(now - 2, NULL, 0);
- q->PostAt(now - 1, NULL, 1);
- q->PostAt(now, NULL, 4);
- q->PostAt(now - 1, NULL, 2);
+ q->PostAt(RTC_FROM_HERE, now, NULL, 3);
+ q->PostAt(RTC_FROM_HERE, now - 2, NULL, 0);
+ q->PostAt(RTC_FROM_HERE, now - 1, NULL, 1);
+ q->PostAt(RTC_FROM_HERE, now, NULL, 4);
+ q->PostAt(RTC_FROM_HERE, now - 1, NULL, 2);
Message msg;
for (size_t i=0; i<5; ++i) {
@@ -109,7 +109,7 @@
// First, post a dispose.
Dispose(handler);
// Now, post a message, which should *not* be returned by Get().
- Post(handler, 1);
+ Post(RTC_FROM_HERE, handler, 1);
Message msg;
EXPECT_FALSE(Get(&msg, 0));
EXPECT_TRUE(deleted);
diff --git a/webrtc/base/network.cc b/webrtc/base/network.cc
index 152bcdf..5593b6d 100644
--- a/webrtc/base/network.cc
+++ b/webrtc/base/network.cc
@@ -730,9 +730,9 @@
// we should trigger network signal immediately for the new clients
// to start allocating ports.
if (sent_first_update_)
- thread_->Post(this, kSignalNetworksMessage);
+ thread_->Post(RTC_FROM_HERE, this, kSignalNetworksMessage);
} else {
- thread_->Post(this, kUpdateNetworksMessage);
+ thread_->Post(RTC_FROM_HERE, this, kUpdateNetworksMessage);
StartNetworkMonitor();
}
++start_count_;
@@ -870,7 +870,8 @@
void BasicNetworkManager::UpdateNetworksContinually() {
UpdateNetworksOnce();
- thread_->PostDelayed(kNetworksUpdateIntervalMs, this, kUpdateNetworksMessage);
+ thread_->PostDelayed(RTC_FROM_HERE, kNetworksUpdateIntervalMs, this,
+ kUpdateNetworksMessage);
}
void BasicNetworkManager::DumpNetworks() {
diff --git a/webrtc/base/networkmonitor.cc b/webrtc/base/networkmonitor.cc
index 8587691..12076bd 100644
--- a/webrtc/base/networkmonitor.cc
+++ b/webrtc/base/networkmonitor.cc
@@ -31,7 +31,7 @@
void NetworkMonitorBase::OnNetworksChanged() {
LOG(LS_VERBOSE) << "Network change is received at the network monitor";
- worker_thread_->Post(this, UPDATE_NETWORKS_MESSAGE);
+ worker_thread_->Post(RTC_FROM_HERE, this, UPDATE_NETWORKS_MESSAGE);
}
void NetworkMonitorBase::OnMessage(Message* msg) {
diff --git a/webrtc/base/nullsocketserver_unittest.cc b/webrtc/base/nullsocketserver_unittest.cc
index e18afb2..fb059c5 100644
--- a/webrtc/base/nullsocketserver_unittest.cc
+++ b/webrtc/base/nullsocketserver_unittest.cc
@@ -30,7 +30,7 @@
TEST_F(NullSocketServerTest, WaitAndSet) {
Thread thread;
EXPECT_TRUE(thread.Start());
- thread.Post(this, 0);
+ thread.Post(RTC_FROM_HERE, this, 0);
// The process_io will be ignored.
const bool process_io = true;
EXPECT_TRUE_WAIT(ss_.Wait(SocketServer::kForever, process_io), kTimeout);
diff --git a/webrtc/base/openssladapter.cc b/webrtc/base/openssladapter.cc
index d1cbaa8..0a416cf 100644
--- a/webrtc/base/openssladapter.cc
+++ b/webrtc/base/openssladapter.cc
@@ -404,7 +404,8 @@
if (DTLSv1_get_timeout(ssl_, &timeout)) {
int delay = timeout.tv_sec * 1000 + timeout.tv_usec/1000;
- Thread::Current()->PostDelayed(delay, this, MSG_TIMEOUT, 0);
+ Thread::Current()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_TIMEOUT,
+ 0);
}
break;
diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc
index abdf5e4..1d2d03a 100644
--- a/webrtc/base/opensslstreamadapter.cc
+++ b/webrtc/base/opensslstreamadapter.cc
@@ -828,7 +828,8 @@
if (DTLSv1_get_timeout(ssl_, &timeout)) {
int delay = timeout.tv_sec * 1000 + timeout.tv_usec/1000;
- Thread::Current()->PostDelayed(delay, this, MSG_TIMEOUT, 0);
+ Thread::Current()->PostDelayed(RTC_FROM_HERE, delay, this,
+ MSG_TIMEOUT, 0);
}
}
break;
diff --git a/webrtc/base/rtccertificategenerator.cc b/webrtc/base/rtccertificategenerator.cc
index f0d72e7..461a00c 100644
--- a/webrtc/base/rtccertificategenerator.cc
+++ b/webrtc/base/rtccertificategenerator.cc
@@ -66,7 +66,8 @@
// Handle callbacks on signaling thread. Pass on the |msg->pdata|
// (which references |this| with ref counting) to that thread.
- signaling_thread_->Post(this, MSG_GENERATE_DONE, msg->pdata);
+ signaling_thread_->Post(RTC_FROM_HERE, this, MSG_GENERATE_DONE,
+ msg->pdata);
break;
case MSG_GENERATE_DONE:
RTC_DCHECK(signaling_thread_->IsCurrent());
@@ -152,7 +153,8 @@
new RefCountedObject<RTCCertificateGenerationTask>(
signaling_thread_, worker_thread_, key_params, expires_ms,
callback));
- worker_thread_->Post(msg_data->data().get(), MSG_GENERATE, msg_data);
+ worker_thread_->Post(RTC_FROM_HERE, msg_data->data().get(), MSG_GENERATE,
+ msg_data);
}
} // namespace rtc
diff --git a/webrtc/base/sharedexclusivelock_unittest.cc b/webrtc/base/sharedexclusivelock_unittest.cc
index 45902af..5fbf320 100644
--- a/webrtc/base/sharedexclusivelock_unittest.cc
+++ b/webrtc/base/sharedexclusivelock_unittest.cc
@@ -67,7 +67,8 @@
}
void PostRead(int* value) {
- worker_thread_->Post(this, kMsgRead, new TypedMessageData<int*>(value));
+ worker_thread_->Post(RTC_FROM_HERE, this, kMsgRead,
+ new TypedMessageData<int*>(value));
}
private:
@@ -100,7 +101,8 @@
}
void PostWrite(int value) {
- worker_thread_->Post(this, kMsgWrite, new TypedMessageData<int>(value));
+ worker_thread_->Post(RTC_FROM_HERE, this, kMsgWrite,
+ new TypedMessageData<int>(value));
}
private:
diff --git a/webrtc/base/signalthread.cc b/webrtc/base/signalthread.cc
index 75f7b77..e5dd694 100644
--- a/webrtc/base/signalthread.cc
+++ b/webrtc/base/signalthread.cc
@@ -137,7 +137,7 @@
{
EnterExit ee(this);
if (main_) {
- main_->Post(this, ST_MSG_WORKER_DONE);
+ main_->Post(RTC_FROM_HERE, this, ST_MSG_WORKER_DONE);
}
}
}
diff --git a/webrtc/base/socket_unittest.cc b/webrtc/base/socket_unittest.cc
index ea37f23..0b282cd 100644
--- a/webrtc/base/socket_unittest.cc
+++ b/webrtc/base/socket_unittest.cc
@@ -672,7 +672,7 @@
thread->Start();
Sleeper sleeper;
TypedMessageData<AsyncSocket*> data(client.get());
- thread->Send(&sleeper, 0, &data);
+ thread->Send(RTC_FROM_HERE, &sleeper, 0, &data);
EXPECT_FALSE(sink.Check(accepted.get(), testing::SSE_READ));
// But should signal when process_io is true.
diff --git a/webrtc/base/stream.cc b/webrtc/base/stream.cc
index 1ddff1c..b9870db 100644
--- a/webrtc/base/stream.cc
+++ b/webrtc/base/stream.cc
@@ -94,7 +94,8 @@
}
void StreamInterface::PostEvent(Thread* t, int events, int err) {
- t->Post(this, MSG_POST_EVENT, new StreamEventData(events, err));
+ t->Post(RTC_FROM_HERE, this, MSG_POST_EVENT,
+ new StreamEventData(events, err));
}
void StreamInterface::PostEvent(int events, int err) {
diff --git a/webrtc/base/task_queue.h b/webrtc/base/task_queue.h
index 380dea7..f57c6b4 100644
--- a/webrtc/base/task_queue.h
+++ b/webrtc/base/task_queue.h
@@ -167,7 +167,7 @@
static bool IsCurrent(const char* queue_name);
bool IsCurrent() const;
- // TODO(tommi): For better debuggability, implement FROM_HERE.
+ // TODO(tommi): For better debuggability, implement RTC_FROM_HERE.
// Ownership of the task is passed to PostTask.
void PostTask(std::unique_ptr<QueuedTask> task);
diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc
index c6dc3c4..5278c93 100644
--- a/webrtc/base/thread.cc
+++ b/webrtc/base/thread.cc
@@ -26,14 +26,13 @@
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/timeutils.h"
+#include "webrtc/base/trace_event.h"
#if !__has_feature(objc_arc) && (defined(WEBRTC_MAC))
#include "webrtc/base/maccocoathreadhelper.h"
#include "webrtc/base/scoped_autorelease_pool.h"
#endif
-#include "webrtc/base/trace_event.h"
-
namespace rtc {
ThreadManager* ThreadManager::Instance() {
@@ -343,7 +342,10 @@
Join();
}
-void Thread::Send(MessageHandler* phandler, uint32_t id, MessageData* pdata) {
+void Thread::Send(const Location& posted_from,
+ MessageHandler* phandler,
+ uint32_t id,
+ MessageData* pdata) {
if (fStop_)
return;
@@ -351,6 +353,7 @@
// of "thread", like Win32 SendMessage. If in the right context,
// call the handler directly.
Message msg;
+ msg.posted_from = posted_from;
msg.phandler = phandler;
msg.message_id = id;
msg.pdata = pdata;
@@ -444,12 +447,12 @@
return false;
}
-void Thread::InvokeBegin() {
- TRACE_EVENT_BEGIN0("webrtc", "Thread::Invoke");
-}
-
-void Thread::InvokeEnd() {
- TRACE_EVENT_END0("webrtc", "Thread::Invoke");
+void Thread::InvokeInternal(const Location& posted_from,
+ MessageHandler* handler) {
+ TRACE_EVENT2("webrtc", "Thread::Invoke", "src_file_and_line",
+ posted_from.file_and_line(), "src_func",
+ posted_from.function_name());
+ Send(posted_from, handler);
}
void Thread::Clear(MessageHandler* phandler,
diff --git a/webrtc/base/thread.h b/webrtc/base/thread.h
index 1afe9d5..97e6941 100644
--- a/webrtc/base/thread.h
+++ b/webrtc/base/thread.h
@@ -151,7 +151,8 @@
// ProcessMessages occasionally.
virtual void Run();
- virtual void Send(MessageHandler* phandler,
+ virtual void Send(const Location& posted_from,
+ MessageHandler* phandler,
uint32_t id = 0,
MessageData* pdata = NULL);
@@ -159,15 +160,14 @@
// provide the |ReturnT| template argument, which cannot (easily) be deduced.
// Uses Send() internally, which blocks the current thread until execution
// is complete.
- // Ex: bool result = thread.Invoke<bool>(&MyFunctionReturningBool);
+ // Ex: bool result = thread.Invoke<bool>(RTC_FROM_HERE,
+ // &MyFunctionReturningBool);
// NOTE: This function can only be called when synchronous calls are allowed.
// See ScopedDisallowBlockingCalls for details.
template <class ReturnT, class FunctorT>
- ReturnT Invoke(const FunctorT& functor) {
- InvokeBegin();
+ ReturnT Invoke(const Location& posted_from, const FunctorT& functor) {
FunctorMessageHandler<ReturnT, FunctorT> handler(functor);
- Send(&handler);
- InvokeEnd();
+ InvokeInternal(posted_from, &handler);
return handler.result();
}
@@ -261,9 +261,7 @@
// Returns true if there is such a message.
bool PopSendMessageFromThread(const Thread* source, _SendMessage* msg);
- // Used for tracking performance of Invoke calls.
- void InvokeBegin();
- void InvokeEnd();
+ void InvokeInternal(const Location& posted_from, MessageHandler* handler);
std::list<_SendMessage> sendlist_;
std::string name_;
diff --git a/webrtc/base/thread_unittest.cc b/webrtc/base/thread_unittest.cc
index bf3cbd0..b0c8cb5 100644
--- a/webrtc/base/thread_unittest.cc
+++ b/webrtc/base/thread_unittest.cc
@@ -72,7 +72,8 @@
uint32_t prev = reinterpret_cast<const uint32_t*>(buf)[0];
uint32_t result = Next(prev);
- post_thread_->PostDelayed(200, post_handler_, 0, new TestMessage(result));
+ post_thread_->PostDelayed(RTC_FROM_HERE, 200, post_handler_, 0,
+ new TestMessage(result));
}
private:
@@ -211,7 +212,7 @@
th2.Start();
// Get the messages started.
- th1.PostDelayed(100, &msg_client, 0, new TestMessage(1));
+ th1.PostDelayed(RTC_FROM_HERE, 100, &msg_client, 0, new TestMessage(1));
// Give the clients a little while to run.
// Messages will be processed at 100, 300, 500, 700, 900.
@@ -272,18 +273,18 @@
Thread thread;
thread.Start();
// Try calling functors.
- EXPECT_EQ(42, thread.Invoke<int>(FunctorA()));
+ EXPECT_EQ(42, thread.Invoke<int>(RTC_FROM_HERE, FunctorA()));
AtomicBool called;
FunctorB f2(&called);
- thread.Invoke<void>(f2);
+ thread.Invoke<void>(RTC_FROM_HERE, f2);
EXPECT_TRUE(called.get());
// Try calling bare functions.
struct LocalFuncs {
static int Func1() { return 999; }
static void Func2() {}
};
- EXPECT_EQ(999, thread.Invoke<int>(&LocalFuncs::Func1));
- thread.Invoke<void>(&LocalFuncs::Func2);
+ EXPECT_EQ(999, thread.Invoke<int>(RTC_FROM_HERE, &LocalFuncs::Func1));
+ thread.Invoke<void>(RTC_FROM_HERE, &LocalFuncs::Func2);
}
// Verifies that two threads calling Invoke on each other at the same time does
@@ -299,13 +300,13 @@
struct LocalFuncs {
static void Set(bool* out) { *out = true; }
static void InvokeSet(Thread* thread, bool* out) {
- thread->Invoke<void>(Bind(&Set, out));
+ thread->Invoke<void>(RTC_FROM_HERE, Bind(&Set, out));
}
};
bool called = false;
other_thread.Invoke<void>(
- Bind(&LocalFuncs::InvokeSet, current_thread, &called));
+ RTC_FROM_HERE, Bind(&LocalFuncs::InvokeSet, current_thread, &called));
EXPECT_TRUE(called);
}
@@ -342,7 +343,7 @@
struct LocalFuncs {
static void Set(LockedBool* out) { out->Set(true); }
static void InvokeSet(Thread* thread, LockedBool* out) {
- thread->Invoke<void>(Bind(&Set, out));
+ thread->Invoke<void>(RTC_FROM_HERE, Bind(&Set, out));
}
// Set |out| true and call InvokeSet on |thread|.
@@ -362,7 +363,8 @@
AsyncInvoker invoker;
invoker.AsyncInvoke<void>(
- thread1, Bind(&SetAndInvokeSet, &async_invoked, thread2, out));
+ RTC_FROM_HERE, thread1,
+ Bind(&SetAndInvokeSet, &async_invoked, thread2, out));
EXPECT_TRUE_WAIT(async_invoked.Get(), 2000);
}
@@ -373,8 +375,9 @@
// Start the sequence A --(invoke)--> B --(async invoke)--> C --(invoke)--> A.
// Thread B returns when C receives the call and C should be blocked until A
// starts to process messages.
- thread_b.Invoke<void>(Bind(&LocalFuncs::AsyncInvokeSetAndWait,
- &thread_c, thread_a, &thread_a_called));
+ thread_b.Invoke<void>(RTC_FROM_HERE,
+ Bind(&LocalFuncs::AsyncInvokeSetAndWait, &thread_c,
+ thread_a, &thread_a_called));
EXPECT_FALSE(thread_a_called.Get());
EXPECT_TRUE_WAIT(thread_a_called.Get(), 2000);
@@ -424,7 +427,7 @@
}
void AsyncInvokeIntCallback(AsyncInvoker* invoker, Thread* thread) {
expected_thread_ = thread;
- invoker->AsyncInvoke(thread, FunctorC(),
+ invoker->AsyncInvoke(RTC_FROM_HERE, RTC_FROM_HERE, thread, FunctorC(),
&AsyncInvokeTest::IntCallback,
static_cast<AsyncInvokeTest*>(this));
invoke_started_.Set();
@@ -452,7 +455,7 @@
thread.Start();
// Try calling functor.
AtomicBool called;
- invoker.AsyncInvoke<void>(&thread, FunctorB(&called));
+ invoker.AsyncInvoke<void>(RTC_FROM_HERE, &thread, FunctorB(&called));
EXPECT_TRUE_WAIT(called.get(), kWaitTimeout);
}
@@ -463,7 +466,7 @@
thread.Start();
// Try calling functor.
SetExpectedThreadForIntCallback(Thread::Current());
- invoker.AsyncInvoke(&thread, FunctorA(),
+ invoker.AsyncInvoke(RTC_FROM_HERE, RTC_FROM_HERE, &thread, FunctorA(),
&AsyncInvokeTest::IntCallback,
static_cast<AsyncInvokeTest*>(this));
EXPECT_EQ_WAIT(42, int_value_, kWaitTimeout);
@@ -476,7 +479,7 @@
// Try destroying invoker during call.
{
AsyncInvoker invoker;
- invoker.AsyncInvoke(&thread, FunctorC(),
+ invoker.AsyncInvoke(RTC_FROM_HERE, RTC_FROM_HERE, &thread, FunctorC(),
&AsyncInvokeTest::IntCallback,
static_cast<AsyncInvokeTest*>(this));
}
@@ -491,9 +494,10 @@
Thread thread;
thread.Start();
// Try calling functor.
- thread.Invoke<void>(Bind(&AsyncInvokeTest::AsyncInvokeIntCallback,
- static_cast<AsyncInvokeTest*>(this),
- &invoker, Thread::Current()));
+ thread.Invoke<void>(
+ RTC_FROM_HERE,
+ Bind(&AsyncInvokeTest::AsyncInvokeIntCallback,
+ static_cast<AsyncInvokeTest*>(this), &invoker, Thread::Current()));
// Wait for the call to begin.
ASSERT_TRUE(invoke_started_.Wait(kWaitTimeout));
}
@@ -508,9 +512,10 @@
{
AsyncInvoker invoker;
// Try calling functor.
- thread.Invoke<void>(Bind(&AsyncInvokeTest::AsyncInvokeIntCallback,
- static_cast<AsyncInvokeTest*>(this),
- &invoker, Thread::Current()));
+ thread.Invoke<void>(
+ RTC_FROM_HERE,
+ Bind(&AsyncInvokeTest::AsyncInvokeIntCallback,
+ static_cast<AsyncInvokeTest*>(this), &invoker, Thread::Current()));
// Wait for the call to begin.
ASSERT_TRUE(invoke_started_.Wait(kWaitTimeout));
}
@@ -524,10 +529,8 @@
AtomicBool flag1;
AtomicBool flag2;
// Queue two async calls to the current thread.
- invoker.AsyncInvoke<void>(Thread::Current(),
- FunctorB(&flag1));
- invoker.AsyncInvoke<void>(Thread::Current(),
- FunctorB(&flag2));
+ invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag1));
+ invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag2));
// Because we haven't pumped messages, these should not have run yet.
EXPECT_FALSE(flag1.get());
EXPECT_FALSE(flag2.get());
@@ -542,11 +545,9 @@
AtomicBool flag1;
AtomicBool flag2;
// Queue two async calls to the current thread, one with a message id.
- invoker.AsyncInvoke<void>(Thread::Current(),
- FunctorB(&flag1),
+ invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag1),
5);
- invoker.AsyncInvoke<void>(Thread::Current(),
- FunctorB(&flag2));
+ invoker.AsyncInvoke<void>(RTC_FROM_HERE, Thread::Current(), FunctorB(&flag2));
// Because we haven't pumped messages, these should not have run yet.
EXPECT_FALSE(flag1.get());
EXPECT_FALSE(flag2.get());
@@ -569,7 +570,8 @@
}
void AsyncInvokeIntCallback(GuardedAsyncInvoker* invoker, Thread* thread) {
expected_thread_ = thread;
- invoker->AsyncInvoke(FunctorC(), &GuardedAsyncInvokeTest::IntCallback,
+ invoker->AsyncInvoke(RTC_FROM_HERE, RTC_FROM_HERE, FunctorC(),
+ &GuardedAsyncInvokeTest::IntCallback,
static_cast<GuardedAsyncInvokeTest*>(this));
invoke_started_.Set();
}
@@ -604,12 +606,12 @@
thread->Start();
std::unique_ptr<GuardedAsyncInvoker> invoker;
// Create the invoker on |thread|.
- thread->Invoke<void>(CreateInvoker(&invoker));
+ thread->Invoke<void>(RTC_FROM_HERE, CreateInvoker(&invoker));
// Kill |thread|.
thread = nullptr;
// Try calling functor.
AtomicBool called;
- EXPECT_FALSE(invoker->AsyncInvoke<void>(FunctorB(&called)));
+ EXPECT_FALSE(invoker->AsyncInvoke<void>(RTC_FROM_HERE, FunctorB(&called)));
// With thread gone, nothing should happen.
WAIT(called.get(), kWaitTimeout);
EXPECT_FALSE(called.get());
@@ -622,12 +624,13 @@
thread->Start();
std::unique_ptr<GuardedAsyncInvoker> invoker;
// Create the invoker on |thread|.
- thread->Invoke<void>(CreateInvoker(&invoker));
+ thread->Invoke<void>(RTC_FROM_HERE, CreateInvoker(&invoker));
// Kill |thread|.
thread = nullptr;
// Try calling functor.
EXPECT_FALSE(
- invoker->AsyncInvoke(FunctorC(), &GuardedAsyncInvokeTest::IntCallback,
+ invoker->AsyncInvoke(RTC_FROM_HERE, RTC_FROM_HERE, FunctorC(),
+ &GuardedAsyncInvokeTest::IntCallback,
static_cast<GuardedAsyncInvokeTest*>(this)));
// With thread gone, callback should be cancelled.
Thread::Current()->ProcessMessages(kWaitTimeout);
@@ -640,7 +643,7 @@
GuardedAsyncInvoker invoker;
// Try calling functor.
AtomicBool called;
- EXPECT_TRUE(invoker.AsyncInvoke<void>(FunctorB(&called)));
+ EXPECT_TRUE(invoker.AsyncInvoke<void>(RTC_FROM_HERE, FunctorB(&called)));
EXPECT_TRUE_WAIT(called.get(), kWaitTimeout);
}
@@ -648,7 +651,7 @@
GuardedAsyncInvoker invoker;
// Try calling functor.
SetExpectedThreadForIntCallback(Thread::Current());
- EXPECT_TRUE(invoker.AsyncInvoke(FunctorA(),
+ EXPECT_TRUE(invoker.AsyncInvoke(RTC_FROM_HERE, RTC_FROM_HERE, FunctorA(),
&GuardedAsyncInvokeTest::IntCallback,
static_cast<GuardedAsyncInvokeTest*>(this)));
EXPECT_EQ_WAIT(42, int_value_, kWaitTimeout);
@@ -659,7 +662,8 @@
{
GuardedAsyncInvoker invoker;
EXPECT_TRUE(
- invoker.AsyncInvoke(FunctorC(), &GuardedAsyncInvokeTest::IntCallback,
+ invoker.AsyncInvoke(RTC_FROM_HERE, RTC_FROM_HERE, FunctorC(),
+ &GuardedAsyncInvokeTest::IntCallback,
static_cast<GuardedAsyncInvokeTest*>(this)));
}
// With invoker gone, callback should be cancelled.
@@ -674,7 +678,8 @@
Thread thread;
thread.Start();
// Try calling functor.
- thread.Invoke<void>(Bind(&GuardedAsyncInvokeTest::AsyncInvokeIntCallback,
+ thread.Invoke<void>(RTC_FROM_HERE,
+ Bind(&GuardedAsyncInvokeTest::AsyncInvokeIntCallback,
static_cast<GuardedAsyncInvokeTest*>(this),
&invoker, Thread::Current()));
// Wait for the call to begin.
@@ -691,7 +696,8 @@
{
GuardedAsyncInvoker invoker;
// Try calling functor.
- thread.Invoke<void>(Bind(&GuardedAsyncInvokeTest::AsyncInvokeIntCallback,
+ thread.Invoke<void>(RTC_FROM_HERE,
+ Bind(&GuardedAsyncInvokeTest::AsyncInvokeIntCallback,
static_cast<GuardedAsyncInvokeTest*>(this),
&invoker, Thread::Current()));
// Wait for the call to begin.
@@ -707,8 +713,8 @@
AtomicBool flag1;
AtomicBool flag2;
// Queue two async calls to the current thread.
- EXPECT_TRUE(invoker.AsyncInvoke<void>(FunctorB(&flag1)));
- EXPECT_TRUE(invoker.AsyncInvoke<void>(FunctorB(&flag2)));
+ EXPECT_TRUE(invoker.AsyncInvoke<void>(RTC_FROM_HERE, FunctorB(&flag1)));
+ EXPECT_TRUE(invoker.AsyncInvoke<void>(RTC_FROM_HERE, FunctorB(&flag2)));
// Because we haven't pumped messages, these should not have run yet.
EXPECT_FALSE(flag1.get());
EXPECT_FALSE(flag2.get());
@@ -723,8 +729,8 @@
AtomicBool flag1;
AtomicBool flag2;
// Queue two async calls to the current thread, one with a message id.
- EXPECT_TRUE(invoker.AsyncInvoke<void>(FunctorB(&flag1), 5));
- EXPECT_TRUE(invoker.AsyncInvoke<void>(FunctorB(&flag2)));
+ EXPECT_TRUE(invoker.AsyncInvoke<void>(RTC_FROM_HERE, FunctorB(&flag1), 5));
+ EXPECT_TRUE(invoker.AsyncInvoke<void>(RTC_FROM_HERE, FunctorB(&flag2)));
// Because we haven't pumped messages, these should not have run yet.
EXPECT_FALSE(flag1.get());
EXPECT_FALSE(flag2.get());
@@ -759,7 +765,7 @@
TEST_F(ComThreadTest, ComInited) {
Thread* thread = new ComThread();
EXPECT_TRUE(thread->Start());
- thread->Post(this, 0);
+ thread->Post(RTC_FROM_HERE, this, 0);
EXPECT_TRUE_WAIT(done_, 1000);
delete thread;
}
diff --git a/webrtc/base/timeutils_unittest.cc b/webrtc/base/timeutils_unittest.cc
index d1cfe23..6707d8c 100644
--- a/webrtc/base/timeutils_unittest.cc
+++ b/webrtc/base/timeutils_unittest.cc
@@ -359,7 +359,7 @@
message_handler_dispatched.Set();
};
FunctorMessageHandler<void, decltype(functor)> handler(functor);
- worker.PostDelayed(60000, &handler);
+ worker.PostDelayed(RTC_FROM_HERE, 60000, &handler);
// Wait for a bit for the worker thread to be started and enter its socket
// select(). Otherwise this test would be trivial since the worker thread
diff --git a/webrtc/base/virtualsocket_unittest.cc b/webrtc/base/virtualsocket_unittest.cc
index ce89b50..f517346 100644
--- a/webrtc/base/virtualsocket_unittest.cc
+++ b/webrtc/base/virtualsocket_unittest.cc
@@ -36,7 +36,7 @@
rate(rt),
count(0) {
last_send = rtc::TimeMillis();
- thread->PostDelayed(NextDelay(), this, 1);
+ thread->PostDelayed(RTC_FROM_HERE, NextDelay(), this, 1);
}
uint32_t NextDelay() {
@@ -61,7 +61,7 @@
socket->Send(dummy, size, options);
last_send = cur_time;
- thread->PostDelayed(NextDelay(), this, 1);
+ thread->PostDelayed(RTC_FROM_HERE, NextDelay(), this, 1);
}
Thread* thread;
@@ -86,7 +86,7 @@
sum_sq(0),
samples(0) {
socket->SignalReadPacket.connect(this, &Receiver::OnReadPacket);
- thread->PostDelayed(1000, this, 1);
+ thread->PostDelayed(RTC_FROM_HERE, 1000, this, 1);
}
~Receiver() {
@@ -121,7 +121,7 @@
if (bandwidth > 0)
ASSERT_TRUE(sec_count <= 5 * bandwidth / 4);
sec_count = 0;
- thread->PostDelayed(1000, this, 1);
+ thread->PostDelayed(RTC_FROM_HERE, 1000, this, 1);
}
Thread* thread;
diff --git a/webrtc/base/virtualsocketserver.cc b/webrtc/base/virtualsocketserver.cc
index baeeb8e..8b8d050 100644
--- a/webrtc/base/virtualsocketserver.cc
+++ b/webrtc/base/virtualsocketserver.cc
@@ -156,7 +156,7 @@
was_any_ = addr.IsAnyIP();
// Post a message here such that test case could have chance to
// process the local address. (i.e. SetAlternativeLocalAddress).
- server_->msg_queue_->Post(this, MSG_ID_ADDRESS_BOUND);
+ server_->msg_queue_->Post(RTC_FROM_HERE, this, MSG_ID_ADDRESS_BOUND);
}
return result;
}
@@ -760,11 +760,11 @@
}
if (remote != NULL) {
SocketAddress addr = socket->GetLocalAddress();
- msg_queue_->PostDelayed(delay, remote, MSG_ID_CONNECT,
+ msg_queue_->PostDelayed(RTC_FROM_HERE, delay, remote, MSG_ID_CONNECT,
new MessageAddress(addr));
} else {
LOG(LS_INFO) << "No one listening at " << remote_addr;
- msg_queue_->PostDelayed(delay, socket, MSG_ID_DISCONNECT);
+ msg_queue_->PostDelayed(RTC_FROM_HERE, delay, socket, MSG_ID_DISCONNECT);
}
return 0;
}
@@ -772,7 +772,7 @@
bool VirtualSocketServer::Disconnect(VirtualSocket* socket) {
if (socket) {
// Remove the mapping.
- msg_queue_->Post(socket, MSG_ID_DISCONNECT);
+ msg_queue_->Post(RTC_FROM_HERE, socket, MSG_ID_DISCONNECT);
return true;
}
return false;
@@ -920,7 +920,7 @@
// introduces artificial delay.
ts = std::max(ts, network_delay_);
}
- msg_queue_->PostAt(ts, recipient, MSG_ID_PACKET, p);
+ msg_queue_->PostAt(RTC_FROM_HERE, ts, recipient, MSG_ID_PACKET, p);
network_delay_ = std::max(ts, network_delay_);
}
diff --git a/webrtc/base/worker.cc b/webrtc/base/worker.cc
index 1b48b9b..f31c43f 100644
--- a/webrtc/base/worker.cc
+++ b/webrtc/base/worker.cc
@@ -63,7 +63,7 @@
void Worker::HaveWork() {
ASSERT(worker_thread_ != NULL);
- worker_thread_->Post(this, MSG_HAVEWORK);
+ worker_thread_->Post(RTC_FROM_HERE, this, MSG_HAVEWORK);
}
void Worker::OnMessage(rtc::Message *msg) {
diff --git a/webrtc/examples/peerconnection/client/peer_connection_client.cc b/webrtc/examples/peerconnection/client/peer_connection_client.cc
index 86d2119..7796220 100644
--- a/webrtc/examples/peerconnection/client/peer_connection_client.cc
+++ b/webrtc/examples/peerconnection/client/peer_connection_client.cc
@@ -500,7 +500,8 @@
} else {
if (socket == control_socket_.get()) {
LOG(WARNING) << "Connection refused; retrying in 2 seconds";
- rtc::Thread::Current()->PostDelayed(kReconnectDelay, this, 0);
+ rtc::Thread::Current()->PostDelayed(RTC_FROM_HERE, kReconnectDelay, this,
+ 0);
} else {
Close();
callback_->OnDisconnected();
diff --git a/webrtc/libjingle/xmpp/pingtask.cc b/webrtc/libjingle/xmpp/pingtask.cc
index ad4566a..f7bef11 100644
--- a/webrtc/libjingle/xmpp/pingtask.cc
+++ b/webrtc/libjingle/xmpp/pingtask.cc
@@ -77,8 +77,8 @@
// Wake ourselves up when it's time to send another ping or when the ping
// times out (so we can fire a signal).
- message_queue_->PostDelayed(ping_timeout_millis_, this);
- message_queue_->PostDelayed(ping_period_millis_, this);
+ message_queue_->PostDelayed(RTC_FROM_HERE, ping_timeout_millis_, this);
+ message_queue_->PostDelayed(RTC_FROM_HERE, ping_period_millis_, this);
}
return STATE_BLOCKED;
diff --git a/webrtc/libjingle/xmpp/xmpppump.cc b/webrtc/libjingle/xmpp/xmpppump.cc
index 4412483..abd7406 100644
--- a/webrtc/libjingle/xmpp/xmpppump.cc
+++ b/webrtc/libjingle/xmpp/xmpppump.cc
@@ -46,7 +46,7 @@
}
void XmppPump::WakeTasks() {
- rtc::Thread::Current()->Post(this);
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this);
}
int64_t XmppPump::CurrentTime() {
diff --git a/webrtc/libjingle/xmpp/xmppthread.cc b/webrtc/libjingle/xmpp/xmppthread.cc
index f492cdf..0fd5002 100644
--- a/webrtc/libjingle/xmpp/xmppthread.cc
+++ b/webrtc/libjingle/xmpp/xmppthread.cc
@@ -42,11 +42,11 @@
}
void XmppThread::Login(const buzz::XmppClientSettings& xcs) {
- Post(this, MSG_LOGIN, new LoginData(xcs));
+ Post(RTC_FROM_HERE, this, MSG_LOGIN, new LoginData(xcs));
}
void XmppThread::Disconnect() {
- Post(this, MSG_DISCONNECT);
+ Post(RTC_FROM_HERE, this, MSG_DISCONNECT);
}
void XmppThread::OnStateChange(buzz::XmppEngine::State state) {
diff --git a/webrtc/media/base/fakenetworkinterface.h b/webrtc/media/base/fakenetworkinterface.h
index 65dac25..ed8b232 100644
--- a/webrtc/media/base/fakenetworkinterface.h
+++ b/webrtc/media/base/fakenetworkinterface.h
@@ -160,7 +160,7 @@
}
void PostMessage(int id, const rtc::CopyOnWriteBuffer& packet) {
- thread_->Post(this, id, rtc::WrapMessageData(packet));
+ thread_->Post(RTC_FROM_HERE, this, id, rtc::WrapMessageData(packet));
}
virtual void OnMessage(rtc::Message* msg) {
diff --git a/webrtc/media/engine/webrtcvideocapturer.cc b/webrtc/media/engine/webrtcvideocapturer.cc
index 71c8841..1c46546 100644
--- a/webrtc/media/engine/webrtcvideocapturer.cc
+++ b/webrtc/media/engine/webrtcvideocapturer.cc
@@ -359,7 +359,7 @@
// thread hop.
// Note that Stop() can cause the async invoke call to be cancelled.
async_invoker_->AsyncInvoke<void>(
- start_thread_,
+ RTC_FROM_HERE, start_thread_,
// Note that Bind captures by value, so there's an intermediate copy
// of sample.
rtc::Bind(&WebRtcVideoCapturer::SignalFrameCapturedOnStartThread, this,
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc
index 9847762..82d32b0 100644
--- a/webrtc/media/engine/webrtcvideoengine2.cc
+++ b/webrtc/media/engine/webrtcvideoengine2.cc
@@ -2004,7 +2004,7 @@
void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) {
if (worker_thread_ != rtc::Thread::Current()) {
invoker_.AsyncInvoke<void>(
- worker_thread_,
+ RTC_FROM_HERE, worker_thread_,
rtc::Bind(&WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate,
this, load));
return;
diff --git a/webrtc/media/sctp/sctpdataengine.cc b/webrtc/media/sctp/sctpdataengine.cc
index 958cd9a..8abdd97 100644
--- a/webrtc/media/sctp/sctpdataengine.cc
+++ b/webrtc/media/sctp/sctpdataengine.cc
@@ -202,7 +202,8 @@
// Note: We have to copy the data; the caller will delete it.
auto* msg = new OutboundPacketMessage(
new rtc::CopyOnWriteBuffer(reinterpret_cast<uint8_t*>(data), length));
- channel->worker_thread()->Post(channel, MSG_SCTPOUTBOUNDPACKET, msg);
+ channel->worker_thread()->Post(RTC_FROM_HERE, channel, MSG_SCTPOUTBOUNDPACKET,
+ msg);
return 0;
}
@@ -239,7 +240,8 @@
packet->flags = flags;
// The ownership of |packet| transfers to |msg|.
InboundPacketMessage* msg = new InboundPacketMessage(packet);
- channel->worker_thread()->Post(channel, MSG_SCTPINBOUNDPACKET, msg);
+ channel->worker_thread()->Post(RTC_FROM_HERE, channel,
+ MSG_SCTPINBOUNDPACKET, msg);
}
free(data);
return 1;
diff --git a/webrtc/media/sctp/sctpdataengine_unittest.cc b/webrtc/media/sctp/sctpdataengine_unittest.cc
index f41691b..7fe209c 100644
--- a/webrtc/media/sctp/sctpdataengine_unittest.cc
+++ b/webrtc/media/sctp/sctpdataengine_unittest.cc
@@ -53,7 +53,8 @@
LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket";
rtc::CopyOnWriteBuffer* buffer = new rtc::CopyOnWriteBuffer(*packet);
- thread_->Post(this, MSG_PACKET, rtc::WrapMessageData(buffer));
+ thread_->Post(RTC_FROM_HERE, this, MSG_PACKET,
+ rtc::WrapMessageData(buffer));
LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket, Posted message.";
return true;
}
diff --git a/webrtc/modules/audio_device/ios/audio_device_ios.mm b/webrtc/modules/audio_device/ios/audio_device_ios.mm
index 8f6fb4d..e564540 100644
--- a/webrtc/modules/audio_device/ios/audio_device_ios.mm
+++ b/webrtc/modules/audio_device/ios/audio_device_ios.mm
@@ -336,22 +336,22 @@
void AudioDeviceIOS::OnInterruptionBegin() {
RTC_DCHECK(thread_);
- thread_->Post(this, kMessageTypeInterruptionBegin);
+ thread_->Post(RTC_FROM_HERE, this, kMessageTypeInterruptionBegin);
}
void AudioDeviceIOS::OnInterruptionEnd() {
RTC_DCHECK(thread_);
- thread_->Post(this, kMessageTypeInterruptionEnd);
+ thread_->Post(RTC_FROM_HERE, this, kMessageTypeInterruptionEnd);
}
void AudioDeviceIOS::OnValidRouteChange() {
RTC_DCHECK(thread_);
- thread_->Post(this, kMessageTypeValidRouteChange);
+ thread_->Post(RTC_FROM_HERE, this, kMessageTypeValidRouteChange);
}
void AudioDeviceIOS::OnCanPlayOrRecordChange(bool can_play_or_record) {
RTC_DCHECK(thread_);
- thread_->Post(this, kMessageTypeCanPlayOrRecordChange,
+ thread_->Post(RTC_FROM_HERE, this, kMessageTypeCanPlayOrRecordChange,
new rtc::TypedMessageData<bool>(can_play_or_record));
}
diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h
index 7f0d969..7b7aec5 100644
--- a/webrtc/p2p/base/faketransportcontroller.h
+++ b/webrtc/p2p/base/faketransportcontroller.h
@@ -207,9 +207,9 @@
PacketMessageData* packet = new PacketMessageData(data, len);
if (async_) {
- rtc::Thread::Current()->Post(this, 0, packet);
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this, 0, packet);
} else {
- rtc::Thread::Current()->Send(this, 0, packet);
+ rtc::Thread::Current()->Send(RTC_FROM_HERE, this, 0, packet);
}
rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis());
SignalSentPacket(this, sent_packet);
@@ -520,6 +520,7 @@
void Connect(FakeTransportController* dest) {
network_thread()->Invoke<void>(
+ RTC_FROM_HERE,
rtc::Bind(&FakeTransportController::Connect_n, this, dest));
}
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index fc1f0a4..d83726e 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -455,7 +455,7 @@
}
// Start checking and pinging as the ports come in.
- thread()->Post(this, MSG_CHECK_AND_PING);
+ thread()->Post(RTC_FROM_HERE, this, MSG_CHECK_AND_PING);
}
void P2PTransportChannel::MaybeStartGathering() {
@@ -1058,7 +1058,7 @@
// Prepare for best candidate sorting.
void P2PTransportChannel::RequestSort() {
if (!sort_dirty_) {
- worker_thread_->Post(this, MSG_SORT);
+ worker_thread_->Post(RTC_FROM_HERE, this, MSG_SORT);
sort_dirty_ = true;
}
}
@@ -1341,7 +1341,7 @@
}
}
int delay = std::min(ping_interval, check_receiving_interval_);
- thread()->PostDelayed(delay, this, MSG_CHECK_AND_PING);
+ thread()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_CHECK_AND_PING);
}
// A connection is considered a backup connection if the channel state
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index 68543a5..cbf5e76 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -655,7 +655,8 @@
if (GetEndpoint(ch)->save_candidates_) {
GetEndpoint(ch)->saved_candidates_.push_back(new CandidatesData(ch, c));
} else {
- main_->Post(this, MSG_ADD_CANDIDATES, new CandidatesData(ch, c));
+ main_->Post(RTC_FROM_HERE, this, MSG_ADD_CANDIDATES,
+ new CandidatesData(ch, c));
}
}
@@ -667,7 +668,7 @@
const std::vector<cricket::Candidate>& candidates) {
// Candidate removals are not paused.
CandidatesData* candidates_data = new CandidatesData(ch, candidates);
- main_->Post(this, MSG_REMOVE_CANDIDATES, candidates_data);
+ main_->Post(RTC_FROM_HERE, this, MSG_REMOVE_CANDIDATES, candidates_data);
}
// Tcp candidate verification has to be done when they are generated.
@@ -691,7 +692,7 @@
Endpoint* ed = GetEndpoint(endpoint);
std::vector<CandidatesData*>::iterator it = ed->saved_candidates_.begin();
for (; it != ed->saved_candidates_.end(); ++it) {
- main_->Post(this, MSG_ADD_CANDIDATES, *it);
+ main_->Post(RTC_FROM_HERE, this, MSG_ADD_CANDIDATES, *it);
}
ed->saved_candidates_.clear();
ed->save_candidates_ = false;
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index 909843c..0add358 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -708,7 +708,7 @@
// fails and is removed before kPortTimeoutDelay, then this message will
// still cause the Port to be destroyed.
if (dead()) {
- thread_->PostDelayed(timeout_delay_, this, MSG_DEAD);
+ thread_->PostDelayed(RTC_FROM_HERE, timeout_delay_, this, MSG_DEAD);
}
}
@@ -1082,7 +1082,7 @@
void Connection::Destroy() {
LOG_J(LS_VERBOSE, this) << "Connection destroyed";
- port_->thread()->Post(this, MSG_DELETE);
+ port_->thread()->Post(RTC_FROM_HERE, this, MSG_DELETE);
}
void Connection::FailAndDestroy() {
diff --git a/webrtc/p2p/base/pseudotcp_unittest.cc b/webrtc/p2p/base/pseudotcp_unittest.cc
index a635bce..8fb5b38b 100644
--- a/webrtc/p2p/base/pseudotcp_unittest.cc
+++ b/webrtc/p2p/base/pseudotcp_unittest.cc
@@ -147,8 +147,8 @@
} else {
int id = (tcp == &local_) ? MSG_RPACKET : MSG_LPACKET;
std::string packet(buffer, len);
- rtc::Thread::Current()->PostDelayed(delay_, this, id,
- rtc::WrapMessageData(packet));
+ rtc::Thread::Current()->PostDelayed(RTC_FROM_HERE, delay_, this, id,
+ rtc::WrapMessageData(packet));
}
return WR_SUCCESS;
}
@@ -160,7 +160,7 @@
tcp->GetNextClock(PseudoTcp::Now(), interval);
interval = std::max<int>(interval, 0L); // sometimes interval is < 0
rtc::Thread::Current()->Clear(this, message);
- rtc::Thread::Current()->PostDelayed(interval, this, message);
+ rtc::Thread::Current()->PostDelayed(RTC_FROM_HERE, interval, this, message);
}
virtual void OnMessage(rtc::Message* message) {
@@ -457,7 +457,7 @@
EXPECT_EQ(0, Connect());
EXPECT_TRUE_WAIT(have_connected_, kConnectTimeoutMs);
- rtc::Thread::Current()->Post(this, MSG_WRITE);
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_WRITE);
EXPECT_TRUE_WAIT(have_disconnected_, kTransferTimeoutMs);
ASSERT_EQ(2u, send_position_.size());
@@ -563,7 +563,7 @@
// If there are non-clock messages remaining, attempt to continue sending
// after giving those messages time to process, which should free up the
// send buffer.
- rtc::Thread::Current()->PostDelayed(10, this, MSG_WRITE);
+ rtc::Thread::Current()->PostDelayed(RTC_FROM_HERE, 10, this, MSG_WRITE);
} else {
if (!remote_.isReceiveBufferFull()) {
LOG(LS_ERROR) << "This shouldn't happen - the send buffer is full, "
diff --git a/webrtc/p2p/base/relayport.cc b/webrtc/p2p/base/relayport.cc
index df0be39..21dc41a 100644
--- a/webrtc/p2p/base/relayport.cc
+++ b/webrtc/p2p/base/relayport.cc
@@ -506,7 +506,7 @@
// If we failed to get a socket, move on to the next protocol.
if (!socket) {
- port()->thread()->Post(this, kMessageConnectTimeout);
+ port()->thread()->Post(RTC_FROM_HERE, this, kMessageConnectTimeout);
return;
}
@@ -525,7 +525,7 @@
if ((ra->proto == PROTO_TCP) || (ra->proto == PROTO_SSLTCP)) {
socket->SignalClose.connect(this, &RelayEntry::OnSocketClose);
socket->SignalConnect.connect(this, &RelayEntry::OnSocketConnect);
- port()->thread()->PostDelayed(kSoftConnectTimeoutMs, this,
+ port()->thread()->PostDelayed(RTC_FROM_HERE, kSoftConnectTimeoutMs, this,
kMessageConnectTimeout);
} else {
current_connection_->SendAllocateRequest(this, 0);
diff --git a/webrtc/p2p/base/relayserver.cc b/webrtc/p2p/base/relayserver.cc
index ebe46c4..0c6df77 100644
--- a/webrtc/p2p/base/relayserver.cc
+++ b/webrtc/p2p/base/relayserver.cc
@@ -668,7 +668,8 @@
NoteUsed();
// Set the first timeout check.
- server_->thread()->PostDelayed(lifetime_, this, MSG_LIFETIME_TIMER);
+ server_->thread()->PostDelayed(RTC_FROM_HERE, lifetime_, this,
+ MSG_LIFETIME_TIMER);
}
RelayServerBinding::~RelayServerBinding() {
@@ -739,7 +740,8 @@
LOG(LS_INFO) << "Expiring binding " << username_;
SignalTimeout(this);
} else {
- server_->thread()->PostDelayed(lifetime_, this, MSG_LIFETIME_TIMER);
+ server_->thread()->PostDelayed(RTC_FROM_HERE, lifetime_, this,
+ MSG_LIFETIME_TIMER);
}
} else {
diff --git a/webrtc/p2p/base/stunrequest.cc b/webrtc/p2p/base/stunrequest.cc
index 32449e2..5886cc9 100644
--- a/webrtc/p2p/base/stunrequest.cc
+++ b/webrtc/p2p/base/stunrequest.cc
@@ -49,9 +49,9 @@
request->Construct();
requests_[request->id()] = request;
if (delay > 0) {
- thread_->PostDelayed(delay, request, MSG_STUN_SEND, NULL);
+ thread_->PostDelayed(RTC_FROM_HERE, delay, request, MSG_STUN_SEND, NULL);
} else {
- thread_->Send(request, MSG_STUN_SEND, NULL);
+ thread_->Send(RTC_FROM_HERE, request, MSG_STUN_SEND, NULL);
}
}
@@ -60,7 +60,7 @@
StunRequest* request = kv.second;
if (msg_type == kAllRequests || msg_type == request->type()) {
thread_->Clear(request, MSG_STUN_SEND);
- thread_->Send(request, MSG_STUN_SEND, NULL);
+ thread_->Send(RTC_FROM_HERE, request, MSG_STUN_SEND, NULL);
}
}
}
@@ -220,7 +220,8 @@
manager_->SignalSendPacket(buf.Data(), buf.Length(), this);
OnSent();
- manager_->thread_->PostDelayed(resend_delay(), this, MSG_STUN_SEND, NULL);
+ manager_->thread_->PostDelayed(RTC_FROM_HERE, resend_delay(), this,
+ MSG_STUN_SEND, NULL);
}
void StunRequest::OnSent() {
diff --git a/webrtc/p2p/base/tcpport.cc b/webrtc/p2p/base/tcpport.cc
index 6166f52..9a1caa2 100644
--- a/webrtc/p2p/base/tcpport.cc
+++ b/webrtc/p2p/base/tcpport.cc
@@ -434,7 +434,7 @@
// We don't attempt reconnect right here. This is to avoid a case where the
// shutdown is intentional and reconnect is not necessary. We only reconnect
// when the connection is used to Send() or Ping().
- port()->thread()->PostDelayed(reconnection_timeout(), this,
+ port()->thread()->PostDelayed(RTC_FROM_HERE, reconnection_timeout(), this,
MSG_TCPCONNECTION_DELAYED_ONCLOSE);
} else if (!pretending_to_be_writable_) {
// OnClose could be called when the underneath socket times out during the
diff --git a/webrtc/p2p/base/transportcontroller.cc b/webrtc/p2p/base/transportcontroller.cc
index 27703c2..2860f87 100644
--- a/webrtc/p2p/base/transportcontroller.cc
+++ b/webrtc/p2p/base/transportcontroller.cc
@@ -51,52 +51,58 @@
TransportController::~TransportController() {
network_thread_->Invoke<void>(
+ RTC_FROM_HERE,
rtc::Bind(&TransportController::DestroyAllTransports_n, this));
signaling_thread_->Clear(this);
}
bool TransportController::SetSslMaxProtocolVersion(
rtc::SSLProtocolVersion version) {
- return network_thread_->Invoke<bool>(rtc::Bind(
- &TransportController::SetSslMaxProtocolVersion_n, this, version));
+ return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&TransportController::SetSslMaxProtocolVersion_n,
+ this, version));
}
void TransportController::SetIceConfig(const IceConfig& config) {
network_thread_->Invoke<void>(
+ RTC_FROM_HERE,
rtc::Bind(&TransportController::SetIceConfig_n, this, config));
}
void TransportController::SetIceRole(IceRole ice_role) {
network_thread_->Invoke<void>(
+ RTC_FROM_HERE,
rtc::Bind(&TransportController::SetIceRole_n, this, ice_role));
}
bool TransportController::GetSslRole(const std::string& transport_name,
rtc::SSLRole* role) {
- return network_thread_->Invoke<bool>(rtc::Bind(
- &TransportController::GetSslRole_n, this, transport_name, role));
+ return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&TransportController::GetSslRole_n, this,
+ transport_name, role));
}
bool TransportController::SetLocalCertificate(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
- return network_thread_->Invoke<bool>(rtc::Bind(
- &TransportController::SetLocalCertificate_n, this, certificate));
+ return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&TransportController::SetLocalCertificate_n,
+ this, certificate));
}
bool TransportController::GetLocalCertificate(
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
return network_thread_->Invoke<bool>(
- rtc::Bind(&TransportController::GetLocalCertificate_n, this,
- transport_name, certificate));
+ RTC_FROM_HERE, rtc::Bind(&TransportController::GetLocalCertificate_n,
+ this, transport_name, certificate));
}
std::unique_ptr<rtc::SSLCertificate>
TransportController::GetRemoteSSLCertificate(
const std::string& transport_name) {
return network_thread_->Invoke<std::unique_ptr<rtc::SSLCertificate>>(
- rtc::Bind(&TransportController::GetRemoteSSLCertificate_n, this,
- transport_name));
+ RTC_FROM_HERE, rtc::Bind(&TransportController::GetRemoteSSLCertificate_n,
+ this, transport_name));
}
bool TransportController::SetLocalTransportDescription(
@@ -105,6 +111,7 @@
ContentAction action,
std::string* err) {
return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE,
rtc::Bind(&TransportController::SetLocalTransportDescription_n, this,
transport_name, tdesc, action, err));
}
@@ -115,12 +122,14 @@
ContentAction action,
std::string* err) {
return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE,
rtc::Bind(&TransportController::SetRemoteTransportDescription_n, this,
transport_name, tdesc, action, err));
}
void TransportController::MaybeStartGathering() {
network_thread_->Invoke<void>(
+ RTC_FROM_HERE,
rtc::Bind(&TransportController::MaybeStartGathering_n, this));
}
@@ -128,25 +137,28 @@
const Candidates& candidates,
std::string* err) {
return network_thread_->Invoke<bool>(
- rtc::Bind(&TransportController::AddRemoteCandidates_n, this,
- transport_name, candidates, err));
+ RTC_FROM_HERE, rtc::Bind(&TransportController::AddRemoteCandidates_n,
+ this, transport_name, candidates, err));
}
bool TransportController::RemoveRemoteCandidates(const Candidates& candidates,
std::string* err) {
- return network_thread_->Invoke<bool>(rtc::Bind(
- &TransportController::RemoveRemoteCandidates_n, this, candidates, err));
+ return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&TransportController::RemoveRemoteCandidates_n,
+ this, candidates, err));
}
bool TransportController::ReadyForRemoteCandidates(
const std::string& transport_name) {
- return network_thread_->Invoke<bool>(rtc::Bind(
- &TransportController::ReadyForRemoteCandidates_n, this, transport_name));
+ return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&TransportController::ReadyForRemoteCandidates_n,
+ this, transport_name));
}
bool TransportController::GetStats(const std::string& transport_name,
TransportStats* stats) {
return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE,
rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats));
}
@@ -555,14 +567,14 @@
candidates.push_back(candidate);
CandidatesData* data =
new CandidatesData(channel->transport_name(), candidates);
- signaling_thread_->Post(this, MSG_CANDIDATESGATHERED, data);
+ signaling_thread_->Post(RTC_FROM_HERE, this, MSG_CANDIDATESGATHERED, data);
}
void TransportController::OnChannelCandidatesRemoved_n(
TransportChannelImpl* channel,
const Candidates& candidates) {
invoker_.AsyncInvoke<void>(
- signaling_thread_,
+ RTC_FROM_HERE, signaling_thread_,
rtc::Bind(&TransportController::OnChannelCandidatesRemoved, this,
candidates));
}
@@ -635,13 +647,13 @@
if (connection_state_ != new_connection_state) {
connection_state_ = new_connection_state;
signaling_thread_->Post(
- this, MSG_ICECONNECTIONSTATE,
+ RTC_FROM_HERE, this, MSG_ICECONNECTIONSTATE,
new rtc::TypedMessageData<IceConnectionState>(new_connection_state));
}
if (receiving_ != any_receiving) {
receiving_ = any_receiving;
- signaling_thread_->Post(this, MSG_RECEIVING,
+ signaling_thread_->Post(RTC_FROM_HERE, this, MSG_RECEIVING,
new rtc::TypedMessageData<bool>(any_receiving));
}
@@ -653,7 +665,7 @@
if (gathering_state_ != new_gathering_state) {
gathering_state_ = new_gathering_state;
signaling_thread_->Post(
- this, MSG_ICEGATHERINGSTATE,
+ RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE,
new rtc::TypedMessageData<IceGatheringState>(new_gathering_state));
}
}
diff --git a/webrtc/p2p/base/transportcontroller_unittest.cc b/webrtc/p2p/base/transportcontroller_unittest.cc
index fdb99a7..4ca481f 100644
--- a/webrtc/p2p/base/transportcontroller_unittest.cc
+++ b/webrtc/p2p/base/transportcontroller_unittest.cc
@@ -100,8 +100,11 @@
// Used for thread hopping test.
void CreateChannelsAndCompleteConnectionOnWorkerThread() {
- worker_thread_->Invoke<void>(rtc::Bind(
- &TransportControllerTest::CreateChannelsAndCompleteConnection_w, this));
+ worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
+ rtc::Bind(
+ &TransportControllerTest::CreateChannelsAndCompleteConnection_w,
+ this));
}
void CreateChannelsAndCompleteConnection_w() {
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc
index 2a0ff35..ff0c292 100644
--- a/webrtc/p2p/base/turnport.cc
+++ b/webrtc/p2p/base/turnport.cc
@@ -736,14 +736,14 @@
// We will send SignalPortError asynchronously as this can be sent during
// port initialization. This way it will not be blocking other port
// creation.
- thread()->Post(this, MSG_ALLOCATE_ERROR);
+ thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATE_ERROR);
}
void TurnPort::OnTurnRefreshError() {
// Need to Close the port asynchronously because otherwise, the refresh
// request may be deleted twice: once at the end of the message processing
// and the other in Close().
- thread()->Post(this, MSG_REFRESH_ERROR);
+ thread()->Post(RTC_FROM_HERE, this, MSG_REFRESH_ERROR);
}
void TurnPort::Close() {
@@ -1026,7 +1026,7 @@
int64_t timestamp = rtc::TimeMillis();
entry->set_destruction_timestamp(timestamp);
invoker_.AsyncInvokeDelayed<void>(
- thread(),
+ RTC_FROM_HERE, thread(),
rtc::Bind(&TurnPort::DestroyEntryIfNotCancelled, this, entry, timestamp),
TURN_PERMISSION_TIMEOUT);
}
@@ -1126,7 +1126,8 @@
case STUN_ERROR_ALLOCATION_MISMATCH:
// We must handle this error async because trying to delete the socket in
// OnErrorResponse will cause a deadlock on the socket.
- port_->thread()->Post(port_, TurnPort::MSG_ALLOCATE_MISMATCH);
+ port_->thread()->Post(RTC_FROM_HERE, port_,
+ TurnPort::MSG_ALLOCATE_MISMATCH);
break;
default:
LOG_J(LS_WARNING, port_) << "Received TURN allocate error response"
@@ -1215,7 +1216,8 @@
// For TCP, we can't close the original Tcp socket during handling a 300 as
// we're still inside that socket's event handler. Doing so will cause
// deadlock.
- port_->thread()->Post(port_, TurnPort::MSG_TRY_ALTERNATE_SERVER);
+ port_->thread()->Post(RTC_FROM_HERE, port_,
+ TurnPort::MSG_TRY_ALTERNATE_SERVER);
}
TurnRefreshRequest::TurnRefreshRequest(TurnPort* port)
diff --git a/webrtc/p2p/base/turnport_unittest.cc b/webrtc/p2p/base/turnport_unittest.cc
index 15a7954..0e415a2 100644
--- a/webrtc/p2p/base/turnport_unittest.cc
+++ b/webrtc/p2p/base/turnport_unittest.cc
@@ -1058,7 +1058,7 @@
ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout);
EXPECT_TRUE(turn_port_->Candidates().empty());
turn_port_.reset();
- rtc::Thread::Current()->Post(this, MSG_TESTFINISH);
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH);
// Waiting for above message to be processed.
ASSERT_TRUE_WAIT(test_finish_, kTimeout);
EXPECT_EQ(last_fd_count, GetFDCount());
diff --git a/webrtc/p2p/base/turnserver.cc b/webrtc/p2p/base/turnserver.cc
index 16df6f9..3e9d669 100644
--- a/webrtc/p2p/base/turnserver.cc
+++ b/webrtc/p2p/base/turnserver.cc
@@ -631,7 +631,8 @@
// Figure out the lifetime and start the allocation timer.
int lifetime_secs = ComputeLifetime(msg);
- thread_->PostDelayed(lifetime_secs * 1000, this, MSG_ALLOCATION_TIMEOUT);
+ thread_->PostDelayed(RTC_FROM_HERE, lifetime_secs * 1000, this,
+ MSG_ALLOCATION_TIMEOUT);
LOG_J(LS_INFO, this) << "Created allocation, lifetime=" << lifetime_secs;
@@ -659,7 +660,8 @@
// Reset the expiration timer.
thread_->Clear(this, MSG_ALLOCATION_TIMEOUT);
- thread_->PostDelayed(lifetime_secs * 1000, this, MSG_ALLOCATION_TIMEOUT);
+ thread_->PostDelayed(RTC_FROM_HERE, lifetime_secs * 1000, this,
+ MSG_ALLOCATION_TIMEOUT);
LOG_J(LS_INFO, this) << "Refreshed allocation, lifetime=" << lifetime_secs;
@@ -924,7 +926,8 @@
void TurnServerAllocation::Permission::Refresh() {
thread_->Clear(this, MSG_ALLOCATION_TIMEOUT);
- thread_->PostDelayed(kPermissionTimeout, this, MSG_ALLOCATION_TIMEOUT);
+ thread_->PostDelayed(RTC_FROM_HERE, kPermissionTimeout, this,
+ MSG_ALLOCATION_TIMEOUT);
}
void TurnServerAllocation::Permission::OnMessage(rtc::Message* msg) {
@@ -945,7 +948,8 @@
void TurnServerAllocation::Channel::Refresh() {
thread_->Clear(this, MSG_ALLOCATION_TIMEOUT);
- thread_->PostDelayed(kChannelTimeout, this, MSG_ALLOCATION_TIMEOUT);
+ thread_->PostDelayed(RTC_FROM_HERE, kChannelTimeout, this,
+ MSG_ALLOCATION_TIMEOUT);
}
void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) {
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
index 20fc84a..e39a440 100644
--- a/webrtc/p2p/client/basicportallocator.cc
+++ b/webrtc/p2p/client/basicportallocator.cc
@@ -199,13 +199,13 @@
}
running_ = true;
- network_thread_->Post(this, MSG_CONFIG_START);
+ network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_START);
}
void BasicPortAllocatorSession::StopGettingPorts() {
ASSERT(rtc::Thread::Current() == network_thread_);
running_ = false;
- network_thread_->Post(this, MSG_CONFIG_STOP);
+ network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_STOP);
ClearGettingPorts();
}
@@ -336,7 +336,7 @@
}
void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) {
- network_thread_->Post(this, MSG_CONFIG_READY, config);
+ network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_READY, config);
}
// Adds a configuration to the list.
@@ -381,7 +381,7 @@
void BasicPortAllocatorSession::AllocatePorts() {
ASSERT(rtc::Thread::Current() == network_thread_);
- network_thread_->Post(this, MSG_ALLOCATE);
+ network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE);
}
void BasicPortAllocatorSession::OnAllocate() {
@@ -491,7 +491,7 @@
}
}
if (done_signal_needed) {
- network_thread_->Post(this, MSG_SEQUENCEOBJECTS_CREATED);
+ network_thread_->Post(RTC_FROM_HERE, this, MSG_SEQUENCEOBJECTS_CREATED);
}
}
@@ -840,7 +840,7 @@
void AllocationSequence::Start() {
state_ = kRunning;
- session_->network_thread()->Post(this, MSG_ALLOCATION_PHASE);
+ session_->network_thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATION_PHASE);
}
void AllocationSequence::Stop() {
@@ -890,9 +890,9 @@
if (state() == kRunning) {
++phase_;
- session_->network_thread()->PostDelayed(
- session_->allocator()->step_delay(),
- this, MSG_ALLOCATION_PHASE);
+ session_->network_thread()->PostDelayed(RTC_FROM_HERE,
+ session_->allocator()->step_delay(),
+ this, MSG_ALLOCATION_PHASE);
} else {
// If all phases in AllocationSequence are completed, no allocation
// steps needed further. Canceling pending signal.
diff --git a/webrtc/p2p/client/socketmonitor.cc b/webrtc/p2p/client/socketmonitor.cc
index cc48c01..7975514 100644
--- a/webrtc/p2p/client/socketmonitor.cc
+++ b/webrtc/p2p/client/socketmonitor.cc
@@ -39,11 +39,11 @@
rate_ = milliseconds;
if (rate_ < 250)
rate_ = 250;
- worker_thread_->Post(this, MSG_MONITOR_START);
+ worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_START);
}
void ConnectionMonitor::Stop() {
- worker_thread_->Post(this, MSG_MONITOR_STOP);
+ worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP);
}
void ConnectionMonitor::OnMessage(rtc::Message *message) {
@@ -89,8 +89,8 @@
stats_getter_->GetConnectionStats(&connection_infos_);
// Signal the monitoring thread, start another poll timer
- monitoring_thread_->Post(this, MSG_MONITOR_SIGNAL);
- worker_thread_->PostDelayed(rate_, this, MSG_MONITOR_POLL);
+ monitoring_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL);
+ worker_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL);
}
} // namespace cricket
diff --git a/webrtc/p2p/quic/quicconnectionhelper.cc b/webrtc/p2p/quic/quicconnectionhelper.cc
index f9b4697..2b40820 100644
--- a/webrtc/p2p/quic/quicconnectionhelper.cc
+++ b/webrtc/p2p/quic/quicconnectionhelper.cc
@@ -59,7 +59,7 @@
if (delay_ms < 0) {
delay_ms = 0;
}
- thread_->PostDelayed(delay_ms, this);
+ thread_->PostDelayed(RTC_FROM_HERE, delay_ms, this);
}
void QuicAlarm::CancelImpl() {
diff --git a/webrtc/p2p/stunprober/stunprober.cc b/webrtc/p2p/stunprober/stunprober.cc
index 90dc60e..f32a200 100644
--- a/webrtc/p2p/stunprober/stunprober.cc
+++ b/webrtc/p2p/stunprober/stunprober.cc
@@ -323,7 +323,7 @@
// Deletion of AsyncResolverInterface can't be done in OnResolveResult which
// handles SignalDone.
invoker_.AsyncInvoke<void>(
- thread_,
+ RTC_FROM_HERE, thread_,
rtc::Bind(&rtc::AsyncResolverInterface::Destroy, resolver, false));
servers_.pop_back();
@@ -418,8 +418,8 @@
if (Done()) {
invoker_.AsyncInvokeDelayed<void>(
- thread_, rtc::Bind(&StunProber::ReportOnFinished, this, SUCCESS),
- timeout_ms_);
+ RTC_FROM_HERE, thread_,
+ rtc::Bind(&StunProber::ReportOnFinished, this, SUCCESS), timeout_ms_);
return;
}
if (should_send_next_request(now)) {
@@ -430,7 +430,8 @@
next_request_time_ms_ = now + interval_ms_;
}
invoker_.AsyncInvokeDelayed<void>(
- thread_, rtc::Bind(&StunProber::MaybeScheduleStunRequests, this),
+ RTC_FROM_HERE, thread_,
+ rtc::Bind(&StunProber::MaybeScheduleStunRequests, this),
get_wake_up_interval_ms());
}
diff --git a/webrtc/pc/audiomonitor.cc b/webrtc/pc/audiomonitor.cc
index 085ab93..9c610bc 100644
--- a/webrtc/pc/audiomonitor.cc
+++ b/webrtc/pc/audiomonitor.cc
@@ -35,11 +35,11 @@
rate_ = milliseconds;
if (rate_ < 100)
rate_ = 100;
- voice_channel_->worker_thread()->Post(this, MSG_MONITOR_START);
+ voice_channel_->worker_thread()->Post(RTC_FROM_HERE, this, MSG_MONITOR_START);
}
void AudioMonitor::Stop() {
- voice_channel_->worker_thread()->Post(this, MSG_MONITOR_STOP);
+ voice_channel_->worker_thread()->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP);
}
void AudioMonitor::OnMessage(rtc::Message *message) {
@@ -89,8 +89,9 @@
voice_channel_->GetActiveStreams_w(&audio_info_.active_streams);
// Signal the monitoring thread, start another poll timer
- monitoring_thread_->Post(this, MSG_MONITOR_SIGNAL);
- voice_channel_->worker_thread()->PostDelayed(rate_, this, MSG_MONITOR_POLL);
+ monitoring_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL);
+ voice_channel_->worker_thread()->PostDelayed(RTC_FROM_HERE, rate_, this,
+ MSG_MONITOR_POLL);
}
VoiceChannel *AudioMonitor::voice_channel() {
diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc
index be47646..6f980e1 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -207,7 +207,7 @@
// Note that we don't just call SetTransportChannel_n(nullptr) because that
// would call a pure virtual method which we can't do from a destructor.
network_thread_->Invoke<void>(
- Bind(&BaseChannel::DestroyTransportChannels_n, this));
+ RTC_FROM_HERE, Bind(&BaseChannel::DestroyTransportChannels_n, this));
LOG(LS_INFO) << "Destroyed channel";
}
@@ -245,6 +245,7 @@
bool BaseChannel::Init_w(const std::string* bundle_transport_name) {
if (!network_thread_->Invoke<bool>(
+ RTC_FROM_HERE,
Bind(&BaseChannel::InitNetwork_n, this, bundle_transport_name))) {
return false;
}
@@ -281,12 +282,12 @@
// functions, so need to stop this process in Deinit that is called in
// derived classes destructor.
network_thread_->Invoke<void>(
- Bind(&BaseChannel::DisconnectTransportChannels_n, this));
+ RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this));
}
bool BaseChannel::SetTransport(const std::string& transport_name) {
return network_thread_->Invoke<bool>(
- Bind(&BaseChannel::SetTransport_n, this, transport_name));
+ RTC_FROM_HERE, Bind(&BaseChannel::SetTransport_n, this, transport_name));
}
bool BaseChannel::SetTransport_n(const std::string& transport_name) {
@@ -430,44 +431,47 @@
}
bool BaseChannel::Enable(bool enable) {
- worker_thread_->Invoke<void>(Bind(
- enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
- this));
+ worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
+ Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
+ this));
return true;
}
bool BaseChannel::AddRecvStream(const StreamParams& sp) {
- return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp));
+ return InvokeOnWorker(RTC_FROM_HERE,
+ Bind(&BaseChannel::AddRecvStream_w, this, sp));
}
bool BaseChannel::RemoveRecvStream(uint32_t ssrc) {
- return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc));
+ return InvokeOnWorker(RTC_FROM_HERE,
+ Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc));
}
bool BaseChannel::AddSendStream(const StreamParams& sp) {
return InvokeOnWorker(
- Bind(&MediaChannel::AddSendStream, media_channel(), sp));
+ RTC_FROM_HERE, Bind(&MediaChannel::AddSendStream, media_channel(), sp));
}
bool BaseChannel::RemoveSendStream(uint32_t ssrc) {
- return InvokeOnWorker(
- Bind(&MediaChannel::RemoveSendStream, media_channel(), ssrc));
+ return InvokeOnWorker(RTC_FROM_HERE, Bind(&MediaChannel::RemoveSendStream,
+ media_channel(), ssrc));
}
bool BaseChannel::SetLocalContent(const MediaContentDescription* content,
ContentAction action,
std::string* error_desc) {
TRACE_EVENT0("webrtc", "BaseChannel::SetLocalContent");
- return InvokeOnWorker(Bind(&BaseChannel::SetLocalContent_w,
- this, content, action, error_desc));
+ return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetLocalContent_w,
+ this, content, action, error_desc));
}
bool BaseChannel::SetRemoteContent(const MediaContentDescription* content,
ContentAction action,
std::string* error_desc) {
TRACE_EVENT0("webrtc", "BaseChannel::SetRemoteContent");
- return InvokeOnWorker(Bind(&BaseChannel::SetRemoteContent_w,
- this, content, action, error_desc));
+ return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetRemoteContent_w,
+ this, content, action, error_desc));
}
void BaseChannel::StartConnectionMonitor(int cms) {
@@ -507,7 +511,7 @@
return enabled() && IsReceiveContentDirection(remote_content_direction_) &&
IsSendContentDirection(local_content_direction_) &&
network_thread_->Invoke<bool>(
- Bind(&BaseChannel::IsTransportReadyToSend_n, this));
+ RTC_FROM_HERE, Bind(&BaseChannel::IsTransportReadyToSend_n, this));
}
bool BaseChannel::IsTransportReadyToSend_n() const {
@@ -528,7 +532,7 @@
int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
int value) {
return network_thread_->Invoke<int>(
- Bind(&BaseChannel::SetOption_n, this, type, opt, value));
+ RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
}
int BaseChannel::SetOption_n(SocketType type,
@@ -609,8 +613,9 @@
last_sent_packet_id);
}
invoker_.AsyncInvoke<void>(
- worker_thread_, Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_,
- transport_name, network_route));
+ RTC_FROM_HERE, worker_thread_,
+ Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
+ network_route));
}
void BaseChannel::SetReadyToSend(bool rtcp, bool ready) {
@@ -627,7 +632,7 @@
(rtcp_ready_to_send_ || !rtcp_transport_channel_));
invoker_.AsyncInvoke<void>(
- worker_thread_,
+ RTC_FROM_HERE, worker_thread_,
Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send));
}
@@ -653,7 +658,7 @@
SendPacketMessageData* data = new SendPacketMessageData;
data->packet = std::move(*packet);
data->options = options;
- network_thread_->Post(this, message_id, data);
+ network_thread_->Post(RTC_FROM_HERE, this, message_id, data);
return true;
}
TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
@@ -788,7 +793,7 @@
// indicates the media has started flowing.
if (!has_received_packet_ && !rtcp) {
has_received_packet_ = true;
- signaling_thread()->Post(this, MSG_FIRSTPACKETRECEIVED);
+ signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED);
}
// Unprotect the packet, if needed.
@@ -838,7 +843,7 @@
}
invoker_.AsyncInvoke<void>(
- worker_thread_,
+ RTC_FROM_HERE, worker_thread_,
Bind(&BaseChannel::OnPacketReceived, this, rtcp, *packet, packet_time));
}
@@ -942,7 +947,7 @@
void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) {
RTC_DCHECK(network_thread_->IsCurrent());
invoker_.AsyncInvoke<void>(
- signaling_thread(),
+ RTC_FROM_HERE, signaling_thread(),
Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp));
}
@@ -1101,8 +1106,8 @@
// Cache secure_required_ for belt and suspenders check on SendPacket
return network_thread_->Invoke<bool>(
- Bind(&BaseChannel::SetRtpTransportParameters_n, this, content, action,
- src, error_desc));
+ RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this,
+ content, action, src, error_desc));
}
bool BaseChannel::SetRtpTransportParameters_n(
@@ -1188,7 +1193,8 @@
}
void BaseChannel::ActivateRtcpMux() {
- network_thread_->Invoke<void>(Bind(&BaseChannel::ActivateRtcpMux_n, this));
+ network_thread_->Invoke<void>(RTC_FROM_HERE,
+ Bind(&BaseChannel::ActivateRtcpMux_n, this));
}
void BaseChannel::ActivateRtcpMux_n() {
@@ -1414,8 +1420,9 @@
int rtp_abs_sendtime_extn_id =
send_time_extension ? send_time_extension->id : -1;
invoker_.AsyncInvoke<void>(
- network_thread_, Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n,
- this, rtp_abs_sendtime_extn_id));
+ RTC_FROM_HERE, network_thread_,
+ Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this,
+ rtp_abs_sendtime_extn_id));
#endif
}
@@ -1451,7 +1458,8 @@
rtc::MessageList rtcp_messages;
network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages);
for (const auto& message : rtcp_messages) {
- network_thread_->Send(this, MSG_SEND_RTCP_PACKET, message.pdata);
+ network_thread_->Send(RTC_FROM_HERE, this, MSG_SEND_RTCP_PACKET,
+ message.pdata);
}
}
@@ -1459,7 +1467,7 @@
const rtc::SentPacket& sent_packet) {
RTC_DCHECK(network_thread_->IsCurrent());
invoker_.AsyncInvoke<void>(
- worker_thread_,
+ RTC_FROM_HERE, worker_thread_,
rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet));
}
@@ -1504,7 +1512,8 @@
bool enable,
const AudioOptions* options,
AudioSource* source) {
- return InvokeOnWorker(Bind(&VoiceMediaChannel::SetAudioSend, media_channel(),
+ return InvokeOnWorker(RTC_FROM_HERE,
+ Bind(&VoiceMediaChannel::SetAudioSend, media_channel(),
ssrc, enable, options, source));
}
@@ -1516,8 +1525,8 @@
void VoiceChannel::SetEarlyMedia(bool enable) {
if (enable) {
// Start the early media timeout
- worker_thread()->PostDelayed(kEarlyMediaTimeout, this,
- MSG_EARLYMEDIATIMEOUT);
+ worker_thread()->PostDelayed(RTC_FROM_HERE, kEarlyMediaTimeout, this,
+ MSG_EARLYMEDIATIMEOUT);
} else {
// Stop the timeout if currently going.
worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT);
@@ -1525,20 +1534,20 @@
}
bool VoiceChannel::CanInsertDtmf() {
- return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf,
- media_channel()));
+ return InvokeOnWorker(
+ RTC_FROM_HERE, Bind(&VoiceMediaChannel::CanInsertDtmf, media_channel()));
}
bool VoiceChannel::InsertDtmf(uint32_t ssrc,
int event_code,
int duration) {
- return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this,
- ssrc, event_code, duration));
+ return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceChannel::InsertDtmf_w, this,
+ ssrc, event_code, duration));
}
bool VoiceChannel::SetOutputVolume(uint32_t ssrc, double volume) {
- return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputVolume,
- media_channel(), ssrc, volume));
+ return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceMediaChannel::SetOutputVolume,
+ media_channel(), ssrc, volume));
}
void VoiceChannel::SetRawAudioSink(
@@ -1547,12 +1556,13 @@
// We need to work around Bind's lack of support for unique_ptr and ownership
// passing. So we invoke to our own little routine that gets a pointer to
// our local variable. This is OK since we're synchronously invoking.
- InvokeOnWorker(Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink));
+ InvokeOnWorker(RTC_FROM_HERE,
+ Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink));
}
webrtc::RtpParameters VoiceChannel::GetRtpSendParameters(uint32_t ssrc) const {
return worker_thread()->Invoke<webrtc::RtpParameters>(
- Bind(&VoiceChannel::GetRtpSendParameters_w, this, ssrc));
+ RTC_FROM_HERE, Bind(&VoiceChannel::GetRtpSendParameters_w, this, ssrc));
}
webrtc::RtpParameters VoiceChannel::GetRtpSendParameters_w(
@@ -1564,6 +1574,7 @@
uint32_t ssrc,
const webrtc::RtpParameters& parameters) {
return InvokeOnWorker(
+ RTC_FROM_HERE,
Bind(&VoiceChannel::SetRtpSendParameters_w, this, ssrc, parameters));
}
@@ -1575,6 +1586,7 @@
webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters(
uint32_t ssrc) const {
return worker_thread()->Invoke<webrtc::RtpParameters>(
+ RTC_FROM_HERE,
Bind(&VoiceChannel::GetRtpReceiveParameters_w, this, ssrc));
}
@@ -1587,6 +1599,7 @@
uint32_t ssrc,
const webrtc::RtpParameters& parameters) {
return InvokeOnWorker(
+ RTC_FROM_HERE,
Bind(&VoiceChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
}
@@ -1596,8 +1609,8 @@
}
bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
- return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats,
- media_channel(), stats));
+ return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceMediaChannel::GetStats,
+ media_channel(), stats));
}
void VoiceChannel::StartMediaMonitor(int cms) {
@@ -1661,7 +1674,7 @@
void BaseChannel::ChangeState() {
RTC_DCHECK(network_thread_->IsCurrent());
- invoker_.AsyncInvoke<void>(worker_thread_,
+ invoker_.AsyncInvoke<void>(RTC_FROM_HERE, worker_thread_,
Bind(&BaseChannel::ChangeState_w, this));
}
@@ -1867,6 +1880,7 @@
bool VideoChannel::SetSink(uint32_t ssrc,
rtc::VideoSinkInterface<VideoFrame>* sink) {
worker_thread()->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&VideoMediaChannel::SetSink, media_channel(), ssrc, sink));
return true;
}
@@ -1876,13 +1890,14 @@
bool mute,
const VideoOptions* options,
rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
- return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
+ return InvokeOnWorker(RTC_FROM_HERE,
+ Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
ssrc, mute, options, source));
}
webrtc::RtpParameters VideoChannel::GetRtpSendParameters(uint32_t ssrc) const {
return worker_thread()->Invoke<webrtc::RtpParameters>(
- Bind(&VideoChannel::GetRtpSendParameters_w, this, ssrc));
+ RTC_FROM_HERE, Bind(&VideoChannel::GetRtpSendParameters_w, this, ssrc));
}
webrtc::RtpParameters VideoChannel::GetRtpSendParameters_w(
@@ -1894,6 +1909,7 @@
uint32_t ssrc,
const webrtc::RtpParameters& parameters) {
return InvokeOnWorker(
+ RTC_FROM_HERE,
Bind(&VideoChannel::SetRtpSendParameters_w, this, ssrc, parameters));
}
@@ -1905,6 +1921,7 @@
webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters(
uint32_t ssrc) const {
return worker_thread()->Invoke<webrtc::RtpParameters>(
+ RTC_FROM_HERE,
Bind(&VideoChannel::GetRtpReceiveParameters_w, this, ssrc));
}
@@ -1917,6 +1934,7 @@
uint32_t ssrc,
const webrtc::RtpParameters& parameters) {
return InvokeOnWorker(
+ RTC_FROM_HERE,
Bind(&VideoChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
}
@@ -1938,8 +1956,8 @@
}
bool VideoChannel::GetStats(VideoMediaInfo* stats) {
- return InvokeOnWorker(
- Bind(&VideoMediaChannel::GetStats, media_channel(), stats));
+ return InvokeOnWorker(RTC_FROM_HERE, Bind(&VideoMediaChannel::GetStats,
+ media_channel(), stats));
}
void VideoChannel::StartMediaMonitor(int cms) {
@@ -2131,8 +2149,9 @@
bool DataChannel::SendData(const SendDataParams& params,
const rtc::CopyOnWriteBuffer& payload,
SendDataResult* result) {
- return InvokeOnWorker(Bind(&DataMediaChannel::SendData,
- media_channel(), params, payload, result));
+ return InvokeOnWorker(
+ RTC_FROM_HERE, Bind(&DataMediaChannel::SendData, media_channel(), params,
+ payload, result));
}
const ContentInfo* DataChannel::GetFirstContent(
@@ -2381,21 +2400,21 @@
const ReceiveDataParams& params, const char* data, size_t len) {
DataReceivedMessageData* msg = new DataReceivedMessageData(
params, data, len);
- signaling_thread()->Post(this, MSG_DATARECEIVED, msg);
+ signaling_thread()->Post(RTC_FROM_HERE, this, MSG_DATARECEIVED, msg);
}
void DataChannel::OnDataChannelError(uint32_t ssrc,
DataMediaChannel::Error err) {
DataChannelErrorMessageData* data = new DataChannelErrorMessageData(
ssrc, err);
- signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data);
+ signaling_thread()->Post(RTC_FROM_HERE, this, MSG_CHANNEL_ERROR, data);
}
void DataChannel::OnDataChannelReadyToSend(bool writable) {
// This is usded for congestion control to indicate that the stream is ready
// to send by the MediaChannel, as opposed to OnReadyToSend, which indicates
// that the transport channel is ready.
- signaling_thread()->Post(this, MSG_READYTOSENDDATA,
+ signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
new DataChannelReadyToSendMessageData(writable));
}
@@ -2410,7 +2429,8 @@
void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
rtc::TypedMessageData<uint32_t>* message =
new rtc::TypedMessageData<uint32_t>(sid);
- signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
+ signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY,
+ message);
}
} // namespace cricket
diff --git a/webrtc/pc/channel.h b/webrtc/pc/channel.h
index 348dbe2..f994bda 100644
--- a/webrtc/pc/channel.h
+++ b/webrtc/pc/channel.h
@@ -308,8 +308,9 @@
// Helper function for invoking bool-returning methods on the worker thread.
template <class FunctorT>
- bool InvokeOnWorker(const FunctorT& functor) {
- return worker_thread_->Invoke<bool>(functor);
+ bool InvokeOnWorker(const rtc::Location& posted_from,
+ const FunctorT& functor) {
+ return worker_thread_->Invoke<bool>(posted_from, functor);
}
private:
diff --git a/webrtc/pc/channel_unittest.cc b/webrtc/pc/channel_unittest.cc
index 57a1d75..0e56652 100644
--- a/webrtc/pc/channel_unittest.cc
+++ b/webrtc/pc/channel_unittest.cc
@@ -268,11 +268,13 @@
cricket::FakeTransport* GetTransport1() {
std::string name = channel1_->content_name();
return network_thread_->Invoke<cricket::FakeTransport*>(
+ RTC_FROM_HERE,
[this, name] { return transport_controller1_->GetTransport_n(name); });
}
cricket::FakeTransport* GetTransport2() {
std::string name = channel2_->content_name();
return network_thread_->Invoke<cricket::FakeTransport*>(
+ RTC_FROM_HERE,
[this, name] { return transport_controller2_->GetTransport_n(name); });
}
@@ -400,7 +402,7 @@
: thread_(rtc::Thread::Create()),
task_(new rtc::FunctorMessageHandler<void, FunctorT>(functor)) {
thread_->Start();
- thread_->Post(task_.get());
+ thread_->Post(RTC_FROM_HERE, task_.get());
}
~ScopedCallThread() { thread_->Stop(); }
@@ -911,7 +913,7 @@
ASSERT_TRUE(media_channel1);
media_channel1->set_num_network_route_changes(0);
- network_thread_->Invoke<void>([transport_channel1] {
+ network_thread_->Invoke<void>(RTC_FROM_HERE, [transport_channel1] {
// The transport channel becomes disconnected.
transport_channel1->SignalSelectedCandidatePairChanged(transport_channel1,
nullptr, -1);
@@ -921,8 +923,9 @@
EXPECT_FALSE(media_channel1->last_network_route().connected);
media_channel1->set_num_network_route_changes(0);
- network_thread_->Invoke<void>([this, transport_channel1, media_channel1,
- kLocalNetId, kRemoteNetId, kLastPacketId] {
+ network_thread_->Invoke<void>(RTC_FROM_HERE, [this, transport_channel1,
+ media_channel1, kLocalNetId,
+ kRemoteNetId, kLastPacketId] {
// The transport channel becomes connected.
rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */);
rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */);
@@ -1455,7 +1458,7 @@
// Lose writability, which should fail.
network_thread_->Invoke<void>(
- [this] { GetTransport1()->SetWritable(false); });
+ RTC_FROM_HERE, [this] { GetTransport1()->SetWritable(false); });
SendRtp1();
SendRtp2();
WaitForThreads();
@@ -1464,7 +1467,7 @@
// Regain writability
network_thread_->Invoke<void>(
- [this] { GetTransport1()->SetWritable(true); });
+ RTC_FROM_HERE, [this] { GetTransport1()->SetWritable(true); });
EXPECT_TRUE(media_channel1_->sending());
SendRtp1();
SendRtp2();
@@ -1476,7 +1479,7 @@
// Lose writability completely
network_thread_->Invoke<void>(
- [this] { GetTransport1()->SetDestination(NULL); });
+ RTC_FROM_HERE, [this] { GetTransport1()->SetDestination(NULL); });
EXPECT_TRUE(media_channel1_->sending());
// Should fail also.
@@ -1487,8 +1490,9 @@
EXPECT_TRUE(CheckNoRtp2());
// Gain writability back
- network_thread_->Invoke<void>(
- [this] { GetTransport1()->SetDestination(GetTransport2()); });
+ network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
+ GetTransport1()->SetDestination(GetTransport2());
+ });
EXPECT_TRUE(media_channel1_->sending());
SendRtp1();
SendRtp2();
@@ -1788,7 +1792,7 @@
error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
- network_thread_->Invoke<void>([this] {
+ network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
cricket::TransportChannel* transport_channel =
channel2_->transport_channel();
transport_channel->SignalReadPacket(
@@ -1805,11 +1809,13 @@
TransportChannel* rtcp = channel1_->rtcp_transport_channel();
EXPECT_FALSE(media_channel1_->ready_to_send());
- network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); });
+ network_thread_->Invoke<void>(RTC_FROM_HERE,
+ [rtp] { rtp->SignalReadyToSend(rtp); });
WaitForThreads();
EXPECT_FALSE(media_channel1_->ready_to_send());
- network_thread_->Invoke<void>([rtcp] { rtcp->SignalReadyToSend(rtcp); });
+ network_thread_->Invoke<void>(RTC_FROM_HERE,
+ [rtcp] { rtcp->SignalReadyToSend(rtcp); });
WaitForThreads();
// MediaChannel::OnReadyToSend only be called when both rtp and rtcp
// channel are ready to send.
@@ -1817,23 +1823,23 @@
// rtp channel becomes not ready to send will be propagated to mediachannel
network_thread_->Invoke<void>(
- [this] { channel1_->SetReadyToSend(false, false); });
+ RTC_FROM_HERE, [this] { channel1_->SetReadyToSend(false, false); });
WaitForThreads();
EXPECT_FALSE(media_channel1_->ready_to_send());
network_thread_->Invoke<void>(
- [this] { channel1_->SetReadyToSend(false, true); });
+ RTC_FROM_HERE, [this] { channel1_->SetReadyToSend(false, true); });
WaitForThreads();
EXPECT_TRUE(media_channel1_->ready_to_send());
// rtcp channel becomes not ready to send will be propagated to mediachannel
network_thread_->Invoke<void>(
- [this] { channel1_->SetReadyToSend(true, false); });
+ RTC_FROM_HERE, [this] { channel1_->SetReadyToSend(true, false); });
WaitForThreads();
EXPECT_FALSE(media_channel1_->ready_to_send());
network_thread_->Invoke<void>(
- [this] { channel1_->SetReadyToSend(true, true); });
+ RTC_FROM_HERE, [this] { channel1_->SetReadyToSend(true, true); });
WaitForThreads();
EXPECT_TRUE(media_channel1_->ready_to_send());
}
@@ -1851,12 +1857,13 @@
EXPECT_FALSE(media_channel1_->ready_to_send());
// In the case of rtcp mux, the SignalReadyToSend() from rtp channel
// should trigger the MediaChannel's OnReadyToSend.
- network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); });
+ network_thread_->Invoke<void>(RTC_FROM_HERE,
+ [rtp] { rtp->SignalReadyToSend(rtp); });
WaitForThreads();
EXPECT_TRUE(media_channel1_->ready_to_send());
network_thread_->Invoke<void>(
- [this] { channel1_->SetReadyToSend(false, false); });
+ RTC_FROM_HERE, [this] { channel1_->SetReadyToSend(false, false); });
WaitForThreads();
EXPECT_FALSE(media_channel1_->ready_to_send());
}
@@ -1919,13 +1926,14 @@
void WaitForThreads(rtc::ArrayView<rtc::Thread*> threads) {
// |threads| and current thread post packets to network thread.
for (rtc::Thread* thread : threads) {
- thread->Invoke<void>([thread] { ProcessThreadQueue(thread); });
+ thread->Invoke<void>(RTC_FROM_HERE,
+ [thread] { ProcessThreadQueue(thread); });
}
ProcessThreadQueue(rtc::Thread::Current());
// Network thread move them around and post back to worker = current thread.
if (!network_thread_->IsCurrent()) {
network_thread_->Invoke<void>(
- [this] { ProcessThreadQueue(network_thread_); });
+ RTC_FROM_HERE, [this] { ProcessThreadQueue(network_thread_); });
}
// Worker thread = current Thread process received messages.
ProcessThreadQueue(rtc::Thread::Current());
diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc
index 56dd135..334a712 100644
--- a/webrtc/pc/channelmanager.cc
+++ b/webrtc/pc/channelmanager.cc
@@ -81,8 +81,8 @@
}
// The media engine needs to be deleted on the worker thread for thread safe
// destruction,
- worker_thread_->Invoke<void>(Bind(
- &ChannelManager::DestructorDeletes_w, this));
+ worker_thread_->Invoke<void>(
+ RTC_FROM_HERE, Bind(&ChannelManager::DestructorDeletes_w, this));
}
bool ChannelManager::SetVideoRtxEnabled(bool enable) {
@@ -150,11 +150,12 @@
if (!network_thread_->IsCurrent()) {
// Do not allow invoking calls to other threads on the network thread.
network_thread_->Invoke<bool>(
+ RTC_FROM_HERE,
rtc::Bind(&rtc::Thread::SetAllowBlockingCalls, network_thread_, false));
}
initialized_ = worker_thread_->Invoke<bool>(
- Bind(&ChannelManager::InitMediaEngine_w, this));
+ RTC_FROM_HERE, Bind(&ChannelManager::InitMediaEngine_w, this));
ASSERT(initialized_);
if (!initialized_) {
return false;
@@ -181,7 +182,8 @@
if (!initialized_) {
return;
}
- worker_thread_->Invoke<void>(Bind(&ChannelManager::Terminate_w, this));
+ worker_thread_->Invoke<void>(RTC_FROM_HERE,
+ Bind(&ChannelManager::Terminate_w, this));
initialized_ = false;
}
@@ -209,9 +211,9 @@
bool rtcp,
const AudioOptions& options) {
return worker_thread_->Invoke<VoiceChannel*>(
- Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller,
- transport_controller, content_name, bundle_transport_name, rtcp,
- options));
+ RTC_FROM_HERE, Bind(&ChannelManager::CreateVoiceChannel_w, this,
+ media_controller, transport_controller, content_name,
+ bundle_transport_name, rtcp, options));
}
VoiceChannel* ChannelManager::CreateVoiceChannel_w(
@@ -244,6 +246,7 @@
TRACE_EVENT0("webrtc", "ChannelManager::DestroyVoiceChannel");
if (voice_channel) {
worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel));
}
}
@@ -270,9 +273,9 @@
bool rtcp,
const VideoOptions& options) {
return worker_thread_->Invoke<VideoChannel*>(
- Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller,
- transport_controller, content_name, bundle_transport_name, rtcp,
- options));
+ RTC_FROM_HERE, Bind(&ChannelManager::CreateVideoChannel_w, this,
+ media_controller, transport_controller, content_name,
+ bundle_transport_name, rtcp, options));
}
VideoChannel* ChannelManager::CreateVideoChannel_w(
@@ -306,6 +309,7 @@
TRACE_EVENT0("webrtc", "ChannelManager::DestroyVideoChannel");
if (video_channel) {
worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&ChannelManager::DestroyVideoChannel_w, this, video_channel));
}
}
@@ -332,6 +336,7 @@
bool rtcp,
DataChannelType channel_type) {
return worker_thread_->Invoke<DataChannel*>(
+ RTC_FROM_HERE,
Bind(&ChannelManager::CreateDataChannel_w, this, transport_controller,
content_name, bundle_transport_name, rtcp, channel_type));
}
@@ -368,6 +373,7 @@
TRACE_EVENT0("webrtc", "ChannelManager::DestroyDataChannel");
if (data_channel) {
worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&ChannelManager::DestroyDataChannel_w, this, data_channel));
}
}
@@ -391,6 +397,7 @@
return false;
}
return worker_thread_->Invoke<bool>(
+ RTC_FROM_HERE,
Bind(&MediaEngineInterface::GetOutputVolume, media_engine_.get(), level));
}
@@ -398,8 +405,8 @@
bool ret = level >= 0 && level <= 255;
if (initialized_) {
ret &= worker_thread_->Invoke<bool>(
- Bind(&MediaEngineInterface::SetOutputVolume,
- media_engine_.get(), level));
+ RTC_FROM_HERE, Bind(&MediaEngineInterface::SetOutputVolume,
+ media_engine_.get(), level));
}
if (ret) {
@@ -412,25 +419,27 @@
bool ChannelManager::StartAecDump(rtc::PlatformFile file,
int64_t max_size_bytes) {
- return worker_thread_->Invoke<bool>(Bind(&MediaEngineInterface::StartAecDump,
- media_engine_.get(), file,
- max_size_bytes));
+ return worker_thread_->Invoke<bool>(
+ RTC_FROM_HERE, Bind(&MediaEngineInterface::StartAecDump,
+ media_engine_.get(), file, max_size_bytes));
}
void ChannelManager::StopAecDump() {
worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&MediaEngineInterface::StopAecDump, media_engine_.get()));
}
bool ChannelManager::StartRtcEventLog(rtc::PlatformFile file,
int64_t max_size_bytes) {
return worker_thread_->Invoke<bool>(
- Bind(&MediaEngineInterface::StartRtcEventLog, media_engine_.get(), file,
- max_size_bytes));
+ RTC_FROM_HERE, Bind(&MediaEngineInterface::StartRtcEventLog,
+ media_engine_.get(), file, max_size_bytes));
}
void ChannelManager::StopRtcEventLog() {
worker_thread_->Invoke<void>(
+ RTC_FROM_HERE,
Bind(&MediaEngineInterface::StopRtcEventLog, media_engine_.get()));
}
diff --git a/webrtc/pc/mediamonitor.cc b/webrtc/pc/mediamonitor.cc
index 066094d..5ed68fa 100644
--- a/webrtc/pc/mediamonitor.cc
+++ b/webrtc/pc/mediamonitor.cc
@@ -37,11 +37,11 @@
rate_ = milliseconds;
if (rate_ < 100)
rate_ = 100;
- worker_thread_->Post(this, MSG_MONITOR_START);
+ worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_START);
}
void MediaMonitor::Stop() {
- worker_thread_->Post(this, MSG_MONITOR_STOP);
+ worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP);
rate_ = 0;
}
@@ -84,8 +84,8 @@
GetStats();
// Signal the monitoring thread, start another poll timer
- monitor_thread_->Post(this, MSG_MONITOR_SIGNAL);
- worker_thread_->PostDelayed(rate_, this, MSG_MONITOR_POLL);
+ monitor_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL);
+ worker_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL);
}
} // namespace cricket
diff --git a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
index 4a0ecea..778d70b 100644
--- a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
+++ b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
@@ -624,7 +624,7 @@
// after it has successfully been signaled.
CVBufferRetain(image_buffer);
AVFoundationFrame frame(image_buffer, rtc::TimeNanos());
- _startThread->Post(this, kMessageTypeFrame,
+ _startThread->Post(RTC_FROM_HERE, this, kMessageTypeFrame,
new rtc::TypedMessageData<AVFoundationFrame>(frame));
}