Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: base/threading/platform_thread_win.cc

Issue 1164713007: base/threading: minor cleanups to remove friend class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove debug code Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/debug/alias.h" 7 #include "base/debug/alias.h"
8 #include "base/debug/profiler.h" 8 #include "base/debug/profiler.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_id_name_manager.h" 10 #include "base/threading/thread_id_name_manager.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return result; 199 return result;
200 } 200 }
201 201
202 // static 202 // static
203 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { 203 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) {
204 return CreateThreadInternal(stack_size, delegate, NULL); 204 return CreateThreadInternal(stack_size, delegate, NULL);
205 } 205 }
206 206
207 // static 207 // static
208 void PlatformThread::Join(PlatformThreadHandle thread_handle) { 208 void PlatformThread::Join(PlatformThreadHandle thread_handle) {
209 DCHECK(thread_handle.handle_); 209 DCHECK(thread_handle.platform_handle());
210 // TODO(willchan): Enable this check once I can get it to work for Windows 210 // TODO(willchan): Enable this check once I can get it to work for Windows
211 // shutdown. 211 // shutdown.
212 // Joining another thread may block the current thread for a long time, since 212 // Joining another thread may block the current thread for a long time, since
213 // the thread referred to by |thread_handle| may still be running long-lived / 213 // the thread referred to by |thread_handle| may still be running long-lived /
214 // blocking tasks. 214 // blocking tasks.
215 #if 0 215 #if 0
216 base::ThreadRestrictions::AssertIOAllowed(); 216 base::ThreadRestrictions::AssertIOAllowed();
217 #endif 217 #endif
218 218
219 // Wait for the thread to exit. It should already have terminated but make 219 // Wait for the thread to exit. It should already have terminated but make
220 // sure this assumption is valid. 220 // sure this assumption is valid.
221 DWORD result = WaitForSingleObject(thread_handle.handle_, INFINITE); 221 DWORD result = WaitForSingleObject(thread_handle.platform_handle(), INFINITE);
222 if (result != WAIT_OBJECT_0) { 222 if (result != WAIT_OBJECT_0) {
223 // Debug info for bug 127931. 223 // Debug info for bug 127931.
224 DWORD error = GetLastError(); 224 DWORD error = GetLastError();
225 debug::Alias(&error); 225 debug::Alias(&error);
226 debug::Alias(&result); 226 debug::Alias(&result);
227 debug::Alias(&thread_handle.handle_);
228 CHECK(false); 227 CHECK(false);
Takashi Toyoshima 2015/06/02 08:57:08 No one work on this bug now, and the bug 127931 wa
gab 2015/06/02 14:15:41 I think this should be okay since |thread_handle|
229 } 228 }
230 229
231 CloseHandle(thread_handle.handle_); 230 CloseHandle(thread_handle.platform_handle());
232 } 231 }
233 232
234 // static 233 // static
235 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle, 234 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
236 ThreadPriority priority) { 235 ThreadPriority priority) {
237 DCHECK(!handle.is_null()); 236 DCHECK(!handle.is_null());
238 237
239 int desired_priority = THREAD_PRIORITY_ERROR_RETURN; 238 int desired_priority = THREAD_PRIORITY_ERROR_RETURN;
240 switch (priority) { 239 switch (priority) {
241 case ThreadPriority::BACKGROUND: 240 case ThreadPriority::BACKGROUND:
(...skipping 10 matching lines...) Expand all
252 break; 251 break;
253 default: 252 default:
254 NOTREACHED() << "Unknown priority."; 253 NOTREACHED() << "Unknown priority.";
255 break; 254 break;
256 } 255 }
257 DCHECK_NE(desired_priority, THREAD_PRIORITY_ERROR_RETURN); 256 DCHECK_NE(desired_priority, THREAD_PRIORITY_ERROR_RETURN);
258 257
259 #ifndef NDEBUG 258 #ifndef NDEBUG
260 const BOOL success = 259 const BOOL success =
261 #endif 260 #endif
262 ::SetThreadPriority(handle.handle_, desired_priority); 261 ::SetThreadPriority(handle.platform_handle(), desired_priority);
263 DPLOG_IF(ERROR, !success) << "Failed to set thread priority to " 262 DPLOG_IF(ERROR, !success) << "Failed to set thread priority to "
264 << desired_priority; 263 << desired_priority;
265 } 264 }
266 265
267 // static 266 // static
268 ThreadPriority PlatformThread::GetThreadPriority(PlatformThreadHandle handle) { 267 ThreadPriority PlatformThread::GetThreadPriority(PlatformThreadHandle handle) {
269 DCHECK(!handle.is_null()); 268 DCHECK(!handle.is_null());
270 269
271 int priority = ::GetThreadPriority(handle.handle_); 270 int priority = ::GetThreadPriority(handle.platform_handle());
272 switch (priority) { 271 switch (priority) {
273 case THREAD_PRIORITY_LOWEST: 272 case THREAD_PRIORITY_LOWEST:
274 return ThreadPriority::BACKGROUND; 273 return ThreadPriority::BACKGROUND;
275 case THREAD_PRIORITY_NORMAL: 274 case THREAD_PRIORITY_NORMAL:
276 return ThreadPriority::NORMAL; 275 return ThreadPriority::NORMAL;
277 case THREAD_PRIORITY_ABOVE_NORMAL: 276 case THREAD_PRIORITY_ABOVE_NORMAL:
278 return ThreadPriority::DISPLAY; 277 return ThreadPriority::DISPLAY;
279 case THREAD_PRIORITY_TIME_CRITICAL: 278 case THREAD_PRIORITY_TIME_CRITICAL:
280 return ThreadPriority::REALTIME_AUDIO; 279 return ThreadPriority::REALTIME_AUDIO;
281 case THREAD_PRIORITY_ERROR_RETURN: 280 case THREAD_PRIORITY_ERROR_RETURN:
282 DPCHECK(false) << "GetThreadPriority error"; // Falls through. 281 DPCHECK(false) << "GetThreadPriority error"; // Falls through.
283 default: 282 default:
284 NOTREACHED() << "Unexpected priority: " << priority; 283 NOTREACHED() << "Unexpected priority: " << priority;
285 return ThreadPriority::NORMAL; 284 return ThreadPriority::NORMAL;
286 } 285 }
287 } 286 }
288 287
289 } // namespace base 288 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698