OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 AutoThread::~AutoThread() { | 524 AutoThread::~AutoThread() { |
525 Stop(); | 525 Stop(); |
526 if (ThreadManager::Instance()->CurrentThread() == this) { | 526 if (ThreadManager::Instance()->CurrentThread() == this) { |
527 ThreadManager::Instance()->SetCurrentThread(nullptr); | 527 ThreadManager::Instance()->SetCurrentThread(nullptr); |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
| 531 AutoSocketServerThread::AutoSocketServerThread(SocketServer* ss) |
| 532 : Thread(ss) { |
| 533 old_thread_ = ThreadManager::Instance()->CurrentThread(); |
| 534 rtc::ThreadManager::Instance()->SetCurrentThread(this); |
| 535 if (old_thread_) { |
| 536 MessageQueueManager::Remove(old_thread_); |
| 537 } |
| 538 } |
| 539 |
| 540 AutoSocketServerThread::~AutoSocketServerThread() { |
| 541 RTC_DCHECK(ThreadManager::Instance()->CurrentThread() == this); |
| 542 // Some tests post destroy messages to this thread. To avoid memory |
| 543 // leaks, we have to process those messages. In particular |
| 544 // P2PTransportChannelPingTest, relying on the message posted in |
| 545 // cricket::Connection::Destroy. |
| 546 ProcessMessages(0); |
| 547 rtc::ThreadManager::Instance()->SetCurrentThread(old_thread_); |
| 548 if (old_thread_) { |
| 549 MessageQueueManager::Add(old_thread_); |
| 550 } |
| 551 } |
| 552 |
531 } // namespace rtc | 553 } // namespace rtc |
OLD | NEW |