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

Unified Diff: webrtc/base/thread_unittest.cc

Issue 1666863002: Fix race between Thread ctor/dtor and MessageQueueManager registrations. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added unittest. Created 4 years, 11 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/base/thread.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/thread_unittest.cc
diff --git a/webrtc/base/thread_unittest.cc b/webrtc/base/thread_unittest.cc
index 240ffc411f7435727597c48b4da659a0c2205c73..f930078c57a641cd6353df66b30461345c8921fb 100644
--- a/webrtc/base/thread_unittest.cc
+++ b/webrtc/base/thread_unittest.cc
@@ -13,6 +13,7 @@
#include "webrtc/base/event.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
+#include "webrtc/base/sigslot.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/thread.h"
@@ -377,6 +378,40 @@ TEST(ThreadTest, ThreeThreadsInvoke) {
EXPECT_TRUE_WAIT(thread_a_called.Get(), 2000);
}
+// Set the name on a thread when the underlying QueueDestroyed signal is
+// triggered. This causes an error if the object is already partially
+// destroyed.
+class SetNameOnSignalQueueDestroyedTester : public sigslot::has_slots<> {
+ public:
+ SetNameOnSignalQueueDestroyedTester(Thread* thread) : thread_(thread) {
+ thread->SignalQueueDestroyed.connect(
+ this, &SetNameOnSignalQueueDestroyedTester::OnQueueDestroyed);
+ }
+
+ void OnQueueDestroyed() {
+ thread_->SetName("foo", nullptr);
pthatcher1 2016/02/04 00:50:38 Can you leave a comment here, perhaps something li
joachim 2016/02/04 01:00:09 Done.
+ }
+
+ private:
+ Thread* thread_;
+};
+
+TEST(ThreadTest, SetNameOnSignalQueueDestroyed) {
+ Thread* thread1 = new Thread();
+ SetNameOnSignalQueueDestroyedTester tester1(thread1);
+ delete thread1;
+
+ Thread* thread2 = new AutoThread();
+ SetNameOnSignalQueueDestroyedTester tester2(thread2);
+ delete thread2;
+
+#if defined(WEBRTC_WIN)
+ Thread* thread3 = new ComThread();
+ SetNameOnSignalQueueDestroyedTester tester3(thread3);
+ delete thread3;
+#endif
+}
+
class AsyncInvokeTest : public testing::Test {
public:
void IntCallback(int value) {
« no previous file with comments | « webrtc/base/thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698