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

Side by Side Diff: base/task_scheduler/task_scheduler_impl_unittest.cc

Issue 1951453002: Name TaskScheduler's worker threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b7_fdoray_fixtracing
Patch Set: explicit cast to int Created 4 years, 7 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
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/task_scheduler/task_scheduler_impl.h" 5 #include "base/task_scheduler/task_scheduler_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string>
9 #include <utility> 10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
17 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
18 #include "base/task_scheduler/task_traits.h" 19 #include "base/task_scheduler/task_traits.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 EXPECT_EQ(traits.priority() == TaskPriority::BACKGROUND 71 EXPECT_EQ(traits.priority() == TaskPriority::BACKGROUND
71 ? ThreadPriority::BACKGROUND 72 ? ThreadPriority::BACKGROUND
72 : ThreadPriority::NORMAL, 73 : ThreadPriority::NORMAL,
73 PlatformThread::GetCurrentThreadPriority()); 74 PlatformThread::GetCurrentThreadPriority());
74 75
75 #if ENABLE_THREAD_RESTRICTIONS 76 #if ENABLE_THREAD_RESTRICTIONS
76 // The #if above is required because GetIOAllowed() always returns true when 77 // The #if above is required because GetIOAllowed() always returns true when
77 // !ENABLE_THREAD_RESTRICTIONS, even when |traits| don't allow file I/O. 78 // !ENABLE_THREAD_RESTRICTIONS, even when |traits| don't allow file I/O.
78 EXPECT_EQ(traits.with_file_io(), GetIOAllowed()); 79 EXPECT_EQ(traits.with_file_io(), GetIOAllowed());
79 #endif 80 #endif
81
82 // Verify that the thread the task is running on is named as expected.
83 const std::string current_thread_name(PlatformThread::GetName());
84 EXPECT_NE(std::string::npos, current_thread_name.find("TaskScheduler"));
85 EXPECT_NE(std::string::npos,
86 current_thread_name.find(
87 traits.priority() == TaskPriority::BACKGROUND ? "Background"
88 : "Foreground"));
89 EXPECT_EQ(traits.with_file_io(),
90 current_thread_name.find("FileIO") != std::string::npos);
80 } 91 }
81 92
82 void VerifyTaskEnvironementAndSignalEvent(const TaskTraits& traits, 93 void VerifyTaskEnvironementAndSignalEvent(const TaskTraits& traits,
83 WaitableEvent* event) { 94 WaitableEvent* event) {
84 DCHECK(event); 95 DCHECK(event);
85 VerifyTaskEnvironement(traits); 96 VerifyTaskEnvironement(traits);
86 event->Signal(); 97 event->Signal();
87 } 98 }
88 99
89 class ThreadPostingTasks : public SimpleThread { 100 class ThreadPostingTasks : public SimpleThread {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 210 }
200 211
201 scheduler->JoinForTesting(); 212 scheduler->JoinForTesting();
202 } 213 }
203 214
204 // TODO(fdoray): Add tests with Sequences that move around thread pools once 215 // TODO(fdoray): Add tests with Sequences that move around thread pools once
205 // child TaskRunners are supported. 216 // child TaskRunners are supported.
206 217
207 } // namespace internal 218 } // namespace internal
208 } // namespace base 219 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698