Remove MessageHandler[AutoCleanup] dependency from StreamInterface.

This includes relying on related types such as MessageData and
PostEvent functionality inside the StreamInterface itself.

This affects mostly tests but OpenSSLStreamAdapter
requires special attention.

Bug: webrtc:11988
Change-Id: Ib5c895f1bdf77bb49e3162bd49718f8a98812d91
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185505
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32290}
This commit is contained in:
Tomas Gunnarsson
2020-10-02 12:54:10 +02:00
committed by Commit Bot
parent b33a7186e6
commit eb79dd9ffd
9 changed files with 86 additions and 67 deletions

View File

@ -26,6 +26,8 @@
#include "rtc_base/ssl_identity.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/stream.h"
#include "rtc_base/task_utils/pending_task_safety_flag.h"
#include "rtc_base/task_utils/to_queued_task.h"
#include "test/field_trial.h"
using ::testing::Combine;
@ -214,7 +216,15 @@ class SSLDummyStreamBase : public rtc::StreamInterface,
out_->Close();
}
protected:
private:
void PostEvent(int events, int err) {
thread_->PostTask(webrtc::ToQueuedTask(task_safety_, [this, events, err]() {
SignalEvent(this, events, err);
}));
}
webrtc::ScopedTaskSafety task_safety_;
rtc::Thread* const thread_ = rtc::Thread::Current();
SSLStreamAdapterTestBase* test_base_;
const std::string side_;
rtc::StreamInterface* in_;
@ -276,10 +286,17 @@ class BufferQueueStream : public rtc::StreamInterface {
protected:
void NotifyReadableForTest() { PostEvent(rtc::SE_READ, 0); }
void NotifyWritableForTest() { PostEvent(rtc::SE_WRITE, 0); }
private:
void PostEvent(int events, int err) {
thread_->PostTask(webrtc::ToQueuedTask(task_safety_, [this, events, err]() {
SignalEvent(this, events, err);
}));
}
rtc::Thread* const thread_ = rtc::Thread::Current();
webrtc::ScopedTaskSafety task_safety_;
rtc::BufferQueue buffer_;
};