| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <sys/prctl.h> | 9 #include <sys/prctl.h> |
| 10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (Java_ThreadUtils_isThreadPriorityAudio( | 54 if (Java_ThreadUtils_isThreadPriorityAudio( |
| 55 env, PlatformThread::CurrentId())) { | 55 env, PlatformThread::CurrentId())) { |
| 56 *priority = ThreadPriority::REALTIME_AUDIO; | 56 *priority = ThreadPriority::REALTIME_AUDIO; |
| 57 return true; | 57 return true; |
| 58 } | 58 } |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace internal | 62 } // namespace internal |
| 63 | 63 |
| 64 void PlatformThread::SetName(const std::string& name) { | 64 void PlatformThread::SetName(const std::string& name, bool is_worker_thread) { |
| 65 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); | 65 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); |
| 66 tracked_objects::ThreadData::InitializeThreadContext(name); | 66 tracked_objects::ThreadData::InitializeThreadContext(name, is_worker_thread); |
| 67 | 67 |
| 68 // Like linux, on android we can get the thread names to show up in the | 68 // Like linux, on android we can get the thread names to show up in the |
| 69 // debugger by setting the process name for the LWP. | 69 // debugger by setting the process name for the LWP. |
| 70 // We don't want to do this for the main thread because that would rename | 70 // We don't want to do this for the main thread because that would rename |
| 71 // the process, causing tools like killall to stop working. | 71 // the process, causing tools like killall to stop working. |
| 72 if (PlatformThread::CurrentId() == getpid()) | 72 if (PlatformThread::CurrentId() == getpid()) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 // Set the name for the LWP (which gets truncated to 15 characters). | 75 // Set the name for the LWP (which gets truncated to 15 characters). |
| 76 int err = prctl(PR_SET_NAME, name.c_str()); | 76 int err = prctl(PR_SET_NAME, name.c_str()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 94 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). | 94 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). |
| 95 return 2 * (1 << 20); // 2Mb | 95 return 2 * (1 << 20); // 2Mb |
| 96 #endif | 96 #endif |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool RegisterThreadUtils(JNIEnv* env) { | 99 bool RegisterThreadUtils(JNIEnv* env) { |
| 100 return RegisterNativesImpl(env); | 100 return RegisterNativesImpl(env); |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace base | 103 } // namespace base |
| OLD | NEW |