Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: webrtc/rtc_base/nethelpers.h

Issue 2915253002: Delete SignalThread class. (Closed)
Patch Set: Another TODO on moving to QueuedTask. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/rtc_base/messagequeue.cc ('k') | webrtc/rtc_base/nethelpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/rtc_base/nethelpers.h
diff --git a/webrtc/rtc_base/nethelpers.h b/webrtc/rtc_base/nethelpers.h
index 2d34f2df1f220c6d56a7fc9589f2284e63c9321b..99d0602943bab800162748228888b46aad856daf 100644
--- a/webrtc/rtc_base/nethelpers.h
+++ b/webrtc/rtc_base/nethelpers.h
@@ -19,19 +19,25 @@
#endif
#include <list>
+#include <memory>
#include "webrtc/base/asyncresolverinterface.h"
-#include "webrtc/base/signalthread.h"
+#include "webrtc/base/refcount.h"
+#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/socketaddress.h"
+#include "webrtc/base/thread_checker.h"
namespace rtc {
-class AsyncResolverTest;
+class Thread;
+class TaskQueue;
-// AsyncResolver will perform async DNS resolution, signaling the result on
-// the SignalDone from AsyncResolverInterface when the operation completes.
-class AsyncResolver : public SignalThread, public AsyncResolverInterface {
+// 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 {
public:
AsyncResolver();
~AsyncResolver() override;
@@ -42,16 +48,34 @@ class AsyncResolver : public SignalThread, public AsyncResolverInterface {
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_;
+ int error_ = -1;
};
// rtc namespaced wrappers for inet_ntop and inet_pton so we can avoid
« no previous file with comments | « webrtc/rtc_base/messagequeue.cc ('k') | webrtc/rtc_base/nethelpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698