OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
6 | 6 |
7 #include "base/debug/alias.h" | 7 #include "base/debug/alias.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 DWORD dwThreadID; // Thread ID (-1=caller thread). | 27 DWORD dwThreadID; // Thread ID (-1=caller thread). |
28 DWORD dwFlags; // Reserved for future use, must be zero. | 28 DWORD dwFlags; // Reserved for future use, must be zero. |
29 } THREADNAME_INFO; | 29 } THREADNAME_INFO; |
30 | 30 |
31 struct ThreadParams { | 31 struct ThreadParams { |
32 PlatformThread::Delegate* delegate; | 32 PlatformThread::Delegate* delegate; |
33 bool joinable; | 33 bool joinable; |
34 }; | 34 }; |
35 | 35 |
36 DWORD __stdcall ThreadFunc(void* params) { | 36 DWORD __stdcall ThreadFunc(void* params) { |
37 // TODO(apatrick): Remove this ASAP. This ensures that if the | |
38 // TerminateProcess entry point has been patched to point into a third party | |
39 // DLL, this is visible on the stack and the DLL in question can be | |
40 // determined. | |
41 typedef BOOL (WINAPI *TerminateProcessPtr)(HANDLE, UINT); | |
42 TerminateProcessPtr terminate_process = TerminateProcess; | |
43 base::debug::Alias(&terminate_process); | |
44 | |
45 ThreadParams* thread_params = static_cast<ThreadParams*>(params); | 37 ThreadParams* thread_params = static_cast<ThreadParams*>(params); |
46 PlatformThread::Delegate* delegate = thread_params->delegate; | 38 PlatformThread::Delegate* delegate = thread_params->delegate; |
47 if (!thread_params->joinable) | 39 if (!thread_params->joinable) |
48 base::ThreadRestrictions::SetSingletonAllowed(false); | 40 base::ThreadRestrictions::SetSingletonAllowed(false); |
49 delete thread_params; | 41 delete thread_params; |
50 delegate->ThreadMain(); | 42 delegate->ThreadMain(); |
51 return NULL; | 43 return NULL; |
52 } | 44 } |
53 | 45 |
54 // CreateThreadInternal() matches PlatformThread::Create(), except that | 46 // CreateThreadInternal() matches PlatformThread::Create(), except that |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 CloseHandle(thread_handle); | 156 CloseHandle(thread_handle); |
165 } | 157 } |
166 | 158 |
167 // static | 159 // static |
168 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 160 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
169 // TODO(crogers): implement | 161 // TODO(crogers): implement |
170 NOTIMPLEMENTED(); | 162 NOTIMPLEMENTED(); |
171 } | 163 } |
172 | 164 |
173 } // namespace base | 165 } // namespace base |
OLD | NEW |