summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
authortoyoshim <toyoshim@chromium.org>2015-07-18 02:49:33 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-18 09:50:20 +0000
commit9f3199f1a065ed5e926b43372504e597e8b03346 (patch)
tree7b9ed2ac28d1ce52506962220afa0fdbb11ef164 /base/threading
parent349423af4f5941a60af567f7bc389ed7dc3da5f9 (diff)
downloadchromium_src-9f3199f1a065ed5e926b43372504e597e8b03346.zip
chromium_src-9f3199f1a065ed5e926b43372504e597e8b03346.tar.gz
chromium_src-9f3199f1a065ed5e926b43372504e597e8b03346.tar.bz2
base/threading: Move Create() to share from all platforms
For now, each PlatformThread implementation has a Create() that just calls CreateWithPriority() internally. So let's remove platform specific Create() implementation and share the same code placed in PlatformThread class header. BUG=468793 Review URL: https://codereview.chromium.org/1240073002 Cr-Commit-Position: refs/heads/master@{#339395}
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/platform_thread.h8
-rw-r--r--base/threading/platform_thread_posix.cc8
-rw-r--r--base/threading/platform_thread_win.cc7
-rw-r--r--base/threading/thread.cc10
4 files changed, 8 insertions, 25 deletions
diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h
index 0b92265..7b076a2 100644
--- a/base/threading/platform_thread.h
+++ b/base/threading/platform_thread.h
@@ -173,8 +173,12 @@ class BASE_EXPORT PlatformThread {
// NOTE: When you are done with the thread handle, you must call Join to
// release system resources associated with the thread. You must ensure that
// the Delegate object outlives the thread.
- static bool Create(size_t stack_size, Delegate* delegate,
- PlatformThreadHandle* thread_handle);
+ static bool Create(size_t stack_size,
+ Delegate* delegate,
+ PlatformThreadHandle* thread_handle) {
+ return CreateWithPriority(stack_size, delegate, thread_handle,
+ ThreadPriority::NORMAL);
+ }
// CreateWithPriority() does the same thing as Create() except the priority of
// the thread is set based on |priority|.
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index f3a835e..50c3357 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -194,14 +194,6 @@ const char* PlatformThread::GetName() {
}
// static
-bool PlatformThread::Create(size_t stack_size, Delegate* delegate,
- PlatformThreadHandle* thread_handle) {
- base::ThreadRestrictions::ScopedAllowWait allow_wait;
- return CreateThread(stack_size, true /* joinable thread */,
- delegate, thread_handle, ThreadPriority::NORMAL);
-}
-
-// static
bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate,
PlatformThreadHandle* thread_handle,
ThreadPriority priority) {
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index 059547b..0f7241a 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -189,13 +189,6 @@ const char* PlatformThread::GetName() {
}
// static
-bool PlatformThread::Create(size_t stack_size, Delegate* delegate,
- PlatformThreadHandle* thread_handle) {
- return CreateWithPriority(
- stack_size, delegate, thread_handle, ThreadPriority::NORMAL);
-}
-
-// static
bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate,
PlatformThreadHandle* thread_handle,
ThreadPriority priority) {
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index 7bff242..cf1d0b6 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -103,14 +103,8 @@ bool Thread::StartWithOptions(const Options& options) {
// that thread_ is populated before the newly created thread accesses it.
{
AutoLock lock(thread_lock_);
- bool created;
- if (options.priority == ThreadPriority::NORMAL) {
- created = PlatformThread::Create(options.stack_size, this, &thread_);
- } else {
- created = PlatformThread::CreateWithPriority(options.stack_size, this,
- &thread_, options.priority);
- }
- if (!created) {
+ if (!PlatformThread::CreateWithPriority(options.stack_size, this, &thread_,
+ options.priority)) {
DLOG(ERROR) << "failed to create thread";
message_loop_ = nullptr;
start_event_.reset();