[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:55:27 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 11272aa3531e4c0c718fa39bbd6b695974d1376e
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Feb 11 19:05:40 2002 +0000

    2002-02-11  Kenneth Kocienda  <kocienda at apple.com>
    
        Added new files.
    
    	* CacheLoader.subproj/IFCachedObject.h:
    	* CacheLoader.subproj/IFCachedObject.m:
    	* CacheLoader.subproj/IFURLCacheLoaderConstants.h:
    	* CacheLoader.subproj/IFURLCacheLoaderConstants.m:
    
        Changed setRequestData to return BOOL to reflect fact that it might fail given
        the state of the handle.
    
    	* CacheLoader.subproj/IFHTTPURLHandle.h:
    	* CacheLoader.subproj/IFHTTPURLHandle.m: (-[IFHTTPURLHandle setRequestData:]):
    
    
        Added setResponseHeaders method, and cleaned up code that actually reads the
        stream to set headers.
    
    	* CacheLoader.subproj/IFHTTPURLProtocolHandler.m: (-[IFHTTPURLProtocolHandler
    	endLoadInBackground]), (-[IFHTTPURLProtocolHandler performHTTPHeaderRead:]),
    	(-[IFHTTPURLProtocolHandler setResponseHeaders:]):
    
    
        Modified class so that it is smart about attributes associated with cached data
        and not just the data itself. Added IFURLCacheObject class to help out with this.
    
        Tweaked cache object accessor interface.
    
    	* CacheLoader.subproj/IFURLCache.h:
    	* CacheLoader.subproj/IFURLCache.m: (-[IFURLCache objectForURL:]), (-[IFURLCache
    	cacheObject:forURL:withAttributes:untilDate:]), (-[IFURLCache
    	cacheObject:forURL:]), (-[IFURLCache setSizeLimit:]), (-[IFURLCache
    	initWithSizeLimit:]):
    	* CacheLoader.subproj/IFURLCacheObject.h:
    	* CacheLoader.subproj/IFURLCacheObject.m: (+[IFURLCacheObject
    	URLCacheObject:url:attributes:expiry:]), (-[IFURLCacheObject initWithCoder:]),
    	(-[IFURLCacheObject encodeWithCoder:]), (-[IFURLCacheObject object]),
    	(-[IFURLCacheObject url]), (-[IFURLCacheObject attributes]), (-[IFURLCacheObject
    	expiry]), (-[IFURLCacheObject dealloc]):
    
    
        Changed on-disk cache location from a URL to a path.
    
        Added implementation of disk caching with a file-per-URL database as the backing store.
    
    	* CacheLoader.subproj/IFURLDiskCache.h:
    	* CacheLoader.subproj/IFURLDiskCache.m: (-[IFURLDiskCache initWithSizeLimit:]),
    	(-[IFURLDiskCache initWithSizeLimit:path:]), (-[IFURLDiskCache objectForURL:]),
    	(-[IFURLDiskCache cacheObject:forURL:]), (-[IFURLDiskCache containsURL:]),
    	(-[IFURLDiskCache invalidateURL:]):
    
    
    	Removed fromStream:(CFReadStreamRef)stream from interface. The need to pass this has been
    	obsoleted by the creation of protocol handler classes.
    
    	Fixed a bug that assumed we always get back a no-copy data object from the network. The
    	disk cache does not return such objects.
    
    	* CacheLoader.subproj/IFURLHandle.h:
    	* CacheLoader.subproj/IFURLHandle.m: (+[IFURLHandle initialize]), (-[IFURLHandle
    	didLoadData:]), (-[IFURLHandle notifyClientsDidLoadData]):
    	* CacheLoader.subproj/IFURLHandleC.h:
    	* CacheLoader.subproj/IFURLHandleC.m: (IFURLHandleDidLoadData):
    	* CacheLoader.subproj/IFURLHandleConstants.h:
    
    
        Much work to support the on-disk cache, and returning attributes with cached objects.
    
    	* CacheLoader.subproj/IFURLLoad.h:
    	* CacheLoader.subproj/IFURLLoad.m: (-[IFURLLoad initWithURL:flags:]),
    	(-[IFURLLoad setResourceData:]), (-[IFURLLoad updateHandlesWithData]),
    	(-[IFURLLoad cleanup]), (+[IFURLLoad IFURLLoadCacheCheckerRun:]):
    	* CacheLoader.subproj/IFURLLoadManager.h:
    	* CacheLoader.subproj/IFURLLoadManager.m: (-[IFURLLoadManager
    	initWithDefaultStack]), (-[IFURLLoadManager cacheObjectForURL:]),
    	(-[IFURLLoadManager cacheObject:forURL:withAttributes:untilDate:]),
    	(-[IFURLLoadManager handleURLLoadDone:]), (-[IFURLLoadManager
    	handleURLLoadedResourceData:]):
    
    
        Changed internal IFMemoryCacheObject so that it subclasses the new IFCacheObject.
    
        Now supports returning attributes with cached objects.
    
    	* CacheLoader.subproj/IFURLMemoryCache.m: (+[IFMemoryCacheObject
    	memoryCacheObjectWithObject:url:attributes:expiry:]), (-[IFMemoryCacheObject
    	setExpiration:]), (-[IFMemoryCacheObject expire]), (-[IFMemoryCacheObject
    	isExpired]), (-[IFMemoryCacheObject dealloc]), (-[IFURLMemoryCache
    	truncateToSizeLimit]), (-[IFURLMemoryCache objectForURL:]):
    
    
        Added database subproj.
    
    	* Database.subproj/IFDatabase.h:
    	* Database.subproj/IFDatabase.m: (-[IFDatabase setObject:forKey:]), (-[IFDatabase
    	removeObjectForKey:]), (-[IFDatabase objectForKey:]), (-[IFDatabase keys]),
    	(-[IFDatabase count]), (-[IFDatabase initWithPath:]), (-[IFDatabase dealloc]),
    	(-[IFDatabase open]), (-[IFDatabase close]), (-[IFDatabase sync]), (-[IFDatabase
    	path]), (-[IFDatabase isOpen]):
    	* Database.subproj/IFNDBMDatabase.h:
    	* Database.subproj/IFNDBMDatabase.m: (-[IFNDBMDatabase initWithPath:]),
    	(-[IFNDBMDatabase dealloc]), (-[IFNDBMDatabase setObject:forKey:]),
    	(-[IFNDBMDatabase removeObjectForKey:]), (-[IFNDBMDatabase objectForKey:]),
    	(-[IFNDBMDatabase keys]), (-[IFNDBMDatabase open]), (-[IFNDBMDatabase close]),
    	(-[IFNDBMDatabase sync]):
    	* Database.subproj/IFURLFileDatabase.h:
    	* Database.subproj/IFURLFileDatabase.m: (+[IFURLFileDatabase initialize]),
    	(-[IFURLFileDatabase initWithPath:]), (-[IFURLFileDatabase dealloc]),
    	(+[IFURLFileDatabase uniqueFilePathForKey:]), (-[IFURLFileDatabase
    	setObject:forKey:]), (-[IFURLFileDatabase removeObjectForKey:]),
    	(-[IFURLFileDatabase objectForKey:]), (-[IFURLFileDatabase keys]),
    	(-[IFURLFileDatabase open]), (-[IFURLFileDatabase close]), (-[IFURLFileDatabase
    	sync]):
    	* Misc.subproj/IFMutableDataPrivate.m: (-[IFData
    	initWithBytes:length:copy:freeWhenDone:bytesAreVM:]):
    
    
        Added class.
    
    	* Misc.subproj/IFNSFileManagerExtensions.h:
    	* Misc.subproj/IFNSFileManagerExtensions.m: (-[NSFileManager
    	createDirectoryAtPathWithIntermediateDirectories:attributes:]), (-[NSFileManager
    	createFileAtPathWithIntermediateDirectories:contents:attributes:directoryAttribut
    	es:]), (-[NSFileManager createIntermediateDirectoriesForPath:attributes:]):
    
    
        Removed obsoleted IFContentType.
    
    	* Misc.subproj/WebFoundation.h:
    	* WebFoundation.pbproj/project.pbxproj:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@609 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/Misc.subproj/WebDatabase.h b/WebKit/Misc.subproj/WebDatabase.h
new file mode 100644
index 0000000..87472bd
--- /dev/null
+++ b/WebKit/Misc.subproj/WebDatabase.h
@@ -0,0 +1,40 @@
+/*	IFDatabase.h
+	Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+
+ at interface IFDatabase : NSObject 
+{
+    NSString *path;
+    unsigned count;
+    BOOL isOpen;
+}
+
+-(void)setObject:(id)object forKey:(id)key;
+-(void)removeObjectForKey:(id)key;
+-(id)objectForKey:(id)key;
+-(NSEnumerator *)keys;
+-(unsigned)count;
+
+ at end
+
+
+ at interface IFDatabase (IFDatabaseCreation)
+
+-(id)initWithPath:(NSString *)thePath;
+
+ at end
+
+
+ at interface IFDatabase (IFDatabaseManagement)
+
+-(BOOL)open;
+-(BOOL)close;
+-(void)sync;
+
+-(NSString *)path;
+-(BOOL)isOpen;
+
+ at end
diff --git a/WebKit/Misc.subproj/WebDatabase.m b/WebKit/Misc.subproj/WebDatabase.m
new file mode 100644
index 0000000..22240e3
--- /dev/null
+++ b/WebKit/Misc.subproj/WebDatabase.m
@@ -0,0 +1,100 @@
+/*	IFDatabase.m
+	Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/NSPrivateDecls.h>
+#import "IFDatabase.h"
+
+// implementation IFDatabase ------------------------------------------------------------------------
+
+ at implementation IFDatabase
+
+-(void)setObject:(id)object forKey:(id)key
+{
+    NSRequestConcreteImplementation(self, _cmd, [IFDatabase class]);
+}
+
+-(void)removeObjectForKey:(id)key
+{
+    NSRequestConcreteImplementation(self, _cmd, [IFDatabase class]);
+}
+
+-(id)objectForKey:(id)key
+{
+    NSRequestConcreteImplementation(self, _cmd, [IFDatabase class]);
+    return nil;
+}
+
+-(NSEnumerator *)keys
+{
+    NSRequestConcreteImplementation(self, _cmd, [IFDatabase class]);
+    return nil;
+}
+
+-(unsigned)count
+{
+    return count;
+}
+
+ at end
+
+
+// implementation IFDatabase (IFDatabaseCreation) --------------------------------------------------------
+
+ at implementation IFDatabase (IFDatabaseCreation)
+
+-(id)initWithPath:(NSString *)thePath
+{
+    if ((self = [super init])) {
+    
+        path = [[NSString alloc] initWithString:[thePath stringByStandardizingPath]];
+        isOpen = NO;
+    
+        return self;
+    }
+    
+    return nil;
+}
+
+-(void)dealloc
+{
+    [path release];
+
+    [super dealloc];
+}
+
+ at end
+
+
+// implementation IFDatabase (IFDatabaseManagement) ------------------------------------------------------
+
+ at implementation IFDatabase (IFDatabaseManagement)
+
+-(BOOL)open
+{
+    NSRequestConcreteImplementation(self, _cmd, [IFDatabase class]);
+    return NO;
+}
+
+-(BOOL)close
+{
+    NSRequestConcreteImplementation(self, _cmd, [IFDatabase class]);
+    return NO;
+}
+
+-(void)sync
+{
+    NSRequestConcreteImplementation(self, _cmd, [IFDatabase class]);
+}
+
+-(NSString *)path
+{
+    return path;
+}
+
+-(BOOL)isOpen
+{
+    return isOpen;
+}
+
+ at end
diff --git a/WebKit/Misc.subproj/WebFileDatabase.h b/WebKit/Misc.subproj/WebFileDatabase.h
new file mode 100644
index 0000000..bedcf77
--- /dev/null
+++ b/WebKit/Misc.subproj/WebFileDatabase.h
@@ -0,0 +1,11 @@
+/*	IFURLFileDatabase.h
+	Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+#import "IFDatabase.h"
+
+
+ at interface IFURLFileDatabase : IFDatabase 
+ at end
diff --git a/WebKit/Misc.subproj/WebFileDatabase.m b/WebKit/Misc.subproj/WebFileDatabase.m
new file mode 100644
index 0000000..e96f5a4
--- /dev/null
+++ b/WebKit/Misc.subproj/WebFileDatabase.m
@@ -0,0 +1,203 @@
+/*	IFURLFileDatabase.m
+	Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFURLFileDatabase.h"
+#import "IFNSFileManagerExtensions.h"
+
+static NSNumber *IFURLFileDirectoryPosixPermissions;
+static NSNumber *IFURLFilePosixPermissions;
+
+// implementation IFURLFileDatabase -------------------------------------------------------------
+
+ at implementation IFURLFileDatabase
+
+// creation functions ---------------------------------------------------------------------------
+#pragma mark creation functions
+
++(void)initialize
+{
+    // set file perms to owner read/write/execute only
+    IFURLFileDirectoryPosixPermissions = [[NSNumber numberWithInt:700] retain];
+
+    // set file perms to owner read/write only
+    IFURLFilePosixPermissions = [[NSNumber numberWithInt:600] retain];
+}
+
+-(id)initWithPath:(NSString *)thePath
+{
+    if ((self = [super initWithPath:thePath])) {
+        return self;
+    }
+    
+    return nil;
+}
+
+-(void)dealloc
+{
+    [self close];
+
+    [super dealloc];
+}
+
++(NSString *)uniqueFilePathForKey:(id)key
+{
+    const char *s;
+    UInt32 hash1;
+    UInt32 hash2;
+    CFIndex len;
+    CFIndex cnt;
+
+    s = [[[[key description] lowercaseString] stringByStandardizingPath] lossyCString];
+    len = strlen(s);
+
+    // compute first hash    
+    hash1 = len;
+    for (cnt = 0; cnt < len; cnt++) {
+        hash1 += (hash1 << 8) + s[cnt];
+    }
+    hash1 += (hash1 << (len & 31));
+
+    // compute second hash    
+    hash2 = len;
+    for (cnt = 0; cnt < len; cnt++) {
+        hash2 = (37 * hash2) ^ s[cnt];
+    }
+
+    // create the path and return it
+    return [NSString stringWithFormat:@"%.2u/%.2u/%.10u-%.10u.cache", ((hash1 & 0xff) >> 4), ((hash2 & 0xff) >> 4), hash1, hash2];
+}
+
+// database functions ---------------------------------------------------------------------------
+#pragma mark database functions
+
+
+-(void)setObject:(id)object forKey:(id)key
+{
+    BOOL result;
+    NSString *filePath;
+    NSMutableData *data;
+    NSDictionary *attributes;
+    NSDictionary *directoryAttributes;
+    NSArchiver *archiver;
+
+    result = NO;
+
+    data = [NSMutableData data];
+    archiver = [[NSArchiver alloc] initForWritingWithMutableData:data];
+    [archiver encodeRootObject:key];
+    [archiver encodeRootObject:object];
+    
+    // FIXME: set attributes
+    attributes = [NSDictionary dictionaryWithObjectsAndKeys:
+        [NSDate date], @"NSFileModificationDate",
+        NSUserName(), @"NSFileOwnerAccountName",
+        NULL
+    ];
+
+    directoryAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
+        [NSDate date], @"NSFileModificationDate",
+        NSUserName(), @"NSFileOwnerAccountName",
+        NULL
+    ];
+
+//        IFURLFilePosixPermissions, @"NSFilePosixPermissions",
+    filePath = [NSString stringWithFormat:@"%@/%@", path, [IFURLFileDatabase uniqueFilePathForKey:key]];
+    result = [[NSFileManager defaultManager] createFileAtPathWithIntermediateDirectories:filePath contents:data attributes:attributes directoryAttributes:directoryAttributes];
+
+    [archiver release];
+
+    NSLog(@"IFURLFileDatabase wrote file: [%@] %@", result ? @"YES" : @"NO", filePath);
+    
+    //return result;
+}
+
+-(void)removeObjectForKey:(id)key
+{
+    NSString *filePath;
+
+    filePath = [NSString stringWithFormat:@"%@/%@", path, [IFURLFileDatabase uniqueFilePathForKey:key]];
+    [[NSFileManager defaultManager] removeFileAtPath:filePath handler:nil];
+}
+
+-(id)objectForKey:(id)key
+{
+    id result;
+    id fileKey;
+    id object;
+    NSString *filePath;
+    NSData *data;
+    NSUnarchiver *unarchiver;
+        
+    result = nil;
+    fileKey = nil;
+
+    filePath = [NSString stringWithFormat:@"%@/%@", path, [IFURLFileDatabase uniqueFilePathForKey:key]];
+    
+    data = [[NSFileManager defaultManager] contentsAtPath:filePath];
+    if (data) {
+        unarchiver = [[NSUnarchiver alloc] initForReadingWithData:data];
+        fileKey = [unarchiver decodeObject];
+        object = [unarchiver decodeObject];
+        if ([fileKey isEqual:key]) {
+            // FIXME: should not be retained
+            result = [object retain];
+            [result autorelease];
+        }
+        [unarchiver release];
+    }
+
+    return result;
+}
+
+-(NSEnumerator *)keys
+{
+    // FIXME: implement this
+    return nil;
+}
+
+
+// database management functions ---------------------------------------------------------------------------
+#pragma mark database management functions
+
+-(BOOL)open
+{
+    NSFileManager *manager;
+    BOOL isDir;
+    
+    if (!isOpen) {
+        manager = [NSFileManager defaultManager];
+        if ([manager fileExistsAtPath:path isDirectory:&isDir]) {
+            if (isDir) {
+                isOpen = YES;
+            }
+        }
+        else {
+            isOpen = [manager createDirectoryAtPathWithIntermediateDirectories:path attributes:[NSDictionary dictionaryWithObjectsAndKeys:
+                [NSDate date], @"NSFileModificationDate",
+                NSUserName(), @"NSFileOwnerAccountName",
+                NULL
+            ]];
+        }
+    }
+    
+    return isOpen;
+}
+//                IFURLFileDirectoryPosixPermissions, @"NSFilePosixPermissions",
+
+
+-(BOOL)close
+{
+    if (isOpen) {
+        isOpen = NO;
+    }
+    
+    return YES;
+}
+
+-(void)sync
+{
+    // no-op for this kind of database
+}
+
+ at end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list