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 <errno.h> | 7 #include <errno.h> |
8 #include <sys/prctl.h> | 8 #include <sys/prctl.h> |
9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 bool GetThreadPriorityForPlatform(PlatformThreadHandle handle, | 59 bool GetThreadPriorityForPlatform(PlatformThreadHandle handle, |
60 ThreadPriority* priority) { | 60 ThreadPriority* priority) { |
61 NOTIMPLEMENTED(); | 61 NOTIMPLEMENTED(); |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 } // namespace internal | 65 } // namespace internal |
66 | 66 |
67 void PlatformThread::SetName(const char* name) { | 67 void PlatformThread::SetName(const std::string& name) { |
68 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); | 68 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); |
69 tracked_objects::ThreadData::InitializeThreadContext(name); | 69 tracked_objects::ThreadData::InitializeThreadContext(name); |
70 | 70 |
71 // Like linux, on android we can get the thread names to show up in the | 71 // Like linux, on android we can get the thread names to show up in the |
72 // debugger by setting the process name for the LWP. | 72 // debugger by setting the process name for the LWP. |
73 // We don't want to do this for the main thread because that would rename | 73 // We don't want to do this for the main thread because that would rename |
74 // the process, causing tools like killall to stop working. | 74 // the process, causing tools like killall to stop working. |
75 if (PlatformThread::CurrentId() == getpid()) | 75 if (PlatformThread::CurrentId() == getpid()) |
76 return; | 76 return; |
77 | 77 |
78 // Set the name for the LWP (which gets truncated to 15 characters). | 78 // Set the name for the LWP (which gets truncated to 15 characters). |
79 int err = prctl(PR_SET_NAME, name); | 79 int err = prctl(PR_SET_NAME, name.c_str()); |
80 if (err < 0 && errno != EPERM) | 80 if (err < 0 && errno != EPERM) |
81 DPLOG(ERROR) << "prctl(PR_SET_NAME)"; | 81 DPLOG(ERROR) << "prctl(PR_SET_NAME)"; |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 void InitThreading() { | 85 void InitThreading() { |
86 } | 86 } |
87 | 87 |
88 void InitOnThread() { | 88 void InitOnThread() { |
89 // Threads on linux/android may inherit their priority from the thread | 89 // Threads on linux/android may inherit their priority from the thread |
(...skipping 14 matching lines...) Expand all Loading... |
104 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). | 104 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). |
105 return 2 * (1 << 20); // 2Mb | 105 return 2 * (1 << 20); // 2Mb |
106 #endif | 106 #endif |
107 } | 107 } |
108 | 108 |
109 bool RegisterThreadUtils(JNIEnv* env) { | 109 bool RegisterThreadUtils(JNIEnv* env) { |
110 return RegisterNativesImpl(env); | 110 return RegisterNativesImpl(env); |
111 } | 111 } |
112 | 112 |
113 } // namespace base | 113 } // namespace base |
OLD | NEW |