| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const Closure& 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, task, CalculateDelayedRuntime(delay), |
| 71 from_here, task, CalculateDelayedRuntime(delay), nestable); | 71 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 Loading... |
| 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 |
| OLD | NEW |