WebCore:
authorbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Sep 2006 21:32:59 +0000 (21:32 +0000)
committerbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Sep 2006 21:32:59 +0000 (21:32 +0000)
        Reviewed by Tim Omernick

        Part of fixing a crash Tim O showed me that I missed in a release build.
        WebKit should be able to call through the bridge to WebCore no matter what -
        Replace the _iconDB member with calls to IconDatabase::sharedIconDatabase()

        * bridge/mac/WebCoreIconDatabaseBridge.h:
        * bridge/mac/WebCoreIconDatabaseBridge.mm:
        (-[WebCoreIconDatabaseBridge closeSharedDatabase]):
        (-[WebCoreIconDatabaseBridge isOpen]):
        (-[WebCoreIconDatabaseBridge removeAllIcons]):
        (-[WebCoreIconDatabaseBridge _isEmpty]):
        (-[WebCoreIconDatabaseBridge isIconExpiredForIconURL:]):
        (-[WebCoreIconDatabaseBridge setPrivateBrowsingEnabled:]):
        (-[WebCoreIconDatabaseBridge privateBrowsingEnabled]):
        (-[WebCoreIconDatabaseBridge iconForPageURL:withSize:]):
        (-[WebCoreIconDatabaseBridge iconURLForPageURL:]):
        (-[WebCoreIconDatabaseBridge defaultIconWithSize:]):
        (-[WebCoreIconDatabaseBridge retainIconForURL:]):
        (-[WebCoreIconDatabaseBridge releaseIconForURL:]):
        (-[WebCoreIconDatabaseBridge _setIconData:forIconURL:]):
        (-[WebCoreIconDatabaseBridge _setHaveNoIconForIconURL:]):
        (-[WebCoreIconDatabaseBridge _setIconURL:forPageURL:]):
        (-[WebCoreIconDatabaseBridge _hasEntryForIconURL:]):
        (-[WebCoreIconDatabaseBridge _setEnabled:]):
        (-[WebCoreIconDatabaseBridge _isEnabled]):

WebKit:

        Reviewed by Tim Omernick

        Fixing part of a crash Tim O showed me.  [WebIconDatabase init] should finish
        gracefully even if we can't open the database

        * Misc/WebIconDatabase.m:
        (-[WebIconDatabase init]):

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

WebCore/ChangeLog
WebCore/bridge/mac/WebCoreIconDatabaseBridge.h
WebCore/bridge/mac/WebCoreIconDatabaseBridge.mm
WebKit/ChangeLog
WebKit/Misc/WebIconDatabase.m

index 023bb37065405586c62683f4fba6510d40bedb21..c8fa60a6ffc744d56599c0e3a96fb8827bc5db3e 100644 (file)
@@ -1,3 +1,32 @@
+2006-09-20  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Tim Omernick
+
+        Part of fixing a crash Tim O showed me that I missed in a release build.
+        WebKit should be able to call through the bridge to WebCore no matter what -
+        Replace the _iconDB member with calls to IconDatabase::sharedIconDatabase()
+
+        * bridge/mac/WebCoreIconDatabaseBridge.h:
+        * bridge/mac/WebCoreIconDatabaseBridge.mm:
+        (-[WebCoreIconDatabaseBridge closeSharedDatabase]):
+        (-[WebCoreIconDatabaseBridge isOpen]):
+        (-[WebCoreIconDatabaseBridge removeAllIcons]):
+        (-[WebCoreIconDatabaseBridge _isEmpty]):
+        (-[WebCoreIconDatabaseBridge isIconExpiredForIconURL:]):
+        (-[WebCoreIconDatabaseBridge setPrivateBrowsingEnabled:]):
+        (-[WebCoreIconDatabaseBridge privateBrowsingEnabled]):
+        (-[WebCoreIconDatabaseBridge iconForPageURL:withSize:]):
+        (-[WebCoreIconDatabaseBridge iconURLForPageURL:]):
+        (-[WebCoreIconDatabaseBridge defaultIconWithSize:]):
+        (-[WebCoreIconDatabaseBridge retainIconForURL:]):
+        (-[WebCoreIconDatabaseBridge releaseIconForURL:]):
+        (-[WebCoreIconDatabaseBridge _setIconData:forIconURL:]):
+        (-[WebCoreIconDatabaseBridge _setHaveNoIconForIconURL:]):
+        (-[WebCoreIconDatabaseBridge _setIconURL:forPageURL:]):
+        (-[WebCoreIconDatabaseBridge _hasEntryForIconURL:]):
+        (-[WebCoreIconDatabaseBridge _setEnabled:]):
+        (-[WebCoreIconDatabaseBridge _isEnabled]):
+
 2006-09-20  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
index fedceedb5e8e01b9226d8e5d6f6a71aef26208a2..76ce0dccc05bc06d54ecda7d983a86f9ccede811 100644 (file)
@@ -32,9 +32,8 @@ typedef WebCore::IconDatabase WebCoreIconDatabase;
 @class WebCoreIconDatabase;
 #endif
 
-@interface WebCoreIconDatabaseBridge : NSObject
+@interface WebCoreIconDatabaseBridge : NSObject 
 {
-    WebCoreIconDatabase *_iconDB;
 }
 - (BOOL)openSharedDatabaseWithPath:(NSString *)path;
 - (void)closeSharedDatabase;
index 8ebad809dd4aff6eb79bc2601a9d4bd1cd84d47b..4037416e2a9ce60557252d45c4c822e98724566f 100644 (file)
@@ -37,66 +37,56 @@ using namespace WebCore;
 
 - (BOOL)openSharedDatabaseWithPath:(NSString *)path
 {
-    assert(path);
+    ASSERT(path);
     
-    _iconDB = IconDatabase::sharedIconDatabase();
-    if (_iconDB) {
-        _iconDB->open((String([path stringByStandardizingPath])));
-        if (!_iconDB->isOpen()) {
-            [self closeSharedDatabase];
-            NSLog(@"Unable to open icon database at %@ - Check your write permissions at that path.  Icon database will be disabled for this browsing session", path);
-            return NO;
-        }
-        return YES;
+    IconDatabase* iconDB = IconDatabase::sharedIconDatabase();
+    
+    iconDB->open((String([path stringByStandardizingPath])));
+    if (!iconDB->isOpen()) {
+        [self closeSharedDatabase];
+        NSLog(@"Unable to open icon database at %@ - Check your write permissions at that path.  Icon database will be disabled for this browsing session", path);
+        return NO;
     }
-    return NO;
+    return YES;
 }
 
 - (void)closeSharedDatabase
 {
-    delete _iconDB;
-    _iconDB = 0;
+    IconDatabase::sharedIconDatabase()->close();
 }
 
 - (BOOL)isOpen
 {
-    return _iconDB != 0;
+    return IconDatabase::sharedIconDatabase()->isOpen();
 }
 
 - (void)removeAllIcons
 {
-    if (_iconDB)
-        _iconDB->removeAllIcons();
+    IconDatabase::sharedIconDatabase()->removeAllIcons();
 }
 
 - (BOOL)_isEmpty
 {
-    return _iconDB ? _iconDB->isEmpty() : NO;
+    return IconDatabase::sharedIconDatabase()->isEmpty();
 }
 
 - (BOOL)isIconExpiredForIconURL:(NSString *)iconURL
 {
-    return _iconDB ? _iconDB->isIconExpiredForIconURL(iconURL) : NO;
+    return IconDatabase::sharedIconDatabase()->isIconExpiredForIconURL(iconURL);
 }
 
 - (void)setPrivateBrowsingEnabled:(BOOL)flag
 {
-    if (_iconDB)
-        _iconDB->setPrivateBrowsingEnabled(flag);
+    IconDatabase::sharedIconDatabase()->setPrivateBrowsingEnabled(flag);
 }
 
 - (BOOL)privateBrowsingEnabled
 {
-    if (_iconDB)
-        return _iconDB->getPrivateBrowsingEnabled();
-    return false;
+    return IconDatabase::sharedIconDatabase()->getPrivateBrowsingEnabled();
 }
 
 - (NSImage *)iconForPageURL:(NSString *)url withSize:(NSSize)size
 {
-    if (!_iconDB)
-        return nil;
-        
     ASSERT(url);
     ASSERT(size.width);
     ASSERT(size.height);
@@ -104,7 +94,7 @@ using namespace WebCore;
     // FIXME - We're doing the resize here for now because WebCore::Image doesn't yet support resizing/multiple representations
     // This makes it so there's effectively only one size of a particular icon in the system at a time.  We really need to move this
     // to WebCore::Image and WebCore::IconDatabase asap
-    Image* image = _iconDB->iconForPageURL(String(url), IntSize(size));
+    Image* image = IconDatabase::sharedIconDatabase()->iconForPageURL(String(url), IntSize(size));
     if (image) {
         NSImage* nsImage = image->getNSImage();
         if (!nsImage) {
@@ -124,22 +114,18 @@ using namespace WebCore;
 
 - (NSString *)iconURLForPageURL:(NSString *)url
 {
-    if (!_iconDB)
-        return nil;
     ASSERT(url);
     
-    String iconURL = _iconDB->iconURLForPageURL(String(url));
+    String iconURL = IconDatabase::sharedIconDatabase()->iconURLForPageURL(String(url));
     return (NSString*)iconURL;
 }
 
 - (NSImage *)defaultIconWithSize:(NSSize)size
 {
-    if (!_iconDB)
-        return nil;
     ASSERT(size.width);
     ASSERT(size.height);
     
-    Image* image = _iconDB->defaultIcon(IntSize(size));
+    Image* image = IconDatabase::sharedIconDatabase()->defaultIcon(IntSize(size));
     if (image)
         return image->getNSImage();
     return nil;
@@ -147,56 +133,44 @@ using namespace WebCore;
 
 - (void)retainIconForURL:(NSString *)url
 {
-    if (!_iconDB)
-        return;
     ASSERT(url);
-    _iconDB->retainIconForPageURL(String(url));
+    
+    IconDatabase::sharedIconDatabase()->retainIconForPageURL(String(url));
 }
 
 - (void)releaseIconForURL:(NSString *)url
 {
-    if (!_iconDB)
-        return;
     ASSERT(url);
-    _iconDB->releaseIconForPageURL(String(url));
+    
+    IconDatabase::sharedIconDatabase()->releaseIconForPageURL(String(url));
 }
 
 - (void)_setIconData:(NSData *)data forIconURL:(NSString *)iconURL
 {
-    if (!_iconDB)
-        return;
     ASSERT(data);
     ASSERT(iconURL);
     
-    _iconDB->setIconDataForIconURL([data bytes], [data length], String(iconURL));
+    IconDatabase::sharedIconDatabase()->setIconDataForIconURL([data bytes], [data length], String(iconURL));
 }
 
 - (void)_setHaveNoIconForIconURL:(NSString *)iconURL
 {
-    if (!_iconDB)
-        return;
     ASSERT(iconURL);
     
-    _iconDB->setHaveNoIconForIconURL(String(iconURL));
+    IconDatabase::sharedIconDatabase()->setHaveNoIconForIconURL(String(iconURL));
 }
 
 - (BOOL)_setIconURL:(NSString *)iconURL forPageURL:(NSString *)pageURL
 {
-    if (!_iconDB)
-        return NO;
     ASSERT(iconURL);
     ASSERT(pageURL);
     
-    return _iconDB->setIconURLForPageURL(String(iconURL), String(pageURL));
+    return IconDatabase::sharedIconDatabase()->setIconURLForPageURL(String(iconURL), String(pageURL));
 }
 
 - (BOOL)_hasEntryForIconURL:(NSString *)iconURL
-{
-    if (!_iconDB)
-        return NO;
-    ASSERT(iconURL);
-    
-    return _iconDB->hasEntryForIconURL(iconURL);
+{    
+    return IconDatabase::sharedIconDatabase()->hasEntryForIconURL(iconURL);
 }
 
 - (NSString *)defaultDatabaseFilename
@@ -206,14 +180,12 @@ using namespace WebCore;
 
 - (void)_setEnabled:(BOOL)enabled
 {
-    if (!_iconDB)
-        return;
-    _iconDB->setEnabled(enabled);
+    IconDatabase::sharedIconDatabase()->setEnabled(enabled);
 }
 
 - (BOOL)_isEnabled
 {
-    return _iconDB ? _iconDB->enabled() : NO;
+    return IconDatabase::sharedIconDatabase()->enabled();
 }
 
 
index f7a7258726c0c72bdcebe2fc0441a6109a1f7170..07478d4f45bba93d909e0b1cea9d4df191ef16df 100644 (file)
@@ -1,3 +1,13 @@
+2006-09-20  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Tim Omernick
+
+        Fixing part of a crash Tim O showed me.  [WebIconDatabase init] should finish
+        gracefully even if we can't open the database
+
+        * Misc/WebIconDatabase.m:
+        (-[WebIconDatabase init]):
+
 2006-09-20  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Tim O.
index 3b540c1b89e484f7cf04ea37fcc1f8f1e6036217..1c79c039a0cbe988a5d52aa3f9b7acc5838586f9 100644 (file)
@@ -108,20 +108,15 @@ NSSize WebIconLargeSize = {128, 128};
     }
     databaseDirectory = [databaseDirectory stringByExpandingTildeInPath];
     
-    // Open the WebCore icon database
-    if (![_private->databaseBridge openSharedDatabaseWithPath:databaseDirectory]) {
+    // Open the WebCore icon database and convert the old WebKit icon database if we haven't done the initial conversion yet
+    if (![_private->databaseBridge openSharedDatabaseWithPath:databaseDirectory])
         LOG_ERROR("Unable to open IconDatabaseBridge");
-        [_private->databaseBridge release];
-        _private->databaseBridge = nil;
-        return self;
-    }
+    else
+        if ([self _isEnabled])
+            [self _convertToWebCoreFormat];
+
     [_private->databaseBridge setPrivateBrowsingEnabled:[[WebPreferences standardPreferences] privateBrowsingEnabled]];
     
-    // <rdar://problem/4674552> New IconDB: New Safari icon database needs to convert from the old icons on first load 
-    // We call this method on each load - it determines, on its own, whether or not we actually need to do the conversion and 
-    // returns early if the conversion is already done
-    [self _convertToWebCoreFormat];
-    
     // Register for important notifications
     [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(_applicationWillTerminate:)