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

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

Issue 2831883003: Do not inherit TaskPriority in TaskTraits. (Closed)
Patch Set: self-review Created 3 years, 8 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 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_traits.h" 5 #include "base/task_scheduler/task_traits.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <ostream> 9 #include <ostream>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/task_scheduler/scoped_set_task_priority_for_current_thread.h"
13 12
14 namespace base { 13 namespace base {
15 14
16 // Do not rely on defaults hard-coded below beyond the guarantees described in 15 // Do not rely on defaults hard-coded below beyond the guarantees described in
17 // the header; anything else is subject to change. Tasks should explicitly 16 // the header; anything else is subject to change. Tasks should explicitly
18 // request defaults if the behavior is critical to the task. 17 // request defaults if the behavior is critical to the task.
19 TaskTraits::TaskTraits() 18 TaskTraits::TaskTraits()
20 : may_block_(false), 19 : may_block_(false),
21 with_base_sync_primitives_(false), 20 with_base_sync_primitives_(false),
22 priority_(internal::GetTaskPriorityForCurrentThread()), 21 priority_(TaskPriority::INHERITED),
23 shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {} 22 shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {}
24 23
25 TaskTraits::~TaskTraits() = default; 24 TaskTraits::~TaskTraits() = default;
26 25
27 TaskTraits& TaskTraits::MayBlock() { 26 TaskTraits& TaskTraits::MayBlock() {
28 may_block_ = true; 27 may_block_ = true;
29 return *this; 28 return *this;
30 } 29 }
31 30
32 TaskTraits& TaskTraits::WithBaseSyncPrimitives() { 31 TaskTraits& TaskTraits::WithBaseSyncPrimitives() {
(...skipping 13 matching lines...) Expand all
46 } 45 }
47 46
48 const char* TaskPriorityToString(TaskPriority task_priority) { 47 const char* TaskPriorityToString(TaskPriority task_priority) {
49 switch (task_priority) { 48 switch (task_priority) {
50 case TaskPriority::BACKGROUND: 49 case TaskPriority::BACKGROUND:
51 return "BACKGROUND"; 50 return "BACKGROUND";
52 case TaskPriority::USER_VISIBLE: 51 case TaskPriority::USER_VISIBLE:
53 return "USER_VISIBLE"; 52 return "USER_VISIBLE";
54 case TaskPriority::USER_BLOCKING: 53 case TaskPriority::USER_BLOCKING:
55 return "USER_BLOCKING"; 54 return "USER_BLOCKING";
55 case TaskPriority::INHERITED:
56 return "INHERITED";
56 } 57 }
57 NOTREACHED(); 58 NOTREACHED();
58 return ""; 59 return "";
59 } 60 }
60 61
61 const char* TaskShutdownBehaviorToString( 62 const char* TaskShutdownBehaviorToString(
62 TaskShutdownBehavior shutdown_behavior) { 63 TaskShutdownBehavior shutdown_behavior) {
63 switch (shutdown_behavior) { 64 switch (shutdown_behavior) {
64 case TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN: 65 case TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN:
65 return "CONTINUE_ON_SHUTDOWN"; 66 return "CONTINUE_ON_SHUTDOWN";
(...skipping 11 matching lines...) Expand all
77 return os; 78 return os;
78 } 79 }
79 80
80 std::ostream& operator<<(std::ostream& os, 81 std::ostream& operator<<(std::ostream& os,
81 const TaskShutdownBehavior& shutdown_behavior) { 82 const TaskShutdownBehavior& shutdown_behavior) {
82 os << TaskShutdownBehaviorToString(shutdown_behavior); 83 os << TaskShutdownBehaviorToString(shutdown_behavior);
83 return os; 84 return os;
84 } 85 }
85 86
86 } // namespace base 87 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698