Chromium Code Reviews| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 | 304 |
| 305 class AutoThread : public Thread { | 305 class AutoThread : public Thread { |
| 306 public: | 306 public: |
| 307 AutoThread(); | 307 AutoThread(); |
| 308 ~AutoThread() override; | 308 ~AutoThread() override; |
| 309 | 309 |
| 310 private: | 310 private: |
| 311 RTC_DISALLOW_COPY_AND_ASSIGN(AutoThread); | 311 RTC_DISALLOW_COPY_AND_ASSIGN(AutoThread); |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 // Provides an easy way to install/uninstall a socketserver on a thread. | 314 // AutoSocketServerThread automatically installs itself at |
| 315 class SocketServerScope { | 315 // construction uninstalls at destruction. If a Thread object is |
| 316 // already associated with the current OS thread, it is temporarily | |
| 317 // disassociated and restored by the destructor. | |
| 318 | |
| 319 class AutoSocketServerThread : public Thread { | |
|
tommi
2017/04/27 13:57:07
if this is only for tests, can we indicate that in
nisse-webrtc
2017/04/27 14:08:56
It's *almost* test-only ;-/
It's used by peerconn
| |
| 316 public: | 320 public: |
| 317 explicit SocketServerScope(SocketServer* ss) { | 321 explicit AutoSocketServerThread(SocketServer* ss); |
| 318 old_ss_ = Thread::Current()->socketserver(); | 322 ~AutoSocketServerThread() override; |
| 319 Thread::Current()->set_socketserver(ss); | |
| 320 } | |
| 321 ~SocketServerScope() { | |
| 322 Thread::Current()->set_socketserver(old_ss_); | |
| 323 } | |
| 324 | 323 |
| 325 private: | 324 private: |
| 326 SocketServer* old_ss_; | 325 private: |
|
tommi
2017/04/27 13:57:07
super private? :)
nisse-webrtc
2017/04/27 14:08:56
Top-secret! And deleted.
| |
| 326 rtc::Thread* old_thread_; | |
| 327 | 327 |
| 328 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketServerScope); | 328 RTC_DISALLOW_COPY_AND_ASSIGN(AutoSocketServerThread); |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 } // namespace rtc | 331 } // namespace rtc |
| 332 | 332 |
| 333 #endif // WEBRTC_BASE_THREAD_H_ | 333 #endif // WEBRTC_BASE_THREAD_H_ |
| OLD | NEW |