Title: [143795] trunk/Source/WebCore
Revision
143795
Author
benja...@webkit.org
Date
2013-02-22 14:15:21 -0800 (Fri, 22 Feb 2013)

Log Message

Use CFNotificationCenter instead of NSNotificationCenter for SharedTimerIOS
https://bugs.webkit.org/show_bug.cgi?id=110544

Patch by Benjamin Poulain <bpoul...@apple.com> on 2013-02-22
Reviewed by Daniel Bates.

Previously, we were instantiating the Obj-C object WebCoreResumeNotifierIOS
with the only purpose of forwarding one notification to a C function.

This patch updates the code to use CFNotificationCenter to dispatch the notification
without the intermediary object.

* platform/ios/SharedTimerIOS.mm:
(WebCore::applicationDidBecomeActive):
(WebCore::setSharedTimerFireInterval):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143794 => 143795)


--- trunk/Source/WebCore/ChangeLog	2013-02-22 22:12:47 UTC (rev 143794)
+++ trunk/Source/WebCore/ChangeLog	2013-02-22 22:15:21 UTC (rev 143795)
@@ -1,3 +1,20 @@
+2013-02-22  Benjamin Poulain  <bpoul...@apple.com>
+
+        Use CFNotificationCenter instead of NSNotificationCenter for SharedTimerIOS
+        https://bugs.webkit.org/show_bug.cgi?id=110544
+
+        Reviewed by Daniel Bates.
+
+        Previously, we were instantiating the Obj-C object WebCoreResumeNotifierIOS
+        with the only purpose of forwarding one notification to a C function.
+
+        This patch updates the code to use CFNotificationCenter to dispatch the notification
+        without the intermediary object.
+
+        * platform/ios/SharedTimerIOS.mm:
+        (WebCore::applicationDidBecomeActive):
+        (WebCore::setSharedTimerFireInterval):
+
 2013-02-22  Kenneth Russell  <k...@google.com>
 
         Uint8ClampedArray constructor is wrong in WorkerContext.idl

Modified: trunk/Source/WebCore/platform/ios/SharedTimerIOS.mm (143794 => 143795)


--- trunk/Source/WebCore/platform/ios/SharedTimerIOS.mm	2013-02-22 22:12:47 UTC (rev 143794)
+++ trunk/Source/WebCore/platform/ios/SharedTimerIOS.mm	2013-02-22 22:15:21 UTC (rev 143795)
@@ -34,35 +34,9 @@
 namespace WebCore {
 static CFRunLoopTimerRef sharedTimer;
 static void timerFired(CFRunLoopTimerRef, void*);
-}
 
-@interface WebCoreResumeNotifierIOS : NSObject
-- (void)didWake;
-@end
-
-@implementation WebCoreResumeNotifierIOS
-
-- (id)init
+static void applicationDidBecomeActive(CFNotificationCenterRef, void*, CFStringRef, const void*, CFDictionaryRef)
 {
-    if (!(self = [super init])) {
-        ASSERT_NOT_REACHED();
-        return nil;
-    }
-
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didWake) name:@"UIApplicationDidBecomeActiveNotification" object:nil];
-
-    return self;
-}
-
-- (void)dealloc
-{
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
-
-    [super dealloc];
-}
-
-- (void)didWake
-{
     WebThreadRun(^{
         if (!sharedTimer)
             return;
@@ -72,11 +46,6 @@
     });
 }
 
-@end
-
-namespace WebCore {
-
-static WebCoreResumeNotifierIOS *resumeNotifier;
 typedef void (*SharedTimerFiredFunction)();
 static SharedTimerFiredFunction sharedTimerFiredFunction;
 
@@ -108,8 +77,12 @@
     sharedTimer = CFRunLoopTimerCreate(0, fireDate, 0, 0, 0, timerFired, 0);
     CFRunLoopAddTimer(WebThreadRunLoop(), sharedTimer, kCFRunLoopCommonModes);
 
-    if (!resumeNotifier)
-        resumeNotifier = [[WebCoreResumeNotifierIOS alloc] init];
+    static bool registeredForApplicationNotification = false;
+    if (!registeredForApplicationNotification) {
+        registeredForApplicationNotification = true;
+        CFNotificationCenterRef notificationCenter = CFNotificationCenterGetLocalCenter();
+        CFNotificationCenterAddObserver(notificationCenter, 0, applicationDidBecomeActive, CFSTR("UIApplicationDidBecomeActiveNotification"), NULL, CFNotificationSuspensionBehaviorCoalesce);
+    }
 }
 
 void stopSharedTimer()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to