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

Unified Diff: base/task_scheduler/task_traits.h

Issue 2873453002: Add base::TaskTraits::Override(). (Closed)
Patch Set: self-review Created 3 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 side-by-side diff with in-line comments
Download patch
Index: base/task_scheduler/task_traits.h
diff --git a/base/task_scheduler/task_traits.h b/base/task_scheduler/task_traits.h
index cd1d7ccf3c674a56ff6fc80a94b1d621f2b94ad5..f8cc30ebf7898dd95db7637d7e014a8ef9f876d0 100644
--- a/base/task_scheduler/task_traits.h
+++ b/base/task_scheduler/task_traits.h
@@ -157,6 +157,9 @@ class BASE_EXPORT TaskTraits {
internal::EnumArgGetter<base::TaskPriority,
base::TaskPriority::USER_VISIBLE>(),
args...)),
+ shutdown_behavior_set_explicitly_(
+ internal::HasArgOfType<base::TaskShutdownBehavior,
+ ArgTypes...>::value),
shutdown_behavior_(internal::GetValueFromArgList(
internal::EnumArgGetter<
base::TaskShutdownBehavior,
@@ -172,6 +175,14 @@ class BASE_EXPORT TaskTraits {
constexpr TaskTraits(const TaskTraits& other) = default;
TaskTraits& operator=(const TaskTraits& other) = default;
+ // Returns TaskTraits constructed by merging |left| and |right|. If a trait is
+ // specified in both |left| and |right|, the returned TaskTraits will have the
+ // value from |right|.
+ static constexpr TaskTraits Merge(const TaskTraits& left,
gab 2017/05/09 14:32:31 s/Merge/Override/ as discussed.
fdoray 2017/05/09 14:58:33 Done.
+ const TaskTraits& right) {
+ return TaskTraits(left, right);
+ }
+
// Deprecated. Prefer constexpr construction to builder paradigm as
// documented above.
// TODO(fdoray): Remove these methods. https://crbug.com/713683
@@ -202,10 +213,26 @@ class BASE_EXPORT TaskTraits {
}
private:
+ constexpr TaskTraits(const TaskTraits& left, const TaskTraits& right)
+ : priority_set_explicitly_(left.priority_set_explicitly_ ||
+ right.priority_set_explicitly_),
+ priority_(right.priority_set_explicitly_ ? right.priority_
+ : left.priority_),
+ shutdown_behavior_set_explicitly_(
+ left.shutdown_behavior_set_explicitly_ ||
+ right.shutdown_behavior_set_explicitly_),
+ shutdown_behavior_(right.shutdown_behavior_set_explicitly_
+ ? right.shutdown_behavior_
+ : left.shutdown_behavior_),
+ may_block_(left.may_block_ || right.may_block_),
+ with_base_sync_primitives_(left.with_base_sync_primitives_ ||
+ right.with_base_sync_primitives_) {}
+
// TODO(fdoray): Make these const after refactoring away deprecated builder
// pattern.
gab 2017/05/09 14:32:31 drive-by thought: Actually, this TODO will not be
fdoray 2017/05/09 14:58:33 Acknowledged. TODO removed by upcoming CL.
bool priority_set_explicitly_;
TaskPriority priority_;
+ bool shutdown_behavior_set_explicitly_;
TaskShutdownBehavior shutdown_behavior_;
bool may_block_;
bool with_base_sync_primitives_;

Powered by Google App Engine
This is Rietveld 408576698