| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/frame/DOMTimer.h" | 28 #include "core/frame/DOMTimer.h" |
| 29 | 29 |
| 30 #include "core/dom/ExecutionContext.h" | 30 #include "core/dom/ExecutionContext.h" |
| 31 #include "core/inspector/InspectorInstrumentation.h" | 31 #include "core/inspector/InspectorInstrumentation.h" |
| 32 #include "core/inspector/InspectorTraceEvents.h" | 32 #include "core/inspector/InspectorTraceEvents.h" |
| 33 #include "platform/TraceEvent.h" | 33 #include "platform/TraceEvent.h" |
| 34 #include "wtf/CurrentTime.h" | 34 #include "wtf/CurrentTime.h" |
| 35 | 35 |
| 36 using namespace std; |
| 37 |
| 36 namespace WebCore { | 38 namespace WebCore { |
| 37 | 39 |
| 38 static const int maxIntervalForUserGestureForwarding = 1000; // One second match
es Gecko. | 40 static const int maxIntervalForUserGestureForwarding = 1000; // One second match
es Gecko. |
| 39 static const int maxTimerNestingLevel = 5; | 41 static const int maxTimerNestingLevel = 5; |
| 40 static const double oneMillisecond = 0.001; | 42 static const double oneMillisecond = 0.001; |
| 41 // Chromium uses a minimum timer interval of 4ms. We'd like to go | 43 // Chromium uses a minimum timer interval of 4ms. We'd like to go |
| 42 // lower; however, there are poorly coded websites out there which do | 44 // lower; however, there are poorly coded websites out there which do |
| 43 // create CPU-spinning loops. Using 4ms prevents the CPU from | 45 // create CPU-spinning loops. Using 4ms prevents the CPU from |
| 44 // spinning too busily and provides a balance between CPU spinning and | 46 // spinning too busily and provides a balance between CPU spinning and |
| 45 // the smallest possible interval timer. | 47 // the smallest possible interval timer. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtr<ScheduledAction> action
, int interval, bool singleShot, int timeoutID) | 91 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtr<ScheduledAction> action
, int interval, bool singleShot, int timeoutID) |
| 90 : SuspendableTimer(context) | 92 : SuspendableTimer(context) |
| 91 , m_timeoutID(timeoutID) | 93 , m_timeoutID(timeoutID) |
| 92 , m_nestingLevel(timerNestingLevel + 1) | 94 , m_nestingLevel(timerNestingLevel + 1) |
| 93 , m_action(action) | 95 , m_action(action) |
| 94 { | 96 { |
| 95 ASSERT(timeoutID > 0); | 97 ASSERT(timeoutID > 0); |
| 96 if (shouldForwardUserGesture(interval, m_nestingLevel)) | 98 if (shouldForwardUserGesture(interval, m_nestingLevel)) |
| 97 m_userGestureToken = UserGestureIndicator::currentToken(); | 99 m_userGestureToken = UserGestureIndicator::currentToken(); |
| 98 | 100 |
| 99 double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillise
cond); | 101 double intervalMilliseconds = max(oneMillisecond, interval * oneMillisecond)
; |
| 100 if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNest
ingLevel) | 102 if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNest
ingLevel) |
| 101 intervalMilliseconds = minimumInterval; | 103 intervalMilliseconds = minimumInterval; |
| 102 if (singleShot) | 104 if (singleShot) |
| 103 startOneShot(intervalMilliseconds, FROM_HERE); | 105 startOneShot(intervalMilliseconds, FROM_HERE); |
| 104 else | 106 else |
| 105 startRepeating(intervalMilliseconds, FROM_HERE); | 107 startRepeating(intervalMilliseconds, FROM_HERE); |
| 106 } | 108 } |
| 107 | 109 |
| 108 DOMTimer::~DOMTimer() | 110 DOMTimer::~DOMTimer() |
| 109 { | 111 { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if (fireTime - alignedTimeRoundedDown < minimumInterval) | 202 if (fireTime - alignedTimeRoundedDown < minimumInterval) |
| 201 return alignedTimeRoundedDown; | 203 return alignedTimeRoundedDown; |
| 202 | 204 |
| 203 return alignedTimeRoundedUp; | 205 return alignedTimeRoundedUp; |
| 204 } | 206 } |
| 205 | 207 |
| 206 return fireTime; | 208 return fireTime; |
| 207 } | 209 } |
| 208 | 210 |
| 209 } // namespace WebCore | 211 } // namespace WebCore |
| OLD | NEW |