Revert of Delete SignalThread class. (patchset #20 id:380001 of https://codereview.webrtc.org/2915253002/ )
Reason for revert:
Seems to be causing new crashes, possibly because of changes to the "Destroy(false)" behavior. Will re-land after investigating these crashes more and addressing the root cause.
Original issue's description:
> Delete SignalThread class.
>
> Rewrite AsyncResolver to use PlatformThread directly, not
> SignalThread, and update includes of peerconnection client to not
> depend on signalthread.h.
>
> BUG=webrtc:6424,webrtc:7723
>
> Review-Url: https://codereview.webrtc.org/2915253002
> Cr-Commit-Position: refs/heads/master@{#18833}
> Committed: https://chromium.googlesource.com/external/webrtc/+/bc8feda1db02b2a9b501e4aa43926ca7e861b638
TBR=tommi@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
NOPRESUBMIT=true
NOTRY=true
BUG=webrtc:6424,webrtc:7723
Review-Url: https://codereview.webrtc.org/2979733002
Cr-Commit-Position: refs/heads/master@{#18980}
diff --git a/webrtc/rtc_base/nethelpers.h b/webrtc/rtc_base/nethelpers.h
index b5f0c01..d25879e 100644
--- a/webrtc/rtc_base/nethelpers.h
+++ b/webrtc/rtc_base/nethelpers.h
@@ -19,25 +19,19 @@
#endif
#include <list>
-#include <memory>
#include "webrtc/rtc_base/asyncresolverinterface.h"
-#include "webrtc/rtc_base/refcount.h"
-#include "webrtc/rtc_base/scoped_ref_ptr.h"
+#include "webrtc/rtc_base/signalthread.h"
#include "webrtc/rtc_base/sigslot.h"
#include "webrtc/rtc_base/socketaddress.h"
-#include "webrtc/rtc_base/thread_checker.h"
namespace rtc {
-class Thread;
-class TaskQueue;
+class AsyncResolverTest;
-// AsyncResolver will perform async DNS resolution, signaling the result on the
-// SignalDone from AsyncResolverInterface when the operation completes.
-// SignalDone is fired on the same thread on which the AsyncResolver was
-// constructed.
-class AsyncResolver : public AsyncResolverInterface {
+// AsyncResolver will perform async DNS resolution, signaling the result on
+// the SignalDone from AsyncResolverInterface when the operation completes.
+class AsyncResolver : public SignalThread, public AsyncResolverInterface {
public:
AsyncResolver();
~AsyncResolver() override;
@@ -48,34 +42,16 @@
void Destroy(bool wait) override;
const std::vector<IPAddress>& addresses() const { return addresses_; }
+ void set_error(int error) { error_ = error; }
+
+ protected:
+ void DoWork() override;
+ void OnWorkDone() override;
private:
- void ResolveDone(int error, std::vector<IPAddress> addresses);
-
- class Trampoline : public RefCountInterface {
- public:
- Trampoline(AsyncResolver* resolver) : resolver(resolver) {}
- // Points back to the resolver, as long as it is alive. Cleared
- // by the AsyncResolver destructor.
- AsyncResolver* resolver;
- };
-
- // |state_| is non-null while resolution is pending, i.e., set
- // non-null by Start() and cleared by ResolveDone(). The destructor
- // clears state_->resolver (assuming |state_| is non-null), to
- // indicate that the resolver can no longer be accessed.
- scoped_refptr<Trampoline> state_ ACCESS_ON(construction_thread_);
-
- Thread* const construction_thread_;
- // Set to true when Destroy() can't delete the object immediately.
- // Indicate that the ResolveDone method is now responsible for
- // deletion. method should delete the object.
- bool destroyed_ = false;
- // Queue used only for a single task.
- std::unique_ptr<TaskQueue> resolver_queue_;
SocketAddress addr_;
std::vector<IPAddress> addresses_;
- int error_ = -1;
+ int error_;
};
// rtc namespaced wrappers for inet_ntop and inet_pton so we can avoid