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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, |
| 232 &thread_id_); | 232 &thread_id_); |
|
Nico
2017/02/01 17:09:36
You can remove this cast now, right?
| |
| 233 if (thread_) { | 233 if (thread_) { |
| 234 running_.Set(); | 234 running_.Set(); |
| 235 } else { | 235 } else { |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 #elif defined(WEBRTC_POSIX) | 238 #elif defined(WEBRTC_POSIX) |
| 239 pthread_attr_t attr; | 239 pthread_attr_t attr; |
| 240 pthread_attr_init(&attr); | 240 pthread_attr_init(&attr); |
| 241 | 241 |
| 242 int error_code = pthread_create(&thread_, &attr, PreRun, init); | 242 int error_code = pthread_create(&thread_, &attr, PreRun, init); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 } | 301 } |
| 302 | 302 |
| 303 // static | 303 // static |
| 304 void Thread::AssertBlockingIsAllowedOnCurrentThread() { | 304 void Thread::AssertBlockingIsAllowedOnCurrentThread() { |
| 305 #if !defined(NDEBUG) | 305 #if !defined(NDEBUG) |
| 306 Thread* current = Thread::Current(); | 306 Thread* current = Thread::Current(); |
| 307 RTC_DCHECK(!current || current->blocking_calls_allowed_); | 307 RTC_DCHECK(!current || current->blocking_calls_allowed_); |
| 308 #endif | 308 #endif |
| 309 } | 309 } |
| 310 | 310 |
| 311 void* Thread::PreRun(void* pv) { | 311 void* THREAD_CALLING_CONV Thread::PreRun(void* pv) { |
| 312 ThreadInit* init = static_cast<ThreadInit*>(pv); | 312 ThreadInit* init = static_cast<ThreadInit*>(pv); |
| 313 ThreadManager::Instance()->SetCurrentThread(init->thread); | 313 ThreadManager::Instance()->SetCurrentThread(init->thread); |
| 314 rtc::SetCurrentThreadName(init->thread->name_.c_str()); | 314 rtc::SetCurrentThreadName(init->thread->name_.c_str()); |
| 315 #if __has_feature(objc_arc) | 315 #if __has_feature(objc_arc) |
| 316 @autoreleasepool | 316 @autoreleasepool |
| 317 #elif defined(WEBRTC_MAC) | 317 #elif defined(WEBRTC_MAC) |
| 318 // Make sure the new thread has an autoreleasepool | 318 // Make sure the new thread has an autoreleasepool |
| 319 ScopedAutoreleasePool pool; | 319 ScopedAutoreleasePool pool; |
| 320 #endif | 320 #endif |
| 321 { | 321 { |
| (...skipping 237 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 |