WebCore:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Sep 2006 21:41:28 +0000 (21:41 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Sep 2006 21:41:28 +0000 (21:41 +0000)
        Reviewed by Brady.

        - a few small tweaks to the icon database bridge

        * bridge/mac/WebCoreIconDatabaseBridge.h: Removed unnecessary declarations.
        Renamed sharedBridgeInstance to sharedInstance.
        * bridge/mac/WebCoreIconDatabaseBridge.mm: Put functions inside WebCore namespace.
        (WebCore::IconDatabase::loadIconFromURL): Updated for sharedInstance namespace.

WebKit:

        Reviewed by Brady.

        - a few small tweaks to the icon database bridge

        * Misc/WebIconDatabase.m: (-[WebIconDatabase init]): Updated for name change.

        * WebCoreSupport/WebIconDatabaseBridge.h: Removed unneeded declarations.
        * WebCoreSupport/WebIconDatabaseBridge.m:
        (-[WebIconDatabaseBridge init]): Added. Always returns nil since you're not supposed
        to allocate one of these.
        (-[WebIconDatabaseBridge _init]): Renamed from init. Used internally to make the
        shared instance. Added the "self = [super init]" idiom even though it's not important
        in this case just to be consistent.
        (-[WebIconDatabaseBridge releaseCachedLoaderForIconURL:]): Moved this up in the file
        so it can be called without declaring it in the header.
        (+[WebIconDatabaseBridge sharedInstance]): Renamed. Calls the new _init. Also use
        CFRetain for compatibility.
        (-[WebIconDatabaseBridge dealloc]): Emptied this out and made it just assert (false).
        (-[WebIconDatabaseBridge finalize]): Added and made it assert (false) too.

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

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/WebCoreIconDatabaseBridge.h
WebCore/bridge/mac/WebCoreIconDatabaseBridge.mm
WebKit/ChangeLog
WebKit/Misc/WebIconDatabase.m
WebKit/WebCoreSupport/WebIconDatabaseBridge.h
WebKit/WebCoreSupport/WebIconDatabaseBridge.m
WebKit/WebKit.xcodeproj/project.pbxproj

index f9e1c9a4d2292a215547e9945d5fce656a253128..82aa947dad72983c9e067f97dffa5be242c04df3 100644 (file)
@@ -1,3 +1,14 @@
+2006-09-01  Darin Adler  <darin@apple.com>
+
+        Reviewed by Brady.
+
+        - a few small tweaks to the icon database bridge
+
+        * bridge/mac/WebCoreIconDatabaseBridge.h: Removed unnecessary declarations.
+        Renamed sharedBridgeInstance to sharedInstance.
+        * bridge/mac/WebCoreIconDatabaseBridge.mm: Put functions inside WebCore namespace.
+        (WebCore::IconDatabase::loadIconFromURL): Updated for sharedInstance namespace.
+
 2006-09-01  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Darin.
index 59064aec802bee2321439a6f4dcdd50ff71f211c..6cb3d3bda6b0c0b4506bf484a653bc91bc28a82e 100644 (file)
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
-                       projectRoot = "";
                        shouldCheckCompatibility = 1;
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
index 473ac14b695e72de476e723d1d6e4ff893df88a7..78e859f4e100c20fe681ab6d51277181f143bd8d 100644 (file)
 
 #ifdef __cplusplus
 namespace WebCore { 
-class IconDatabase; 
-class Image;
-class String;
-} 
+    class IconDatabase; 
+}
 typedef WebCore::IconDatabase WebCoreIconDatabase;
 #else
 @class WebCoreIconDatabase;
 #endif
-@class WebCoreIconDatabaseBridge;
 
 @interface WebCoreIconDatabaseBridge : NSObject
 {
-    WebCoreIconDatabaseBridge *_sharedInstance;
     WebCoreIconDatabase *_iconDB;
 }
 - (BOOL)openSharedDatabaseWithPath:(NSString *)path;
@@ -66,15 +62,13 @@ typedef WebCore::IconDatabase WebCoreIconDatabase;
 - (BOOL)_isEmpty;
 @end
 
-
 // The WebCoreIconDatabaseBridge protocol contains methods for use by the WebCore side of the bridge.
 
 @protocol WebCoreIconDatabaseBridge
-+ (WebCoreIconDatabaseBridge *)sharedBridgeInstance;
++ (WebCoreIconDatabaseBridge *)sharedInstance;
 - (void)loadIconFromURL:(NSString *)iconURL;
 @end
 
-
 // This interface definition allows those who hold a WebCoreIconDatabaseBridge * to call all the methods
 // in the WebCoreIconDatabaseBridge protocol without requiring the base implementation to supply the methods.
 // This idiom is appropriate because WebCoreIconDatabaseBridge is an abstract class.
index 54eba6d2059311d0360bbdedfd7c95421747d0fb..9a778ce49d5c248c2f19d4534e1720e978ed2088 100644 (file)
 
 using namespace WebCore;
 
+namespace WebCore {
 
-void WebCore::IconDatabase::loadIconFromURL(const String& url)
+void IconDatabase::loadIconFromURL(const String& url)
 {
     if (url.isEmpty())
         return;
-    [[WebCoreIconDatabaseBridge sharedBridgeInstance] loadIconFromURL:(NSString *)url];
+    [[WebCoreIconDatabaseBridge sharedInstance] loadIconFromURL:(NSString *)url];
+}
+
 }
 
 @implementation WebCoreIconDatabaseBridge
@@ -211,4 +214,5 @@ void WebCore::IconDatabase::loadIconFromURL(const String& url)
 {
     return IconDatabase::defaultDatabaseFilename();
 }
+
 @end
index 6fe8861b907fc04b8dbb8ec77749dfe3d319fe2a..c20ee71222534ec681a36c0c5a1722610ec09640 100644 (file)
@@ -1,3 +1,25 @@
+2006-09-01  Darin Adler  <darin@apple.com>
+
+        Reviewed by Brady.
+
+        - a few small tweaks to the icon database bridge
+
+        * Misc/WebIconDatabase.m: (-[WebIconDatabase init]): Updated for name change.
+
+        * WebCoreSupport/WebIconDatabaseBridge.h: Removed unneeded declarations.
+        * WebCoreSupport/WebIconDatabaseBridge.m:
+        (-[WebIconDatabaseBridge init]): Added. Always returns nil since you're not supposed
+        to allocate one of these.
+        (-[WebIconDatabaseBridge _init]): Renamed from init. Used internally to make the
+        shared instance. Added the "self = [super init]" idiom even though it's not important
+        in this case just to be consistent.
+        (-[WebIconDatabaseBridge releaseCachedLoaderForIconURL:]): Moved this up in the file
+        so it can be called without declaring it in the header.
+        (+[WebIconDatabaseBridge sharedInstance]): Renamed. Calls the new _init. Also use
+        CFRetain for compatibility.
+        (-[WebIconDatabaseBridge dealloc]): Emptied this out and made it just assert (false).
+        (-[WebIconDatabaseBridge finalize]): Added and made it assert (false) too.
+
 2006-09-01  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Adele.
index 5f7d3cfd4040d85c1f8c8617b60cef7cc218ea49..1e3a399656d85b10a1ad7bfd975ddaa0791349dc 100644 (file)
@@ -92,7 +92,7 @@ NSSize WebIconLargeSize = {128, 128};
     }
         
     // Get/create the shared database bridge - bail if we fail
-    _private->databaseBridge = [WebIconDatabaseBridge sharedBridgeInstance];
+    _private->databaseBridge = [WebIconDatabaseBridge sharedInstance];
     if (!_private->databaseBridge) {
         LOG_ERROR("Unable to create IconDatabaseBridge");
         return self;
index db2d0a1306891c78db5f02222ca2d232d84b710e..11596bd1aeae4957d8559acbe83693612bdc5546 100644 (file)
 
 #import <WebCore/WebCoreIconDatabaseBridge.h>
 
-@class WebDataSource;
-
 @interface WebIconDatabaseBridge : WebCoreIconDatabaseBridge <WebCoreIconDatabaseBridge>
 {
     NSMutableDictionary* cachedLoaders;
 }
-+ (WebCoreIconDatabaseBridge *)sharedBridgeInstance;
-- (void)releaseCachedLoaderForIconURL:(NSString*)iconURL;
-- (void)loadIconFromURL:(NSString *)iconURL;
-
 @end
index 7533072a615018503edaf076656f938ead2f202a..2e15ab3ac9416b5844f964b122272fb2b332fd7c 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <JavaScriptCore/Assertions.h>
 #import "WebIconDatabaseBridge.h"
-#import "WebIconDatabase.h"
+
 #import "WebIconDatabasePrivate.h"
 #import "WebIconLoader.h"
-
+#import <JavaScriptCore/Assertions.h>
 
 @implementation WebIconDatabaseBridge
 
+// Only sharedInstance is allowed to create the bridge.
+// Return nil if someone tries to init.
 - (id)init
 {
-    [super init];
+    [self release];
+    return nil;
+}
+
+- (id)_init
+{
+    self = [super init];
+    if (!self)
+        return nil;
     cachedLoaders = [[NSMutableDictionary alloc] init];
     return self;
 }
     [request release];
 }
 
+- (void)releaseCachedLoaderForIconURL:(NSString*)iconURL
+{
+    WebIconLoader *iconLoader = [cachedLoaders valueForKey:iconURL];
+    if (iconLoader) {
+        [iconLoader stopLoading];
+        [cachedLoaders removeObjectForKey:iconURL];
+    }
+}
+
 // FIXME rdar://4668102 - This is a likely place to add an NSNotification here to notify the app of the updated icon
 - (void)_setIconData:(NSData *)data forIconURL:(NSString *)iconURL
 {
     [super _setHaveNoIconForIconURL:iconURL];
 }
 
-- (void)releaseCachedLoaderForIconURL:(NSString*)iconURL
++ (WebCoreIconDatabaseBridge *)sharedInstance
 {
-    WebIconLoader *iconLoader = [cachedLoaders valueForKey:iconURL];
-    if (iconLoader) {
-        [iconLoader stopLoading];
-        [cachedLoaders removeObjectForKey:iconURL];
+    static WebCoreIconDatabaseBridge* bridge = nil;
+    if (!bridge) {
+        // Need to CFRetain something that's in a global variable, since we want it to
+        // hang around forever, even when running under GC.
+        bridge = [[WebIconDatabaseBridge alloc] _init];
+        CFRetain(bridge);
+        [bridge release];
     }
+    return bridge;
 }
 
-static WebCoreIconDatabaseBridge* g_sharedBridgeInstance = nil;
-+ (WebCoreIconDatabaseBridge *)sharedBridgeInstance
+- (void)dealloc
 {
-    if (!g_sharedBridgeInstance)
-        g_sharedBridgeInstance = [[WebIconDatabaseBridge alloc] init];
-    return g_sharedBridgeInstance;
+    // The single instance should be kept around forever, so this code should never be reached.
+    ASSERT(false);
+    [super dealloc];
 }
 
-- (void)dealloc
+- (void)finalize
 {
-    ASSERT(self == g_sharedBridgeInstance);
-    g_sharedBridgeInstance = nil;
-    [cachedLoaders release];
-    [super dealloc];
+    // The single instance should be kept around forever, so this code should never be reached.
+    ASSERT(false);
+    [super finalize];
 }
 
 @end
-
index 6943bd22373765eb727807f05d8250653e68e646..f68c4eb8cc15247aa5b0d15324940997afc02951 100644 (file)
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
-                       projectRoot = "";
                        targets = (
                                9398100A0824BF01008DF038 /* WebKit */,
                        );