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

Side by Side Diff: base/threading/platform_thread_mac.mm

Issue 8803021: Set thread name in profiler on mac (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 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 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <mach/mach.h> 9 #include <mach/mach.h>
10 #include <mach/mach_time.h> 10 #include <mach/mach_time.h>
11 #include <mach/thread_policy.h> 11 #include <mach/thread_policy.h>
12 12
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/threading/thread_local.h" 15 #include "base/threading/thread_local.h"
16 #include "base/tracked_objects.h"
16 17
17 namespace base { 18 namespace base {
18 19
19 namespace { 20 namespace {
20 21
21 LazyInstance<ThreadLocalPointer<char>, 22 LazyInstance<ThreadLocalPointer<char>,
22 LeakyLazyInstanceTraits<ThreadLocalPointer<char> > > 23 LeakyLazyInstanceTraits<ThreadLocalPointer<char> > >
23 current_thread_name = LAZY_INSTANCE_INITIALIZER; 24 current_thread_name = LAZY_INSTANCE_INITIALIZER;
24 25
25 } // namespace 26 } // namespace
(...skipping 15 matching lines...) Expand all
41 withObject:nil]; 42 withObject:nil];
42 multithreaded = YES; 43 multithreaded = YES;
43 44
44 DCHECK([NSThread isMultiThreaded]); 45 DCHECK([NSThread isMultiThreaded]);
45 } 46 }
46 } 47 }
47 48
48 // static 49 // static
49 void PlatformThread::SetName(const char* name) { 50 void PlatformThread::SetName(const char* name) {
50 current_thread_name.Pointer()->Set(const_cast<char*>(name)); 51 current_thread_name.Pointer()->Set(const_cast<char*>(name));
52 tracked_objects::ThreadData::InitializeThreadContext(name);
51 53
52 // pthread_setname_np is only available in 10.6 or later, so test 54 // pthread_setname_np is only available in 10.6 or later, so test
53 // for it at runtime. 55 // for it at runtime.
54 int (*dynamic_pthread_setname_np)(const char*); 56 int (*dynamic_pthread_setname_np)(const char*);
55 *reinterpret_cast<void**>(&dynamic_pthread_setname_np) = 57 *reinterpret_cast<void**>(&dynamic_pthread_setname_np) =
56 dlsym(RTLD_DEFAULT, "pthread_setname_np"); 58 dlsym(RTLD_DEFAULT, "pthread_setname_np");
57 if (!dynamic_pthread_setname_np) 59 if (!dynamic_pthread_setname_np)
58 return; 60 return;
59 61
60 // Mac OS X does not expose the length limit of the name, so 62 // Mac OS X does not expose the length limit of the name, so
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 case kThreadPriority_Normal: 182 case kThreadPriority_Normal:
181 SetPriorityNormal(mach_thread_id); 183 SetPriorityNormal(mach_thread_id);
182 break; 184 break;
183 case kThreadPriority_RealtimeAudio: 185 case kThreadPriority_RealtimeAudio:
184 SetPriorityRealtimeAudio(mach_thread_id); 186 SetPriorityRealtimeAudio(mach_thread_id);
185 break; 187 break;
186 } 188 }
187 } 189 }
188 190
189 } // namespace base 191 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698