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

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

Issue 1207823004: PlatformThreadHandle: remove public id() interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (upstream master for try) Created 5 years, 5 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
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 <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 26 matching lines...) Expand all
37 // Process.THREAD_PRIORITY_URGENT_DISPLAY = -8; 37 // Process.THREAD_PRIORITY_URGENT_DISPLAY = -8;
38 // We use -6 for display, but we may want to split this into urgent (-8) and 38 // We use -6 for display, but we may want to split this into urgent (-8) and
39 // non-urgent (-4). 39 // non-urgent (-4).
40 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = { 40 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = {
41 {ThreadPriority::BACKGROUND, 10}, 41 {ThreadPriority::BACKGROUND, 10},
42 {ThreadPriority::NORMAL, 0}, 42 {ThreadPriority::NORMAL, 0},
43 {ThreadPriority::DISPLAY, -6}, 43 {ThreadPriority::DISPLAY, -6},
44 {ThreadPriority::REALTIME_AUDIO, -16}, 44 {ThreadPriority::REALTIME_AUDIO, -16},
45 }; 45 };
46 46
47 bool SetThreadPriorityForPlatform(PlatformThreadHandle handle, 47 bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) {
48 ThreadPriority priority) {
49 // On Android, we set the Audio priority through JNI as Audio priority 48 // On Android, we set the Audio priority through JNI as Audio priority
50 // will also allow the process to run while it is backgrounded. 49 // will also allow the process to run while it is backgrounded.
51 if (priority == ThreadPriority::REALTIME_AUDIO) { 50 if (priority == ThreadPriority::REALTIME_AUDIO) {
52 JNIEnv* env = base::android::AttachCurrentThread(); 51 JNIEnv* env = base::android::AttachCurrentThread();
53 Java_ThreadUtils_setThreadPriorityAudio(env, PlatformThread::CurrentId()); 52 Java_ThreadUtils_setThreadPriorityAudio(env, PlatformThread::CurrentId());
54 return true; 53 return true;
55 } 54 }
56 return false; 55 return false;
57 } 56 }
58 57
59 bool GetThreadPriorityForPlatform(PlatformThreadHandle handle, 58 bool GetCurrentThreadPriorityForPlatform(ThreadPriority* priority) {
60 ThreadPriority* priority) { 59 // See http://crbug.com/505474.
61 NOTIMPLEMENTED(); 60 NOTIMPLEMENTED();
62 return false; 61 return false;
63 } 62 }
64 63
65 } // namespace internal 64 } // namespace internal
66 65
67 void PlatformThread::SetName(const std::string& name) { 66 void PlatformThread::SetName(const std::string& name) {
68 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); 67 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
69 tracked_objects::ThreadData::InitializeThreadContext(name); 68 tracked_objects::ThreadData::InitializeThreadContext(name);
70 69
(...skipping 10 matching lines...) Expand all
81 DPLOG(ERROR) << "prctl(PR_SET_NAME)"; 80 DPLOG(ERROR) << "prctl(PR_SET_NAME)";
82 } 81 }
83 82
84 83
85 void InitThreading() { 84 void InitThreading() {
86 } 85 }
87 86
88 void InitOnThread() { 87 void InitOnThread() {
89 // Threads on linux/android may inherit their priority from the thread 88 // Threads on linux/android may inherit their priority from the thread
90 // where they were created. This sets all new threads to the default. 89 // where they were created. This sets all new threads to the default.
91 PlatformThread::SetThreadPriority(PlatformThread::CurrentHandle(), 90 PlatformThread::SetCurrentThreadPriority(ThreadPriority::NORMAL);
92 ThreadPriority::NORMAL);
93 } 91 }
94 92
95 void TerminateOnThread() { 93 void TerminateOnThread() {
96 base::android::DetachFromVM(); 94 base::android::DetachFromVM();
97 } 95 }
98 96
99 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { 97 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
100 #if !defined(ADDRESS_SANITIZER) 98 #if !defined(ADDRESS_SANITIZER)
101 return 0; 99 return 0;
102 #else 100 #else
103 // AddressSanitizer bloats the stack approximately 2x. Default stack size of 101 // AddressSanitizer bloats the stack approximately 2x. Default stack size of
104 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). 102 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example).
105 return 2 * (1 << 20); // 2Mb 103 return 2 * (1 << 20); // 2Mb
106 #endif 104 #endif
107 } 105 }
108 106
109 bool RegisterThreadUtils(JNIEnv* env) { 107 bool RegisterThreadUtils(JNIEnv* env) {
110 return RegisterNativesImpl(env); 108 return RegisterNativesImpl(env);
111 } 109 }
112 110
113 } // namespace base 111 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698