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 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
9 #include <mach/mach_time.h> | 9 #include <mach/mach_time.h> |
10 #include <mach/thread_policy.h> | 10 #include <mach/thread_policy.h> |
(...skipping 24 matching lines...) Expand all Loading... |
35 [NSThread detachNewThreadSelector:@selector(class) | 35 [NSThread detachNewThreadSelector:@selector(class) |
36 toTarget:[NSObject class] | 36 toTarget:[NSObject class] |
37 withObject:nil]; | 37 withObject:nil]; |
38 multithreaded = YES; | 38 multithreaded = YES; |
39 | 39 |
40 DCHECK([NSThread isMultiThreaded]); | 40 DCHECK([NSThread isMultiThreaded]); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 void PlatformThread::SetName(const char* name) { | 45 void PlatformThread::SetName(const std::string& name) { |
46 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); | 46 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); |
47 tracked_objects::ThreadData::InitializeThreadContext(name); | 47 tracked_objects::ThreadData::InitializeThreadContext(name); |
48 | 48 |
49 // Mac OS X does not expose the length limit of the name, so | 49 // Mac OS X does not expose the length limit of the name, so |
50 // hardcode it. | 50 // hardcode it. |
51 const int kMaxNameLength = 63; | 51 const int kMaxNameLength = 63; |
52 std::string shortened_name = std::string(name).substr(0, kMaxNameLength); | 52 std::string shortened_name = name.substr(0, kMaxNameLength); |
53 // pthread_setname() fails (harmlessly) in the sandbox, ignore when it does. | 53 // pthread_setname() fails (harmlessly) in the sandbox, ignore when it does. |
54 // See http://crbug.com/47058 | 54 // See http://crbug.com/47058 |
55 pthread_setname_np(shortened_name.c_str()); | 55 pthread_setname_np(shortened_name.c_str()); |
56 } | 56 } |
57 | 57 |
58 namespace { | 58 namespace { |
59 | 59 |
60 void SetPriorityNormal(mach_port_t mach_thread_id) { | 60 void SetPriorityNormal(mach_port_t mach_thread_id) { |
61 // Make thread standard policy. | 61 // Make thread standard policy. |
62 // Please note that this call could fail in rare cases depending | 62 // Please note that this call could fail in rare cases depending |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 #endif | 214 #endif |
215 } | 215 } |
216 | 216 |
217 void InitOnThread() { | 217 void InitOnThread() { |
218 } | 218 } |
219 | 219 |
220 void TerminateOnThread() { | 220 void TerminateOnThread() { |
221 } | 221 } |
222 | 222 |
223 } // namespace base | 223 } // namespace base |
OLD | NEW |