| OLD | NEW |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 bool IncomingTaskQueue::AddToIncomingQueue( | 51 bool IncomingTaskQueue::AddToIncomingQueue( |
| 52 const tracked_objects::Location& from_here, | 52 const tracked_objects::Location& from_here, |
| 53 const Closure& task, | 53 const Closure& task, |
| 54 TimeDelta delay, | 54 TimeDelta delay, |
| 55 bool nestable) { | 55 bool nestable) { |
| 56 DLOG_IF(WARNING, | 56 DLOG_IF(WARNING, |
| 57 delay.InSeconds() > kTaskDelayWarningThresholdInSeconds) | 57 delay.InSeconds() > kTaskDelayWarningThresholdInSeconds) |
| 58 << "Requesting super-long task delay period of " << delay.InSeconds() | 58 << "Requesting super-long task delay period of " << delay.InSeconds() |
| 59 << " seconds from here: " << from_here.ToString(); | 59 << " seconds from here: " << from_here.ToString(); |
| 60 | 60 |
| 61 PendingTask pending_task( |
| 62 from_here, task, CalculateDelayedRuntime(delay), nestable); |
| 61 AutoLock locked(incoming_queue_lock_); | 63 AutoLock locked(incoming_queue_lock_); |
| 62 PendingTask pending_task( | |
| 63 from_here, task, CalculateDelayedRuntime(delay), nestable); | |
| 64 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
| 65 // We consider the task needs a high resolution timer if the delay is | 65 // We consider the task needs a high resolution timer if the delay is |
| 66 // more than 0 and less than 32ms. This caps the relative error to | 66 // more than 0 and less than 32ms. This caps the relative error to |
| 67 // less than 50% : a 33ms wait can wake at 48ms since the default | 67 // less than 50% : a 33ms wait can wake at 48ms since the default |
| 68 // resolution on Windows is between 10 and 15ms. | 68 // resolution on Windows is between 10 and 15ms. |
| 69 if (delay > TimeDelta() && | 69 if (delay > TimeDelta() && |
| 70 delay.InMilliseconds() < (2 * Time::kMinLowResolutionThresholdMs)) { | 70 delay.InMilliseconds() < (2 * Time::kMinLowResolutionThresholdMs)) { |
| 71 ++high_res_task_count_; | 71 ++high_res_task_count_; |
| 72 pending_task.is_high_res = true; | 72 pending_task.is_high_res = true; |
| 73 } | 73 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // After we've scheduled the message loop, we do not need to do so again | 173 // After we've scheduled the message loop, we do not need to do so again |
| 174 // until we know it has processed all of the work in our queue and is | 174 // until we know it has processed all of the work in our queue and is |
| 175 // waiting for more work again. The message loop will always attempt to | 175 // waiting for more work again. The message loop will always attempt to |
| 176 // reload from the incoming queue before waiting again so we clear this flag | 176 // reload from the incoming queue before waiting again so we clear this flag |
| 177 // in ReloadWorkQueue(). | 177 // in ReloadWorkQueue(). |
| 178 message_loop_scheduled_ = true; | 178 message_loop_scheduled_ = true; |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace internal | 181 } // namespace internal |
| 182 } // namespace base | 182 } // namespace base |
| OLD | NEW |