| OLD | NEW |
| 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 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 | 14 |
| 15 // 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 |
| 16 // the header; anything else is subject to change. Tasks should explicitly | 16 // the header; anything else is subject to change. Tasks should explicitly |
| 17 // request defaults if the behavior is critical to the task. | 17 // request defaults if the behavior is critical to the task. |
| 18 TaskTraits::TaskTraits() | 18 TaskTraits::TaskTraits() |
| 19 : with_file_io_(false), | 19 : with_file_io_(false), |
| 20 with_wait_(false), |
| 20 priority_(TaskPriority::BACKGROUND), | 21 priority_(TaskPriority::BACKGROUND), |
| 21 shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {} | 22 shutdown_behavior_(TaskShutdownBehavior::SKIP_ON_SHUTDOWN) {} |
| 22 | 23 |
| 23 TaskTraits::~TaskTraits() = default; | 24 TaskTraits::~TaskTraits() = default; |
| 24 | 25 |
| 25 TaskTraits& TaskTraits::WithFileIO() { | 26 TaskTraits& TaskTraits::WithFileIO() { |
| 26 with_file_io_ = true; | 27 with_file_io_ = true; |
| 27 return *this; | 28 return *this; |
| 28 } | 29 } |
| 29 | 30 |
| 31 TaskTraits& TaskTraits::WithWait() { |
| 32 with_wait_ = true; |
| 33 return *this; |
| 34 } |
| 35 |
| 30 TaskTraits& TaskTraits::WithPriority(TaskPriority priority) { | 36 TaskTraits& TaskTraits::WithPriority(TaskPriority priority) { |
| 31 priority_ = priority; | 37 priority_ = priority; |
| 32 return *this; | 38 return *this; |
| 33 } | 39 } |
| 34 | 40 |
| 35 TaskTraits& TaskTraits::WithShutdownBehavior( | 41 TaskTraits& TaskTraits::WithShutdownBehavior( |
| 36 TaskShutdownBehavior shutdown_behavior) { | 42 TaskShutdownBehavior shutdown_behavior) { |
| 37 shutdown_behavior_ = shutdown_behavior; | 43 shutdown_behavior_ = shutdown_behavior; |
| 38 return *this; | 44 return *this; |
| 39 } | 45 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 70 return os; | 76 return os; |
| 71 } | 77 } |
| 72 | 78 |
| 73 std::ostream& operator<<(std::ostream& os, | 79 std::ostream& operator<<(std::ostream& os, |
| 74 const TaskShutdownBehavior& shutdown_behavior) { | 80 const TaskShutdownBehavior& shutdown_behavior) { |
| 75 os << TaskShutdownBehaviorToString(shutdown_behavior); | 81 os << TaskShutdownBehaviorToString(shutdown_behavior); |
| 76 return os; | 82 return os; |
| 77 } | 83 } |
| 78 | 84 |
| 79 } // namespace base | 85 } // namespace base |
| OLD | NEW |