| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/debug/profiler.h" | 10 #include "base/debug/profiler.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 if (out_thread_handle) | 126 if (out_thread_handle) |
| 127 *out_thread_handle = PlatformThreadHandle(thread_handle); | 127 *out_thread_handle = PlatformThreadHandle(thread_handle); |
| 128 else | 128 else |
| 129 CloseHandle(thread_handle); | 129 CloseHandle(thread_handle); |
| 130 return true; | 130 return true; |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace | 133 } // namespace |
| 134 | 134 |
| 135 // TODO(prashant.n): Move to common file across platforms. |
| 136 std::string GetThreadPriorityAbbr(ThreadPriority priority) { |
| 137 switch (priority) { |
| 138 case ThreadPriority::BACKGROUND: |
| 139 return "bg"; |
| 140 case ThreadPriority::NORMAL: |
| 141 return "nl"; |
| 142 case ThreadPriority::DISPLAY: |
| 143 return "ds"; |
| 144 case ThreadPriority::REALTIME_AUDIO: |
| 145 return "rt"; |
| 146 default: |
| 147 NOTREACHED(); |
| 148 return ""; |
| 149 } |
| 150 } |
| 151 |
| 135 // static | 152 // static |
| 136 PlatformThreadId PlatformThread::CurrentId() { | 153 PlatformThreadId PlatformThread::CurrentId() { |
| 137 return ::GetCurrentThreadId(); | 154 return ::GetCurrentThreadId(); |
| 138 } | 155 } |
| 139 | 156 |
| 140 // static | 157 // static |
| 141 PlatformThreadRef PlatformThread::CurrentRef() { | 158 PlatformThreadRef PlatformThread::CurrentRef() { |
| 142 return PlatformThreadRef(::GetCurrentThreadId()); | 159 return PlatformThreadRef(::GetCurrentThreadId()); |
| 143 } | 160 } |
| 144 | 161 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return ThreadPriority::REALTIME_AUDIO; | 292 return ThreadPriority::REALTIME_AUDIO; |
| 276 case THREAD_PRIORITY_ERROR_RETURN: | 293 case THREAD_PRIORITY_ERROR_RETURN: |
| 277 DPCHECK(false) << "GetThreadPriority error"; // Falls through. | 294 DPCHECK(false) << "GetThreadPriority error"; // Falls through. |
| 278 default: | 295 default: |
| 279 NOTREACHED() << "Unexpected priority: " << priority; | 296 NOTREACHED() << "Unexpected priority: " << priority; |
| 280 return ThreadPriority::NORMAL; | 297 return ThreadPriority::NORMAL; |
| 281 } | 298 } |
| 282 } | 299 } |
| 283 | 300 |
| 284 } // namespace base | 301 } // namespace base |
| OLD | NEW |