Title: [175110] branches/safari-600.3-branch/Source/WebCore

Diff

Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (175109 => 175110)


--- branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-10-23 09:26:59 UTC (rev 175109)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-10-23 09:28:01 UTC (rev 175110)
@@ -1,5 +1,32 @@
 2014-10-23  Babak Shafiei  <[email protected]>
 
+        Merge r173133.
+
+    2014-08-29  Gavin Barraclough  <[email protected]>
+
+            Make timerNestingLevel threadsafe
+            https://bugs.webkit.org/show_bug.cgi?id=136401
+
+            Reviewed by Tim Horton.
+
+            timerNestingLevel, used by DOMTimer to determine whether a timer is 'nested'
+            (repeating, possible due to a timer rescheduling itself) is a global. Since
+            worker threads can set timers too this is not thread safe.
+
+            * dom/ScriptExecutionContext.cpp:
+            (WebCore::ScriptExecutionContext::ScriptExecutionContext):
+                - added initialize m_timerNestingLevel
+            * dom/ScriptExecutionContext.h:
+            (WebCore::ScriptExecutionContext::timerNestingLevel):
+            (WebCore::ScriptExecutionContext::setTimerNestingLevel):
+                - added accessors
+            * page/DOMTimer.cpp:
+            (WebCore::DOMTimer::DOMTimer):
+            (WebCore::DOMTimer::fired):
+                - move timerNestingLevel to the context
+
+2014-10-23  Babak Shafiei  <[email protected]>
+
         Merge r173132.
 
     2014-08-29  Gavin Barraclough  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebCore/dom/ScriptExecutionContext.cpp (175109 => 175110)


--- branches/safari-600.3-branch/Source/WebCore/dom/ScriptExecutionContext.cpp	2014-10-23 09:26:59 UTC (rev 175109)
+++ branches/safari-600.3-branch/Source/WebCore/dom/ScriptExecutionContext.cpp	2014-10-23 09:28:01 UTC (rev 175110)
@@ -80,6 +80,7 @@
     , m_reasonForSuspendingActiveDOMObjects(static_cast<ActiveDOMObject::ReasonForSuspension>(-1))
     , m_activeDOMObjectsAreStopped(false)
     , m_activeDOMObjectAdditionForbidden(false)
+    , m_timerNestingLevel(0)
 #if !ASSERT_DISABLED
     , m_inScriptExecutionContextDestructor(false)
     , m_activeDOMObjectRemovalForbidden(false)

Modified: branches/safari-600.3-branch/Source/WebCore/dom/ScriptExecutionContext.h (175109 => 175110)


--- branches/safari-600.3-branch/Source/WebCore/dom/ScriptExecutionContext.h	2014-10-23 09:26:59 UTC (rev 175109)
+++ branches/safari-600.3-branch/Source/WebCore/dom/ScriptExecutionContext.h	2014-10-23 09:28:01 UTC (rev 175110)
@@ -175,6 +175,9 @@
     virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) = 0;
 #endif
 
+    int timerNestingLevel() const { return m_timerNestingLevel; }
+    void setTimerNestingLevel(int timerNestingLevel) { m_timerNestingLevel = timerNestingLevel; }
+
 protected:
     class AddConsoleMessageTask : public Task {
     public:
@@ -223,6 +226,7 @@
 #endif
 
     bool m_activeDOMObjectAdditionForbidden;
+    int m_timerNestingLevel;
 
 #if !ASSERT_DISABLED
     bool m_inScriptExecutionContextDestructor;

Modified: branches/safari-600.3-branch/Source/WebCore/page/DOMTimer.cpp (175109 => 175110)


--- branches/safari-600.3-branch/Source/WebCore/page/DOMTimer.cpp	2014-10-23 09:26:59 UTC (rev 175109)
+++ branches/safari-600.3-branch/Source/WebCore/page/DOMTimer.cpp	2014-10-23 09:28:01 UTC (rev 175110)
@@ -49,8 +49,6 @@
 static const int maxTimerNestingLevel = 5;
 static const double _oneMillisecond_ = 0.001;
 
-static int timerNestingLevel = 0;
-    
 static inline bool shouldForwardUserGesture(int interval, int nestingLevel)
 {
     return UserGestureIndicator::processingUserGesture()
@@ -60,7 +58,7 @@
 
 DOMTimer::DOMTimer(ScriptExecutionContext* context, std::unique_ptr<ScheduledAction> action, int interval, bool singleShot)
     : SuspendableTimer(context)
-    , m_nestingLevel(timerNestingLevel)
+    , m_nestingLevel(context->timerNestingLevel())
     , m_action(WTF::move(action))
     , m_originalInterval(interval)
     , m_shouldForwardUserGesture(shouldForwardUserGesture(interval, m_nestingLevel))
@@ -130,7 +128,7 @@
         ASSERT(!document->frame()->timersPaused());
     }
 #endif
-    timerNestingLevel = std::min(m_nestingLevel + 1, maxTimerNestingLevel);
+    context->setTimerNestingLevel(std::min(m_nestingLevel + 1, maxTimerNestingLevel));
 
     ASSERT(!isSuspended());
     ASSERT(!context->activeDOMObjectsAreSuspended());
@@ -192,7 +190,7 @@
 
     InspectorInstrumentation::didFireTimer(cookie);
 
-    timerNestingLevel = 0;
+    context->setTimerNestingLevel(0);
 }
 
 void DOMTimer::didStop()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to