Unreviewed, rolling out r142825.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2013 21:34:00 +0000 (21:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2013 21:34:00 +0000 (21:34 +0000)
http://trac.webkit.org/changeset/142825
https://bugs.webkit.org/show_bug.cgi?id=109856

Causes some inspector tests to time out (Requested by anttik
on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2013-02-14

* platform/mac/SharedTimerMac.mm:
(WebCore):
(WebCore::PowerObserver::restartSharedTimer):
(WebCore::setSharedTimerFireInterval):
(WebCore::stopSharedTimer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142907 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/SharedTimerMac.mm

index f8d507f27cafbd3e4289ecac93c01ac1e23d7005..d727e9b39f6c8a14708a83f6250d7659ada5b179 100644 (file)
@@ -1,3 +1,18 @@
+2013-02-14  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r142825.
+        http://trac.webkit.org/changeset/142825
+        https://bugs.webkit.org/show_bug.cgi?id=109856
+
+        Causes some inspector tests to time out (Requested by anttik
+        on #webkit).
+
+        * platform/mac/SharedTimerMac.mm:
+        (WebCore):
+        (WebCore::PowerObserver::restartSharedTimer):
+        (WebCore::setSharedTimerFireInterval):
+        (WebCore::stopSharedTimer):
+
 2013-02-14  Lamarque V. Souza  <Lamarque.Souza@basyskom.com>
 
         Support the ch unit from css3-values
index df8b36e24315654815e3e30d02f1b514eca8164a..3d01a33c7fbbe233d62115a7228fc5fc29005791 100644 (file)
@@ -42,8 +42,7 @@
 
 namespace WebCore {
 
-static const CFTimeInterval distantFuture = 60 * 60 * 24 * 365 * 10; // Decade.
-
+static CFRunLoopTimerRef sharedTimer;
 static void (*sharedTimerFiredFunction)();
 static void timerFired(CFRunLoopTimerRef, void*);
 
@@ -144,23 +143,14 @@ void PowerObserver::restartSharedTimer()
 {
     ASSERT(CFRunLoopGetCurrent() == CFRunLoopGetMain());
 
+    if (!sharedTimer)
+        return;
+
     stopSharedTimer();
     timerFired(0, 0);
 }
 
-static CFRunLoopTimerRef sharedTimer()
-{
-    static CFRunLoopTimerRef timer;
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-        timer = CFRunLoopTimerCreate(0, CFAbsoluteTimeGetCurrent() + distantFuture, distantFuture, 0, 0, timerFired, 0);
-        CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
-
-        static PowerObserver* powerObserver;
-        powerObserver = PowerObserver::create().leakPtr();
-    });
-    return timer;
-};
+static PowerObserver* PowerObserver;
 
 void setSharedTimerFiredFunction(void (*f)())
 {
@@ -180,13 +170,27 @@ static void timerFired(CFRunLoopTimerRef, void*)
 void setSharedTimerFireInterval(double interval)
 {
     ASSERT(sharedTimerFiredFunction);
+
+    if (sharedTimer) {
+        CFRunLoopTimerInvalidate(sharedTimer);
+        CFRelease(sharedTimer);
+    }
+
     CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + interval;
-    CFRunLoopTimerSetNextFireDate(sharedTimer(), fireDate);
+    sharedTimer = CFRunLoopTimerCreate(0, fireDate, 0, 0, 0, timerFired, 0);
+    CFRunLoopAddTimer(CFRunLoopGetCurrent(), sharedTimer, kCFRunLoopCommonModes);
+    
+    if (!PowerObserver)
+        PowerObserver = PowerObserver::create().leakPtr();
 }
 
 void stopSharedTimer()
 {
-    CFRunLoopTimerSetNextFireDate(sharedTimer(), CFAbsoluteTimeGetCurrent() + distantFuture);
+    if (sharedTimer) {
+        CFRunLoopTimerInvalidate(sharedTimer);
+        CFRelease(sharedTimer);
+        sharedTimer = 0;
+    }
 }
 
 } // namespace WebCore