| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 return true; | 212 return true; |
| 213 } | 213 } |
| 214 | 214 |
| 215 bool Thread::Start(Runnable* runnable) { | 215 bool Thread::Start(Runnable* runnable) { |
| 216 ASSERT(owned_); | 216 ASSERT(owned_); |
| 217 if (!owned_) return false; | 217 if (!owned_) return false; |
| 218 ASSERT(!running()); | 218 ASSERT(!running()); |
| 219 if (running()) return false; | 219 if (running()) return false; |
| 220 | 220 |
| 221 Restart(); // reset IsQuitting() if the thread is being restarted | 221 Restart(); // reset fStop_ if the thread is being restarted |
| 222 | 222 |
| 223 // Make sure that ThreadManager is created on the main thread before | 223 // Make sure that ThreadManager is created on the main thread before |
| 224 // we start a new thread. | 224 // we start a new thread. |
| 225 ThreadManager::Instance(); | 225 ThreadManager::Instance(); |
| 226 | 226 |
| 227 ThreadInit* init = new ThreadInit; | 227 ThreadInit* init = new ThreadInit; |
| 228 init->thread = this; | 228 init->thread = this; |
| 229 init->runnable = runnable; | 229 init->runnable = runnable; |
| 230 #if defined(WEBRTC_WIN) | 230 #if defined(WEBRTC_WIN) |
| 231 thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, init, 0, | 231 thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, init, 0, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 void Thread::Stop() { | 340 void Thread::Stop() { |
| 341 MessageQueue::Quit(); | 341 MessageQueue::Quit(); |
| 342 Join(); | 342 Join(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void Thread::Send(const Location& posted_from, | 345 void Thread::Send(const Location& posted_from, |
| 346 MessageHandler* phandler, | 346 MessageHandler* phandler, |
| 347 uint32_t id, | 347 uint32_t id, |
| 348 MessageData* pdata) { | 348 MessageData* pdata) { |
| 349 if (IsQuitting()) | 349 if (fStop_) |
| 350 return; | 350 return; |
| 351 | 351 |
| 352 // Sent messages are sent to the MessageHandler directly, in the context | 352 // Sent messages are sent to the MessageHandler directly, in the context |
| 353 // of "thread", like Win32 SendMessage. If in the right context, | 353 // of "thread", like Win32 SendMessage. If in the right context, |
| 354 // call the handler directly. | 354 // call the handler directly. |
| 355 Message msg; | 355 Message msg; |
| 356 msg.posted_from = posted_from; | 356 msg.posted_from = posted_from; |
| 357 msg.phandler = phandler; | 357 msg.phandler = phandler; |
| 358 msg.message_id = id; | 358 msg.message_id = id; |
| 359 msg.pdata = pdata; | 359 msg.pdata = pdata; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 if (SUCCEEDED(hr)) { | 559 if (SUCCEEDED(hr)) { |
| 560 Thread::Run(); | 560 Thread::Run(); |
| 561 CoUninitialize(); | 561 CoUninitialize(); |
| 562 } else { | 562 } else { |
| 563 LOG(LS_ERROR) << "CoInitialize failed, hr=" << hr; | 563 LOG(LS_ERROR) << "CoInitialize failed, hr=" << hr; |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 #endif | 566 #endif |
| 567 | 567 |
| 568 } // namespace rtc | 568 } // namespace rtc |
| OLD | NEW |