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

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

Issue 897173004: Increase warning threshold for "super long" delayed tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix 'unused variable' compile error on release builds. Created 5 years, 10 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 | no next file » | 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"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 14
15 namespace base { 15 namespace base {
16 namespace internal { 16 namespace internal {
17 17
18 namespace { 18 namespace {
19 19
20 // Delays larger than this many microseconds are often bogus, and a warning 20 #ifndef NDEBUG
21 // should be emitted in debug builds to warn developers. 21 // Delays larger than this are often bogus, and a warning should be emitted in
22 // http://crbug.com/450045 22 // debug builds to warn developers. http://crbug.com/450045
23 const int kTaskDelayWarningThresholdInMicroseconds = 23 const int kTaskDelayWarningThresholdInSeconds =
24 std::numeric_limits<int>::max() / 2; // A little less than 18 minutes. 24 14 * 24 * 60 * 60; // 14 days.
25 #endif
25 26
26 // Returns true if MessagePump::ScheduleWork() must be called one 27 // Returns true if MessagePump::ScheduleWork() must be called one
27 // time for every task that is added to the MessageLoop incoming queue. 28 // time for every task that is added to the MessageLoop incoming queue.
28 bool AlwaysNotifyPump(MessageLoop::Type type) { 29 bool AlwaysNotifyPump(MessageLoop::Type type) {
29 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
30 // The Android UI message loop needs to get notified each time a task is 31 // The Android UI message loop needs to get notified each time a task is
31 // added 32 // added
32 // to the incoming queue. 33 // to the incoming queue.
33 return type == MessageLoop::TYPE_UI || type == MessageLoop::TYPE_JAVA; 34 return type == MessageLoop::TYPE_UI || type == MessageLoop::TYPE_JAVA;
34 #else 35 #else
(...skipping 10 matching lines...) Expand all
45 message_loop_scheduled_(false), 46 message_loop_scheduled_(false),
46 always_schedule_work_(AlwaysNotifyPump(message_loop_->type())) { 47 always_schedule_work_(AlwaysNotifyPump(message_loop_->type())) {
47 } 48 }
48 49
49 bool IncomingTaskQueue::AddToIncomingQueue( 50 bool IncomingTaskQueue::AddToIncomingQueue(
50 const tracked_objects::Location& from_here, 51 const tracked_objects::Location& from_here,
51 const Closure& task, 52 const Closure& task,
52 TimeDelta delay, 53 TimeDelta delay,
53 bool nestable) { 54 bool nestable) {
54 DLOG_IF(WARNING, 55 DLOG_IF(WARNING,
55 delay.InMicroseconds() > kTaskDelayWarningThresholdInMicroseconds) 56 delay.InSeconds() > kTaskDelayWarningThresholdInSeconds)
56 << "Requesting super-long task delay period of " << delay.InMicroseconds() 57 << "Requesting super-long task delay period of " << delay.InSeconds()
57 << " usec from here: " << from_here.ToString(); 58 << " seconds from here: " << from_here.ToString();
58 59
59 AutoLock locked(incoming_queue_lock_); 60 AutoLock locked(incoming_queue_lock_);
60 PendingTask pending_task( 61 PendingTask pending_task(
61 from_here, task, CalculateDelayedRuntime(delay), nestable); 62 from_here, task, CalculateDelayedRuntime(delay), nestable);
62 #if defined(OS_WIN) 63 #if defined(OS_WIN)
63 // We consider the task needs a high resolution timer if the delay is 64 // We consider the task needs a high resolution timer if the delay is
64 // more than 0 and less than 32ms. This caps the relative error to 65 // more than 0 and less than 32ms. This caps the relative error to
65 // less than 50% : a 33ms wait can wake at 48ms since the default 66 // less than 50% : a 33ms wait can wake at 48ms since the default
66 // resolution on Windows is between 10 and 15ms. 67 // resolution on Windows is between 10 and 15ms.
67 if (delay > TimeDelta() && 68 if (delay > TimeDelta() &&
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // reload from the incoming queue before waiting again so we clear this flag 157 // reload from the incoming queue before waiting again so we clear this flag
157 // in ReloadWorkQueue(). 158 // in ReloadWorkQueue().
158 message_loop_scheduled_ = true; 159 message_loop_scheduled_ = true;
159 } 160 }
160 161
161 return true; 162 return true;
162 } 163 }
163 164
164 } // namespace internal 165 } // namespace internal
165 } // namespace base 166 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698