WebKit:
authorbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 23:02:47 +0000 (23:02 +0000)
committerbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 23:02:47 +0000 (23:02 +0000)
Simple changes to hook up the new WebCore based Icon Database
for testing.
WebCore:
Added the beginnings of sqlite-based code in a WebCore
based version of the Icon Database.  Right now the code
is very loosely hooked up through a Bridge and only
creates an sqlite3 database.
There are also changes to our String classes to allow appending
a single character to a String without creating a temporary object.

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

17 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/WebCoreIconDatabaseBridge.h [new file with mode: 0644]
WebCore/bridge/mac/WebCoreIconDatabaseBridge.mm [new file with mode: 0644]
WebCore/icon/IconDatabase.cpp [new file with mode: 0644]
WebCore/icon/IconDatabase.h [new file with mode: 0644]
WebCore/platform/Logging.cpp
WebCore/platform/Logging.h
WebCore/platform/PlatformString.h
WebCore/platform/String.cpp
WebCore/platform/StringImpl.cpp
WebCore/platform/StringImpl.h
WebKit/ChangeLog
WebKit/Misc/WebIconDatabase.m
WebKit/Misc/WebIconDatabasePrivate.h
WebKit/WebKit.xcodeproj/project.pbxproj

index 8a3584903f7bb7b8ed95e410779488c2cb15b969..cdad059f135a18322cd5af921c88bdb5581c8ebf 100644 (file)
@@ -1,3 +1,56 @@
+2006-06-01  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Maciej.
+
+        Added the beginnings of sqlite-based code in a WebCore
+        based version of the Icon Database.  Right now the code
+        is very loosely hooked up through a Bridge and only
+        creates an sqlite3 database.
+
+        There are also changes to our String classes to allow appending
+        a single character to a String without creating a temporary object.
+
+        * WebCore.exp:
+        -Added a symbol export
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * bridge/mac/WebCoreIconDatabaseBridge.h: Added.
+        * bridge/mac/WebCoreIconDatabaseBridge.mm: Added.
+        (-[WebCoreIconDatabaseBridge openSharedDatabaseWithPath:]):
+        (-[WebCoreIconDatabaseBridge closeSharedDatabase]):
+        (-[WebCoreIconDatabaseBridge isOpen]):
+        -This class will eventually shadow WebIconDatabase but for now
+        is a minimal interface to make the sql code live
+
+        * icon: Added.
+        * icon/IconDatabase.cpp: Added.
+        -This class will eventually resemble WebIconDatabase but for now
+        is minimal just to make the sql code live
+        (WebCore::IconDatabase::sharedIconDatabase):
+        (WebCore::IconDatabase::IconDatabase):
+        (WebCore::IconDatabase::open):
+        -This method calls a mkdir to make sure the target directory
+        exists
+        (WebCore::IconDatabase::close):
+        (WebCore::IconDatabase::~IconDatabase):
+
+        * icon/IconDatabase.h: Added.
+        (WebCore::IconDatabase::isOpen):
+        * platform/Logging.cpp:
+        * platform/Logging.h:
+        -Added an IconDatabase logging channel
+
+        * platform/PlatformString.h:
+        * platform/String.cpp:
+        (WebCore::String::append):
+        * platform/StringImpl.cpp:
+        (WebCore::StringImpl::append):
+        * platform/StringImpl.h:
+        -Added append(char) and append(UChar) to allow appending a
+        single character without creating a temporary object.  Required
+        to facilitate manually adding a null character to a unicode 16
+        string
+
 2006-06-01  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed and landed by Anders.
index 6a9f954f0448ebf866b0fbd47d97091ca0cc8a5b..7d970d5ac4b16d966949d0498d591e5f4345044d 100644 (file)
 .objc_class_name_WebCoreFrameBridge
 .objc_class_name_WebCoreFrameNamespaces
 .objc_class_name_WebCoreHistory
+.objc_class_name_WebCoreIconDatabaseBridge
 .objc_class_name_WebCoreImageRendererFactory
 .objc_class_name_WebCoreJavaScript
 .objc_class_name_WebCoreKeyGenerator
index 449d6cf8b2ff948ea31f165365f937688f510b69..b9fe7bb84611c5be9989db733e5850b23187f4df 100644 (file)
                1AE2AEC80A1D297B00B42B25 /* JSHTMLQuoteElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE2AEC40A1D297B00B42B25 /* JSHTMLQuoteElement.h */; };
                1AE2AEE60A1D2A7500B42B25 /* JSHTMLBlockquoteElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE2AEE40A1D2A7500B42B25 /* JSHTMLBlockquoteElement.cpp */; };
                1AE2AEE70A1D2A7500B42B25 /* JSHTMLBlockquoteElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE2AEE50A1D2A7500B42B25 /* JSHTMLBlockquoteElement.h */; };
+               5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */; };
+               5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 5126E6BA0A2E3B12005C29FA /* IconDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5126E6BF0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 5126E6BD0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5126E6C00A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5126E6BE0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm */; };
                550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
                550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; };
                650F53DC09D15DDA00C9B0C8 /* CSSGrammar.h in Headers */ = {isa = PBXBuildFile; fileRef = 650F53DB09D15DDA00C9B0C8 /* CSSGrammar.h */; };
                2D90660B0665D937006B6F1A /* ClipboardMac.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardMac.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                2D90660C0665D937006B6F1A /* ClipboardMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClipboardMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconDatabase.cpp; sourceTree = "<group>"; };
+               5126E6BA0A2E3B12005C29FA /* IconDatabase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IconDatabase.h; sourceTree = "<group>"; };
+               5126E6BD0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreIconDatabaseBridge.h; sourceTree = "<group>"; };
+               5126E6BE0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreIconDatabaseBridge.mm; sourceTree = "<group>"; };
                5150C2A10702629000AF642C /* WebDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDashboardRegion.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                5150C2A50702629800AF642C /* WebDashboardRegion.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebDashboardRegion.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                51F6A3D50663BF04004D2919 /* HTMLCanvasElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLCanvasElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                F523D32402DE4478018635CA /* dom */,
                                93309D86099E64910056E581 /* editing */,
                                93EEC1EC09C2877700C515D1 /* html */,
+                               5126E6B60A2E3AEF005C29FA /* icon */,
                                A8C0FB51089701F700BA5114 /* kcanvas */,
                                A8C0F6E9089701F100BA5114 /* ksvg2 */,
                                F58785E802DE377601EA4122 /* kwq */,
                        path = impl;
                        sourceTree = "<group>";
                };
+               5126E6B60A2E3AEF005C29FA /* icon */ = {
+                       isa = PBXGroup;
+                       children = (
+                               5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */,
+                               5126E6BA0A2E3B12005C29FA /* IconDatabase.h */,
+                       );
+                       path = icon;
+                       sourceTree = "<group>";
+               };
                55998A57052B598F0017A6C1 /* Accessibility */ = {
                        isa = PBXGroup;
                        children = (
                                6552E7A8096AA11B0006F248 /* WebCoreFrameNamespaces.h */,
                                6552E7A9096AA11B0006F248 /* WebCoreFrameNamespaces.mm */,
                                F587854C02DE375901EA4122 /* WebCoreFrameView.h */,
+                               5126E6BD0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h */,
+                               5126E6BE0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm */,
                                F5B2A52B02E22573018635CB /* WebCoreJavaScript.h */,
                                F5B2A52C02E22573018635CB /* WebCoreJavaScript.mm */,
                                BE983D95052A2E0A00892D85 /* WebCoreKeyboardAccess.h */,
                                A833C1000A2C513300D57664 /* JSSVGTransform.h in Headers */,
                                A833C6D80A2CEA7700D57664 /* JSSVGElementWrapperFactory.h in Headers */,
                                A833C80D0A2CF25600D57664 /* XMLNames.h in Headers */,
+                               5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */,
+                               5126E6BF0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */,
                                A833C80C0A2CF25600D57664 /* XMLNames.cpp in Sources */,
                                A833C8520A2CF52800D57664 /* SVGElementFactory.cpp in Sources */,
+                               5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */,
+                               5126E6C00A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
                                OTHER_LDFLAGS = (
                                        "$(STYLE_LDFLAGS)",
+                                       "-lsqlite3",
                                        "-Wl,-exported_symbols_list,WebCore.exp,-Y,3",
                                );
                                PRODUCT_NAME = WebCore;
                                INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
                                OTHER_LDFLAGS = (
                                        "$(STYLE_LDFLAGS)",
+                                       "-lsqlite3",
                                        "-Wl,-exported_symbols_list,WebCore.exp,-Y,3",
                                );
                                PRODUCT_NAME = WebCore;
                                INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Frameworks";
                                OTHER_LDFLAGS = (
                                        "$(STYLE_LDFLAGS)",
+                                       "-lsqlite3",
                                        "-Wl,-exported_symbols_list,WebCore.exp,-Y,3",
                                );
                                PRODUCT_NAME = WebCore;
diff --git a/WebCore/bridge/mac/WebCoreIconDatabaseBridge.h b/WebCore/bridge/mac/WebCoreIconDatabaseBridge.h
new file mode 100644 (file)
index 0000000..8c81527
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifdef __cplusplus
+namespace WebCore { class IconDatabase; }
+typedef WebCore::IconDatabase WebCoreIconDatabase;
+#else
+@class WebCoreIconDatabase;
+#endif
+
+@interface WebCoreIconDatabaseBridge : NSObject
+{
+    WebCoreIconDatabase *_iconDB;
+}
+- (BOOL)openSharedDatabaseWithPath:(NSString *)path;
+- (void)closeSharedDatabase;
+- (BOOL)isOpen;
+@end
+
+
+
diff --git a/WebCore/bridge/mac/WebCoreIconDatabaseBridge.mm b/WebCore/bridge/mac/WebCoreIconDatabaseBridge.mm
new file mode 100644 (file)
index 0000000..050f1d2
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "WebCoreIconDatabaseBridge.h"
+
+#import "Logging.h"
+#import "IconDatabase.h"
+#import "PlatformString.h"
+
+using WebCore::IconDatabase;
+using WebCore::String;
+
+@implementation WebCoreIconDatabaseBridge
+
+- (BOOL)openSharedDatabaseWithPath:(NSString *)path;
+{
+    assert(path);
+    
+    _iconDB = IconDatabase::sharedIconDatabase();
+    if (_iconDB) {
+        _iconDB->open((String([path stringByStandardizingPath])));
+        return _iconDB->isOpen() ? YES : NO;
+    }
+    return NO;
+}
+
+- (void)closeSharedDatabase;
+{
+    LOG( IconDatabase, "Closing IconDatabase" );
+    if (_iconDB) {
+        _iconDB->close();
+        _iconDB = 0;
+    }
+}
+
+- (BOOL)isOpen;
+{
+    return _iconDB != 0;
+}
+@end
diff --git a/WebCore/icon/IconDatabase.cpp b/WebCore/icon/IconDatabase.cpp
new file mode 100644 (file)
index 0000000..f788bea
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#include "IconDatabase.h"
+
+#include "DeprecatedString.h"
+#include "Logging.h"
+#include "PlatformString.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+const char* DefaultIconDatabaseFilename = "/icon.db";
+
+namespace WebCore {
+
+IconDatabase* IconDatabase::m_sharedInstance = 0;
+
+IconDatabase* IconDatabase::sharedIconDatabase()
+{
+    if (!m_sharedInstance) {
+        m_sharedInstance = new IconDatabase();
+    }
+    return m_sharedInstance;
+}
+
+IconDatabase::IconDatabase() : m_db(0)
+{
+
+}
+
+bool IconDatabase::open(const String& databasePath)
+{
+    close();
+    
+    //Make sure directory exists
+    DeprecatedString ds = databasePath.deprecatedString();
+    const char* path = ds.ascii();
+    
+    struct stat dirInfo;
+    if (stat(path, &dirInfo)) {
+        LOG_ERROR("Unable to stat icon database path %s (%i)", path, errno);
+        return false;
+    }
+    if (dirInfo.st_mode & S_IRWXU != S_IRWXU) {
+        LOG_ERROR("Unable to access icon database path %s", path);
+        return false;
+    }
+        
+    String dbFilename = databasePath + DefaultIconDatabaseFilename;
+    //specifically include the null-terminator as sqlite3 expects it on unicode-16 strings
+    dbFilename.append('\0');
+    
+    int result = sqlite3_open16(dbFilename.characters(), &m_db);
+    if (result != SQLITE_OK) {
+        LOG_ERROR("SQLite database failed to load from %s\nCause - %s", dbFilename.ascii(),
+            sqlite3_errmsg(m_db));
+        sqlite3_close(m_db);
+        m_db = 0;
+    }
+    return m_db;
+}
+
+void IconDatabase::close()
+{
+    if (m_db) {
+        sqlite3_close(m_db);
+        m_db = 0;
+    }
+}
+
+IconDatabase::~IconDatabase()
+{
+    if (!m_db)
+        return;
+        
+    int result = sqlite3_close(m_db);
+    if (result != SQLITE_OK)
+        LOG_ERROR("IconDatabase SQLite database failed to close\n%s", sqlite3_errmsg(m_db));
+}
+
+} //namespace WebCore
+
diff --git a/WebCore/icon/IconDatabase.h b/WebCore/icon/IconDatabase.h
new file mode 100644 (file)
index 0000000..ff724ca
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#ifndef ICONDATABASE_H
+#define ICONDATABASE_H
+
+#include "config.h"
+
+#include "PlatformString.h"
+#include "sqlite3.h"
+
+namespace WebCore { 
+
+class IconDatabase
+{
+public:
+    static IconDatabase* sharedIconDatabase();
+    
+    void close();
+    bool open(const String& path);
+    bool isOpen() { return m_db; }
+    
+private:
+    IconDatabase();
+    ~IconDatabase();
+    
+    static IconDatabase* m_sharedInstance;
+    
+    sqlite3* m_db;
+
+};
+
+} //namespace WebCore
+
+#endif
index c816324c6fafbbaf0cb167a3a634f5fc6bae604b..695facd819a2d4aaa95291f0f5040deac20f6473 100644 (file)
@@ -36,3 +36,5 @@ WTFLogChannel LogPopupBlocking =     { 0x00000040, "WebCoreLogLevel", WTFLogChan
 WTFLogChannel LogEvents =            { 0x00000080, "WebCoreLogLevel", WTFLogChannelOff };
 WTFLogChannel LogEditing =           { 0x00000100, "WebCoreLogLevel", WTFLogChannelOff };
 WTFLogChannel LogTextConversion =    { 0x00000200, "WebCoreLogLevel", WTFLogChannelOff };
+
+WTFLogChannel LogIconDatabase =      { 0x00000400, "WebCoreLogLevel", WTFLogChannelOn };
index 4fec22a89be63f530ad3c68816b13d77ea92653e..30ad341fd1daaa379ee4bcd0d816b23ffb2d2fe8 100644 (file)
@@ -40,5 +40,6 @@ extern WTFLogChannel LogPopupBlocking;
 extern WTFLogChannel LogEvents;
 extern WTFLogChannel LogEditing;
 extern WTFLogChannel LogTextConversion;
+extern WTFLogChannel LogIconDatabase;
 
 #endif
index 62f6c838a2cb7fd4816921afc45e8c56d44468d0..74bb6d16064a834ecdac7314a6e337243a6e3591 100644 (file)
@@ -73,6 +73,8 @@ public:
         { return m_impl ? m_impl->endsWith(s.impl(), caseSensitive) : s.isEmpty(); }
 
     void append(const String&);
+    void append(char);
+    void append(UChar);
     void insert(const String&, unsigned pos);
 
     String& replace(UChar a, UChar b) { if (m_impl) m_impl = m_impl->replace(a, b); return *this; }
index a2d80eb5e743bf6a528e2021b76f84d337f06b55..3df632ee1137758a0c75ff6c15ca4454fd1bc1fc 100644 (file)
@@ -91,6 +91,22 @@ void String::append(const String &str)
     }
 }
 
+void String::append(char c)
+{
+    if (!m_impl)
+        m_impl = new StringImpl(&c, 1);
+    else 
+        m_impl->append(c);
+}
+
+void String::append(UChar c)
+{
+    if (!m_impl)
+        m_impl = new StringImpl(&c, 1);
+    else
+        m_impl->append(c);
+}
+
 String operator+(const String& a, const String& b)
 {
     if (a.isEmpty())
index 80e3074c7645d7acee6ee559d9bbdba66bcf62b7..20db7869e5209d500d06888fc97af3dd20a65ef5 100644 (file)
@@ -138,6 +138,22 @@ void StringImpl::append(const StringImpl* str)
     }
 }
 
+void StringImpl::append(char c)
+{
+    append(UChar(c));
+}
+
+void StringImpl::append(UChar c)
+{
+    assert(!m_inTable);
+    UChar* nc = newUCharVector(m_length + 1);
+    memcpy(nc, m_data, m_length * sizeof(UChar));
+    nc[m_length] = c;
+    deleteUCharVector(m_data);
+    m_data = nc;
+    m_length++;
+}
+
 void StringImpl::insert(const StringImpl* str, unsigned pos)
 {
     assert(!m_inTable);
index 5d29fc1371711ad49afd006022b77cbcf9c4e223..4cae00b4a41c938de432699c345811cb6ef65870 100644 (file)
@@ -69,6 +69,8 @@ public:
     static unsigned computeHash(const char*);
     
     void append(const StringImpl*);
+    void append(char);
+    void append(UChar);
     void insert(const StringImpl*, unsigned pos);
     void truncate(int len);
     void remove(unsigned pos, int len = 1);
index 2057b1f2c763f5d85f0118afc2e98db1db830a13..f33f795e1c31cac85385d7d48f1422d73dd96756 100644 (file)
@@ -1,3 +1,16 @@
+2006-06-01  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Maciej.
+
+        Simple changes to hook up the new WebCore based Icon Database
+        for testing.
+
+        * ChangeLog:
+        * Misc/WebIconDatabase.m:
+        (-[WebIconDatabase _applicationWillTerminate:]):
+        * Misc/WebIconDatabasePrivate.h:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2006-06-01  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
index b8f00873d4ff851c8b86816acf19db42cfb17041..5241cdc974aede15e87fab265123b2fb96f35414 100644 (file)
@@ -35,6 +35,8 @@
 #import <WebKit/WebNSURLExtras.h>
 #import <WebKit/WebPreferences.h>
 
+#import <WebCore/WebCoreIconDatabaseBridge.h>
+
 #import "WebTypesInternal.h"
 
 NSString * const WebIconDatabaseVersionKey =   @"WebIconDatabaseVersion";
@@ -52,6 +54,8 @@ NSString *WebIconDatabaseDidRemoveAllIconsNotification =   @"WebIconDatabaseDidR
 NSString *WebIconDatabaseDirectoryDefaultsKey = @"WebIconDatabaseDirectoryDefaultsKey";
 NSString *WebIconDatabaseEnabledDefaultsKey =   @"WebIconDatabaseEnabled";
 
+NSString *WebIconDatabasePath = @"~/Library/Safari/Icons";
+
 NSSize WebIconSmallSize = {16, 16};
 NSSize WebIconMediumSize = {32, 32};
 NSSize WebIconLargeSize = {128, 128};
@@ -118,6 +122,19 @@ NSSize WebIconLargeSize = {128, 128};
     [self _createFileDatabase];
     [self _loadIconDictionaries];
 
+    _private->databaseBridge = [[WebCoreIconDatabaseBridge alloc] init];
+    if (_private->databaseBridge) {
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        NSString *databaseDirectory = [defaults objectForKey:WebIconDatabaseDirectoryDefaultsKey];
+
+        if (!databaseDirectory) {
+            databaseDirectory = WebIconDatabasePath;
+            [defaults setObject:databaseDirectory forKey:WebIconDatabaseDirectoryDefaultsKey];
+        }
+        databaseDirectory = [databaseDirectory stringByExpandingTildeInPath];
+        [_private->databaseBridge openSharedDatabaseWithPath:databaseDirectory];
+    }
+    
     _private->iconURLToIcons = [[NSMutableDictionary alloc] init];
     _private->iconURLToExtraRetainCount = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, NULL);
     _private->pageURLToRetainCount = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, NULL);
@@ -601,6 +618,8 @@ NSSize WebIconLargeSize = {128, 128};
 {
     // Should only cause a write if user quit before 3 seconds after the last _updateFileDatabase
     [_private->fileDatabase sync];
+    
+    [_private->databaseBridge closeSharedDatabase];
 }
 
 - (int)_totalRetainCountForIconURLString:(NSString *)iconURLString
index 95cbdcdf898737cd54b46a4daf55d4280bd9c9c7..3d7f467cdbf442f595383d84219d00f5f9e8eaa6 100644 (file)
 #import <WebKit/WebIconDatabase.h>
 
 @class WebFileDatabase;
+@class WebCoreIconDatabaseBridge;
 
 @interface WebIconDatabasePrivate : NSObject {
 
 @public
     WebFileDatabase *fileDatabase;
+    WebCoreIconDatabaseBridge *databaseBridge;
 
     NSMutableDictionary *iconURLToIcons;
     NSMutableDictionary *iconURLToPageURLs;
index 22e07976b661e1af8a9a7eef7c99acc5f89dfd37..7dd012811da17aad0ccd5f2d5fae38838c89ccef 100644 (file)
                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               5139C0C70A265D25001AFADD /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               5139C0C80A265D25001AFADD /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXFileReference section */
                1C68F640095B5FC100C2984E /* webInspector */ = {isa = PBXFileReference; lastKnownFileType = folder; name = webInspector; path = WebInspector/webInspector; sourceTree = SOURCE_ROOT; };
                1C68F65C095B5FC100C2984E /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               5139C0C70A265D25001AFADD /* Development */,
+                               5139C0C80A265D25001AFADD /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,