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

Side by Side Diff: base/message_loop/incoming_task_queue.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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/message_loop/incoming_task_queue.h ('k') | base/message_loop/message_loop.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/message_loop/incoming_task_queue.h" 5 #include "base/message_loop/incoming_task_queue.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 : high_res_task_count_(0), 52 : high_res_task_count_(0),
53 message_loop_(message_loop), 53 message_loop_(message_loop),
54 next_sequence_num_(0), 54 next_sequence_num_(0),
55 message_loop_scheduled_(false), 55 message_loop_scheduled_(false),
56 always_schedule_work_(AlwaysNotifyPump(message_loop_->type())), 56 always_schedule_work_(AlwaysNotifyPump(message_loop_->type())),
57 is_ready_for_scheduling_(false) { 57 is_ready_for_scheduling_(false) {
58 } 58 }
59 59
60 bool IncomingTaskQueue::AddToIncomingQueue( 60 bool IncomingTaskQueue::AddToIncomingQueue(
61 const tracked_objects::Location& from_here, 61 const tracked_objects::Location& from_here,
62 const Closure& task, 62 OnceClosure task,
63 TimeDelta delay, 63 TimeDelta delay,
64 bool nestable) { 64 bool nestable) {
65 DLOG_IF(WARNING, 65 DLOG_IF(WARNING,
66 delay.InSeconds() > kTaskDelayWarningThresholdInSeconds) 66 delay.InSeconds() > kTaskDelayWarningThresholdInSeconds)
67 << "Requesting super-long task delay period of " << delay.InSeconds() 67 << "Requesting super-long task delay period of " << delay.InSeconds()
68 << " seconds from here: " << from_here.ToString(); 68 << " seconds from here: " << from_here.ToString();
69 69
70 PendingTask pending_task( 70 PendingTask pending_task(from_here, std::move(task),
71 from_here, task, CalculateDelayedRuntime(delay), nestable); 71 CalculateDelayedRuntime(delay), nestable);
72 #if defined(OS_WIN) 72 #if defined(OS_WIN)
73 // We consider the task needs a high resolution timer if the delay is 73 // We consider the task needs a high resolution timer if the delay is
74 // more than 0 and less than 32ms. This caps the relative error to 74 // more than 0 and less than 32ms. This caps the relative error to
75 // less than 50% : a 33ms wait can wake at 48ms since the default 75 // less than 50% : a 33ms wait can wake at 48ms since the default
76 // resolution on Windows is between 10 and 15ms. 76 // resolution on Windows is between 10 and 15ms.
77 if (delay > TimeDelta() && 77 if (delay > TimeDelta() &&
78 delay.InMilliseconds() < (2 * Time::kMinLowResolutionThresholdMs)) { 78 delay.InMilliseconds() < (2 * Time::kMinLowResolutionThresholdMs)) {
79 pending_task.is_high_res = true; 79 pending_task.is_high_res = true;
80 } 80 }
81 #endif 81 #endif
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // that wants to post a task will be blocked until this thread switches back 190 // that wants to post a task will be blocked until this thread switches back
191 // in and releases |incoming_queue_lock_|. 191 // in and releases |incoming_queue_lock_|.
192 if (schedule_work) 192 if (schedule_work)
193 message_loop_->ScheduleWork(); 193 message_loop_->ScheduleWork();
194 194
195 return true; 195 return true;
196 } 196 }
197 197
198 } // namespace internal 198 } // namespace internal
199 } // namespace base 199 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/incoming_task_queue.h ('k') | base/message_loop/message_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698