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

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

Issue 2873453002: Add base::TaskTraits::Override(). (Closed)
Patch Set: CR-gab 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/task_scheduler/task.cc » ('j') | 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/post_task.h" 5 #include "base/task_scheduler/post_task.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/task_scheduler/scoped_set_task_priority_for_current_thread.h" 10 #include "base/task_scheduler/scoped_set_task_priority_for_current_thread.h"
(...skipping 16 matching lines...) Expand all
27 return true; 27 return true;
28 } 28 }
29 29
30 const TaskTraits traits_; 30 const TaskTraits traits_;
31 }; 31 };
32 32
33 // Returns TaskTraits based on |traits|. If TaskPriority hasn't been set 33 // Returns TaskTraits based on |traits|. If TaskPriority hasn't been set
34 // explicitly in |traits|, the returned TaskTraits have the current 34 // explicitly in |traits|, the returned TaskTraits have the current
35 // TaskPriority. 35 // TaskPriority.
36 TaskTraits GetTaskTraitsWithExplicitPriority(const TaskTraits& traits) { 36 TaskTraits GetTaskTraitsWithExplicitPriority(const TaskTraits& traits) {
37 return traits.priority_set_explicitly() 37 if (traits.priority_set_explicitly())
38 ? traits 38 return traits;
39 : TaskTraits(traits).WithPriority( 39 return TaskTraits::Override(traits,
40 internal::GetTaskPriorityForCurrentThread()); 40 {internal::GetTaskPriorityForCurrentThread()});
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 void PostTask(const tracked_objects::Location& from_here, OnceClosure task) { 45 void PostTask(const tracked_objects::Location& from_here, OnceClosure task) {
46 PostDelayedTask(from_here, std::move(task), TimeDelta()); 46 PostDelayedTask(from_here, std::move(task), TimeDelta());
47 } 47 }
48 48
49 void PostDelayedTask(const tracked_objects::Location& from_here, 49 void PostDelayedTask(const tracked_objects::Location& from_here,
50 OnceClosure task, 50 OnceClosure task,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 scoped_refptr<SingleThreadTaskRunner> CreateCOMSTATaskRunnerWithTraits( 111 scoped_refptr<SingleThreadTaskRunner> CreateCOMSTATaskRunnerWithTraits(
112 const TaskTraits& traits) { 112 const TaskTraits& traits) {
113 DCHECK(TaskScheduler::GetInstance()) 113 DCHECK(TaskScheduler::GetInstance())
114 << "Ref. Prerequisite section of post_task.h"; 114 << "Ref. Prerequisite section of post_task.h";
115 return TaskScheduler::GetInstance()->CreateCOMSTATaskRunnerWithTraits( 115 return TaskScheduler::GetInstance()->CreateCOMSTATaskRunnerWithTraits(
116 GetTaskTraitsWithExplicitPriority(traits)); 116 GetTaskTraitsWithExplicitPriority(traits));
117 } 117 }
118 #endif // defined(OS_WIN) 118 #endif // defined(OS_WIN)
119 119
120 } // namespace base 120 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698