[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 07:42:28 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit fdbec7fa5011c9905912e7fc20e527344ee9127c
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri May 16 16:07:34 2003 +0000
WebFoundation:
Reviewed by Gramps
Moved WebDatabase and WebFileDatabase files to WebKit
Twiddled some logging constants now that the WebFileDatabase
has been removed from the framework.
Updated StringsNotToBeLocalized.txt.
* Database.subproj/NSLRUFileList.m:
(NSLRUFileListRemoveOldestFileFromList):
* Database.subproj/WebDatabase.h: Removed.
* Database.subproj/WebDatabase.m: Removed.
* Database.subproj/WebFileDatabase.h: Removed.
* Database.subproj/WebFileDatabase.m: Removed.
* English.lproj/StringsNotToBeLocalized.txt:
* Misc.subproj/NSURLLogging.h:
* Misc.subproj/NSURLLogging.m:
* WebFoundation.pbproj/project.pbxproj:
WebKit:
Reviewed by Gramps
Moved in WebDatabase and WebFileDatabase files from WebFoundation.
Copied NSLRUFileList from WebFoundation and renamed to WebLRUFileList.
Updated StringsNotToBeLocalized.txt.
* English.lproj/StringsNotToBeLocalized.txt:
* Misc.subproj/WebDatabase.h:
* Misc.subproj/WebDatabase.m:
* Misc.subproj/WebFileDatabase.h:
* Misc.subproj/WebFileDatabase.m:
(-[WebFileDatabaseOp initWithCode:key:object:]):
(-[WebFileDatabaseOp perform:]):
(SetThreadPriority):
(-[WebFileDatabase _createLRUList:]):
(-[WebFileDatabase _truncateToSizeLimit:]):
(+[WebFileDatabase _syncLoop:]):
(-[WebFileDatabase setObject:forKey:]):
(-[WebFileDatabase removeObjectForKey:]):
(-[WebFileDatabase removeAllObjects]):
(-[WebFileDatabase objectForKey:]):
(-[WebFileDatabase performSetObject:forKey:]):
(-[WebFileDatabase performRemoveObjectForKey:]):
(-[WebFileDatabase close]):
(-[WebFileDatabase lazySync:]):
(-[WebFileDatabase sync]):
(-[WebFileDatabase count]):
(-[WebFileDatabase usage]):
* Misc.subproj/WebIconDatabase.m:
* Misc.subproj/WebKitLogging.h:
* Misc.subproj/WebKitLogging.m:
* Misc.subproj/WebLRUFileList.h: Added.
* Misc.subproj/WebLRUFileList.m: Added.
(WebLRUFileListCreate):
(WebLRUFileListRelease):
(WebLRUFileListRebuildFileDataUsingRootDirectory):
(WebLRUFileListRemoveFileWithPath):
(WebLRUFileListTouchFileWithPath):
(WebLRUFileListSetFileData):
(WebLRUFileListGetPathOfOldestFile):
(WebLRUFileListRemoveOldestFileFromList):
(WebLRUFileListContainsItem):
(WebLRUFileListGetFileSize):
(WebLRUFileListCountItems):
(WebLRUFileListGetTotalSize):
(WebLRUFileListRemoveAllFilesFromList):
(compareTimes):
(cStringEqual):
(cStringHash):
(NSLRUFileDataEqual):
(WebLRUFileListGetOldestFileData):
(NSLRUFileDataReleaseApplierFunction):
(NSLRUFileDataRelease):
(NSLRUFileDataBinaryHeapDumpApplierFunction):
(NSLRUFileDataDictDumpApplierFunction):
(WebLRUFileListDescription):
* WebKit.pbproj/project.pbxproj:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 0daccb6..d3256ef 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,65 @@
+2003-05-16 Ken Kocienda <kocienda at apple.com>
+
+ Reviewed by Gramps
+
+ Moved in WebDatabase and WebFileDatabase files from WebFoundation.
+
+ Copied NSLRUFileList from WebFoundation and renamed to WebLRUFileList.
+
+ Updated StringsNotToBeLocalized.txt.
+
+ * English.lproj/StringsNotToBeLocalized.txt:
+ * Misc.subproj/WebDatabase.h:
+ * Misc.subproj/WebDatabase.m:
+ * Misc.subproj/WebFileDatabase.h:
+ * Misc.subproj/WebFileDatabase.m:
+ (-[WebFileDatabaseOp initWithCode:key:object:]):
+ (-[WebFileDatabaseOp perform:]):
+ (SetThreadPriority):
+ (-[WebFileDatabase _createLRUList:]):
+ (-[WebFileDatabase _truncateToSizeLimit:]):
+ (+[WebFileDatabase _syncLoop:]):
+ (-[WebFileDatabase setObject:forKey:]):
+ (-[WebFileDatabase removeObjectForKey:]):
+ (-[WebFileDatabase removeAllObjects]):
+ (-[WebFileDatabase objectForKey:]):
+ (-[WebFileDatabase performSetObject:forKey:]):
+ (-[WebFileDatabase performRemoveObjectForKey:]):
+ (-[WebFileDatabase close]):
+ (-[WebFileDatabase lazySync:]):
+ (-[WebFileDatabase sync]):
+ (-[WebFileDatabase count]):
+ (-[WebFileDatabase usage]):
+ * Misc.subproj/WebIconDatabase.m:
+ * Misc.subproj/WebKitLogging.h:
+ * Misc.subproj/WebKitLogging.m:
+ * Misc.subproj/WebLRUFileList.h: Added.
+ * Misc.subproj/WebLRUFileList.m: Added.
+ (WebLRUFileListCreate):
+ (WebLRUFileListRelease):
+ (WebLRUFileListRebuildFileDataUsingRootDirectory):
+ (WebLRUFileListRemoveFileWithPath):
+ (WebLRUFileListTouchFileWithPath):
+ (WebLRUFileListSetFileData):
+ (WebLRUFileListGetPathOfOldestFile):
+ (WebLRUFileListRemoveOldestFileFromList):
+ (WebLRUFileListContainsItem):
+ (WebLRUFileListGetFileSize):
+ (WebLRUFileListCountItems):
+ (WebLRUFileListGetTotalSize):
+ (WebLRUFileListRemoveAllFilesFromList):
+ (compareTimes):
+ (cStringEqual):
+ (cStringHash):
+ (NSLRUFileDataEqual):
+ (WebLRUFileListGetOldestFileData):
+ (NSLRUFileDataReleaseApplierFunction):
+ (NSLRUFileDataRelease):
+ (NSLRUFileDataBinaryHeapDumpApplierFunction):
+ (NSLRUFileDataDictDumpApplierFunction):
+ (WebLRUFileListDescription):
+ * WebKit.pbproj/project.pbxproj:
+
2003-05-15 Chris Blumenberg <cblu at apple.com>
Fixed: 3199310 - No user agent included in favicon.ico requests
diff --git a/WebKit/English.lproj/StringsNotToBeLocalized.txt b/WebKit/English.lproj/StringsNotToBeLocalized.txt
index c17f51b..1b3d7cc 100644
--- a/WebKit/English.lproj/StringsNotToBeLocalized.txt
+++ b/WebKit/English.lproj/StringsNotToBeLocalized.txt
@@ -1,11 +1,15 @@
" "
+" %s -> %6ld : %.0f : %.0f\n"
+" %s : %6ld : %.0f : %.0f\n"
" *POST*"
" *target*"
" >>>"
"%.1lf"
+"%.2lu/%.2lu/%.10lu-%.10lu.cache"
"%2d) "
"%@ %@"
"%@"
+"%@/%s"
"%@/Library/Caches/WebKitIcons/%@"
"%@/Library/Preferences/%@"
"%@:%u"
@@ -72,6 +76,8 @@
"JoiningRight"
"Joy!peff"
"Library/Internet Plug-Ins"
+"List count: %d items\n"
+"List total size: %d bytes\n"
"MP4 Audio"
"MP4 Video"
"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@ %@"
@@ -86,6 +92,9 @@
"NP_Shutdown"
"NSApplicationIcon"
"NSEvent"
+"NSFileModificationDate"
+"NSFileOwnerAccountName"
+"NSFilePosixPermissions"
"NSTextView"
"NSView"
"NSWindow"
@@ -207,6 +216,9 @@
"\n%s (%s:%d %s)\n=================\n"
"\n(%s:%d %s)\n=================\n"
"\n--------------------------------------------\n"
+"\nDict data: %ld items\n"
+"\nHeap data: %ld items\n"
+"\nList root path: %s\n"
"\r\n"
"_CGFontCacheSetMaxSize"
"_CGFontCacheSetShouldAutoExpire"
diff --git a/WebKit/Misc.subproj/WebDatabase.h b/WebKit/Misc.subproj/WebDatabase.h
index 189d9e3..14e33a9 100644
--- a/WebKit/Misc.subproj/WebDatabase.h
+++ b/WebKit/Misc.subproj/WebDatabase.h
@@ -5,7 +5,6 @@
#import <Foundation/Foundation.h>
-
@interface WebDatabase : NSObject
{
NSString *path;
diff --git a/WebKit/Misc.subproj/WebDatabase.m b/WebKit/Misc.subproj/WebDatabase.m
index 5086f46..58f346b 100644
--- a/WebKit/Misc.subproj/WebDatabase.m
+++ b/WebKit/Misc.subproj/WebDatabase.m
@@ -4,7 +4,7 @@
*/
#import <Foundation/NSPrivateDecls.h>
-#import "WebDatabase.h"
+#import <WebKit/WebDatabase.h>
// implementation WebDatabase ------------------------------------------------------------------------
diff --git a/WebKit/Misc.subproj/WebFileDatabase.h b/WebKit/Misc.subproj/WebFileDatabase.h
index 3696692..bb44400 100644
--- a/WebKit/Misc.subproj/WebFileDatabase.h
+++ b/WebKit/Misc.subproj/WebFileDatabase.h
@@ -9,7 +9,7 @@
@interface WebFileDatabase : WebDatabase
{
- struct NSLRUFileList *lru;
+ struct WebLRUFileList *lru;
NSMutableArray *ops;
NSMutableDictionary *setCache;
NSMutableSet *removeCache;
diff --git a/WebKit/Misc.subproj/WebFileDatabase.m b/WebKit/Misc.subproj/WebFileDatabase.m
index 3e0e239..f0ea47f 100644
--- a/WebKit/Misc.subproj/WebFileDatabase.m
+++ b/WebKit/Misc.subproj/WebFileDatabase.m
@@ -3,7 +3,11 @@
Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
*/
-#import "WebFileDatabase.h"
+#import <WebKit/WebFileDatabase.h>
+#import <WebKit/WebKitLogging.h>
+#import <WebKit/WebLRUFileList.h>
+
+#import <WebFoundation/NSFileManager_NSURLExtras.h>
#import <fcntl.h>
#import <fts.h>
@@ -13,19 +17,14 @@
#import <sys/types.h>
#import <sys/mman.h>
-#import "NSURLLogging.h"
-#import "NSLRUFileList.h"
-#import "NSFileManager_NSURLExtras.h"
-#import "WebSystemBits.h"
-
-#if NSURL_ERROR_DISABLED
+#if ERROR_DISABLED
#define BEGIN_EXCEPTION_HANDLER
#define END_EXCEPTION_HANDLER
#else
#define BEGIN_EXCEPTION_HANDLER NS_DURING
#define END_EXCEPTION_HANDLER \
NS_HANDLER \
- NSURL_ERROR("Uncaught exception: %@ [%@] [%@]", [localException class], [localException reason], [localException userInfo]); \
+ ERROR("Uncaught exception: %@ [%@] [%@]", [localException class], [localException reason], [localException userInfo]); \
NS_ENDHANDLER
#endif
@@ -37,6 +36,9 @@ static NSRunLoop *syncRunLoop;
#define UniqueFilePathSize (34)
static void UniqueFilePathForKey(id key, char *buffer);
+#define MinThreadPriority (10)
+static int SetThreadPriority(int priority);
+
typedef enum
{
WebFileDatabaseSetObjectOp,
@@ -80,7 +82,7 @@ enum
-(id)initWithCode:(WebFileDatabaseOpcode)theOpcode key:(id)theKey object:(id)theObject
{
- NSURL_ASSERT(theKey);
+ ASSERT(theKey);
if ((self = [super init])) {
@@ -111,7 +113,7 @@ enum
-(void)perform:(WebFileDatabase *)target
{
- NSURL_ASSERT(target);
+ ASSERT(target);
switch (opcode) {
case WebFileDatabaseSetObjectOp:
@@ -121,7 +123,7 @@ enum
[target performRemoveObjectForKey:key];
break;
default:
- NSURL_ASSERT_NOT_REACHED();
+ ASSERT_NOT_REACHED();
break;
}
}
@@ -150,6 +152,19 @@ enum
@implementation WebFileDatabase (WebFileDatabasePrivate)
+static int SetThreadPriority(int priority)
+{
+ struct sched_param sp;
+
+ memset(&sp, 0, sizeof(struct sched_param));
+ sp.sched_priority=priority;
+ if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &sp) == -1) {
+ ERROR("Failed to change priority.");
+ return -1;
+ }
+ return 0;
+}
+
static void UniqueFilePathForKey(id key, char *buffer)
{
const char *s;
@@ -179,19 +194,19 @@ static void UniqueFilePathForKey(id key, char *buffer)
-(void)_createLRUList:(id)arg
{
- WebSetThreadPriority(WebMinThreadPriority + 1); // make this a little higher priority than the syncRunLoop thread
+ SetThreadPriority(MinThreadPriority + 1); // make this a little higher priority than the syncRunLoop thread
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
BEGIN_EXCEPTION_HANDLER
- NSLRUFileList *fileList = NSLRUFileListCreate();
- NSLRUFileListRebuildFileDataUsingRootDirectory(fileList, [path fileSystemRepresentation]);
+ WebLRUFileList *fileList = WebLRUFileListCreate();
+ WebLRUFileListRebuildFileDataUsingRootDirectory(fileList, [path fileSystemRepresentation]);
lru = fileList;
END_EXCEPTION_HANDLER
- NSURL_LOG(WebFileDatabaseActivity, "lru list created");
+ LOG(FileDatabaseActivity, "lru list created");
[pool release];
}
@@ -212,13 +227,13 @@ static void UniqueFilePathForKey(id key, char *buffer)
[mutex lock];
while ([self usage] > size) {
char uniqueKey[UniqueFilePathSize];
- if (!NSLRUFileListGetPathOfOldestFile(lru, uniqueKey, UniqueFilePathSize)) {
+ if (!WebLRUFileListGetPathOfOldestFile(lru, uniqueKey, UniqueFilePathSize)) {
break;
}
NSString *filePath = [[NSString alloc] initWithFormat:@"%@/%s", path, uniqueKey];
[defaultManager _web_removeFileOnlyAtPath:filePath];
[filePath release];
- NSLRUFileListRemoveOldestFileFromList(lru);
+ WebLRUFileListRemoveOldestFileFromList(lru);
}
[mutex unlock];
}
@@ -236,7 +251,7 @@ static void UniqueFilePathForKey(id key, char *buffer)
+(void)_syncLoop:(id)arg
{
- WebSetThreadPriority(WebMinThreadPriority);
+ SetThreadPriority(MinThreadPriority);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSPort *placeholderPort;
@@ -324,12 +339,12 @@ static void databaseInit()
{
WebFileDatabaseOp *op;
- NSURL_ASSERT(object);
- NSURL_ASSERT(key);
+ ASSERT(object);
+ ASSERT(key);
touch = CFAbsoluteTimeGetCurrent();
- NSURL_LOG(WebFileDatabaseActivity, "%p - %@", object, key);
+ LOG(FileDatabaseActivity, "%p - %@", object, key);
[mutex lock];
@@ -346,7 +361,7 @@ static void databaseInit()
{
WebFileDatabaseOp *op;
- NSURL_ASSERT(key);
+ ASSERT(key);
touch = CFAbsoluteTimeGetCurrent();
@@ -374,14 +389,14 @@ static void databaseInit()
[self open];
[mutex unlock];
- NSURL_LOG(WebFileDatabaseActivity, "removeAllObjects");
+ LOG(FileDatabaseActivity, "removeAllObjects");
}
-(id)objectForKey:(id)key
{
volatile id result;
- NSURL_ASSERT(key);
+ ASSERT(key);
touch = CFAbsoluteTimeGetCurrent();
@@ -418,15 +433,15 @@ static void databaseInit()
if (lru) {
// if we can't update the list yet, that's too bad
// but not critically bad
- NSLRUFileListTouchFileWithPath(lru, uniqueKey);
+ WebLRUFileListTouchFileWithPath(lru, uniqueKey);
}
- NSURL_LOG(WebFileDatabaseActivity, "read disk cache file - %@", key);
+ LOG(FileDatabaseActivity, "read disk cache file - %@", key);
}
}
}
}
NS_HANDLER
- NSURL_LOG(WebFileDatabaseActivity, "cannot unarchive cache file - %@", key);
+ LOG(FileDatabaseActivity, "cannot unarchive cache file - %@", key);
result = nil;
NS_ENDHANDLER
@@ -448,12 +463,12 @@ static void databaseInit()
char uniqueKey[UniqueFilePathSize];
BOOL result;
- NSURL_ASSERT(object);
- NSURL_ASSERT(key);
+ ASSERT(object);
+ ASSERT(key);
UniqueFilePathForKey(key, uniqueKey);
- NSURL_LOG(WebFileDatabaseActivity, "%@ - %s", key, uniqueKey);
+ LOG(FileDatabaseActivity, "%@ - %s", key, uniqueKey);
data = [NSMutableData data];
archiver = [[NSArchiver alloc] initForWritingWithMutableData:data];
@@ -479,13 +494,13 @@ static void databaseInit()
// update usage and truncate before writing file
// this has the effect of _always_ keeping disk usage under sizeLimit by clearing away space in anticipation of the write.
- NSLRUFileListSetFileData(lru, uniqueKey, [data length], CFAbsoluteTimeGetCurrent());
+ WebLRUFileListSetFileData(lru, uniqueKey, [data length], CFAbsoluteTimeGetCurrent());
[self _truncateToSizeLimit:[self sizeLimit]];
result = [defaultManager _web_createFileAtPathWithIntermediateDirectories:filePath contents:data attributes:attributes directoryAttributes:directoryAttributes];
if (!result) {
- NSLRUFileListRemoveFileWithPath(lru, uniqueKey);
+ WebLRUFileListRemoveFileWithPath(lru, uniqueKey);
}
[archiver release];
@@ -497,14 +512,14 @@ static void databaseInit()
NSString *filePath;
char uniqueKey[UniqueFilePathSize];
- NSURL_ASSERT(key);
+ ASSERT(key);
- NSURL_LOG(WebFileDatabaseActivity, "%@", key);
+ LOG(FileDatabaseActivity, "%@", key);
UniqueFilePathForKey(key, uniqueKey);
filePath = [[NSString alloc] initWithFormat:@"%@/%s", path, uniqueKey];
[[NSFileManager defaultManager] _web_removeFileOnlyAtPath:filePath];
- NSLRUFileListRemoveFileWithPath(lru, uniqueKey);
+ WebLRUFileListRemoveFileWithPath(lru, uniqueKey);
[filePath release];
}
@@ -549,7 +564,7 @@ static void databaseInit()
if (isOpen) {
isOpen = NO;
if (lru) {
- NSLRUFileListRelease(lru);
+ WebLRUFileListRelease(lru);
lru = NULL;
}
}
@@ -566,11 +581,11 @@ static void databaseInit()
CFTimeInterval mark = CFAbsoluteTimeGetCurrent();
#endif
- NSURL_LOG(WebFileDatabaseActivity, ">>> BEFORE lazySync\n%@", NSLRUFileListDescription(lru));
+ LOG(FileDatabaseActivity, ">>> BEFORE lazySync\n%@", WebLRUFileListDescription(lru));
WebFileDatabaseOp *op;
- NSURL_ASSERT(theTimer);
+ ASSERT(theTimer);
while (touch + SYNC_IDLE_THRESHOLD < CFAbsoluteTimeGetCurrent() && [ops count] > 0) {
[mutex lock];
@@ -603,10 +618,10 @@ static void databaseInit()
#ifndef NDEBUG
if (lru)
- NSURL_LOG(WebFileDatabaseActivity, "<<< AFTER lazySync\n%@", NSLRUFileListDescription(lru));
+ LOG(FileDatabaseActivity, "<<< AFTER lazySync\n%@", WebLRUFileListDescription(lru));
CFTimeInterval now = CFAbsoluteTimeGetCurrent();
- NSURL_LOG(WebFileDatabaseActivity, "lazySync ran in %.3f secs.", now - mark);
+ LOG(FileDatabaseActivity, "lazySync ran in %.3f secs.", now - mark);
#endif
}
@@ -621,7 +636,7 @@ static void databaseInit()
touch = CFAbsoluteTimeGetCurrent();
- NSURL_LOG(WebFileDatabaseActivity, ">>> BEFORE sync\n%@", NSLRUFileListDescription(lru));
+ LOG(FileDatabaseActivity, ">>> BEFORE sync\n%@", WebLRUFileListDescription(lru));
[mutex lock];
array = [ops copy];
@@ -636,13 +651,13 @@ static void databaseInit()
[array makeObjectsPerformSelector:@selector(perform:) withObject:self];
[array release];
- NSURL_LOG(WebFileDatabaseActivity, "<<< AFTER sync\n%@", NSLRUFileListDescription(lru));
+ LOG(FileDatabaseActivity, "<<< AFTER sync\n%@", WebLRUFileListDescription(lru));
}
-(unsigned)count
{
if (lru)
- return NSLRUFileListCountItems(lru);
+ return WebLRUFileListCountItems(lru);
return 0;
}
@@ -650,7 +665,7 @@ static void databaseInit()
-(unsigned)usage
{
if (lru)
- return NSLRUFileListGetTotalSize(lru);
+ return WebLRUFileListGetTotalSize(lru);
return 0;
}
diff --git a/WebKit/Misc.subproj/WebIconDatabase.m b/WebKit/Misc.subproj/WebIconDatabase.m
index 4713734..bf8df54 100644
--- a/WebKit/Misc.subproj/WebIconDatabase.m
+++ b/WebKit/Misc.subproj/WebIconDatabase.m
@@ -9,11 +9,11 @@
#import <WebKit/WebIconDatabase.h>
#import <WebKit/WebIconDatabasePrivate.h>
+#import <WebKit/WebFileDatabase.h>
#import <WebKit/WebKitLogging.h>
#import <WebFoundation/NSString_NSURLExtras.h>
#import <WebFoundation/NSURL_NSURLExtras.h>
-#import <WebFoundation/WebFileDatabase.h>
NSString * const WebIconDatabaseVersionKey = @"WebIconDatabaseVersion";
NSString * const WebIconsOnDiskKey = @"WebIconsOnDisk";
diff --git a/WebKit/Misc.subproj/WebKitLogging.h b/WebKit/Misc.subproj/WebKitLogging.h
index 21441f6..e434611 100644
--- a/WebKit/Misc.subproj/WebKitLogging.h
+++ b/WebKit/Misc.subproj/WebKitLogging.h
@@ -29,3 +29,5 @@ extern WebLogChannel WebKitLogPageCache;
extern WebLogChannel WebKitLogCacheSizes;
extern WebLogChannel WebKitLogFormDelegate;
+
+extern WebLogChannel WebKitLogFileDatabaseActivity;
diff --git a/WebKit/Misc.subproj/WebKitLogging.m b/WebKit/Misc.subproj/WebKitLogging.m
index 9911a13..06cacb6 100644
--- a/WebKit/Misc.subproj/WebKitLogging.m
+++ b/WebKit/Misc.subproj/WebKitLogging.m
@@ -25,3 +25,5 @@ WebLogChannel WebKitLogPageCache = { 0x00080000, "WebKitLogLevel",
WebLogChannel WebKitLogCacheSizes = { 0x00100000, "WebKitLogLevel", WebLogChannelUninitialized };
WebLogChannel WebKitLogFormDelegate = { 0x00200000, "WebKitLogLevel", WebLogChannelUninitialized };
+
+WebLogChannel WebKitLogFileDatabaseActivity = { 0x00400000, "WebKitLogLevel", WebLogChannelUninitialized };
diff --git a/WebKit/Misc.subproj/WebLRUFileList.h b/WebKit/Misc.subproj/WebLRUFileList.h
new file mode 100644
index 0000000..a3c5478
--- /dev/null
+++ b/WebKit/Misc.subproj/WebLRUFileList.h
@@ -0,0 +1,28 @@
+/*
+ WebLRUFileList.h
+ Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+*/
+
+#import <CoreFoundation/CoreFoundation.h>
+
+typedef struct WebLRUFileList WebLRUFileList;
+
+WebLRUFileList *WebLRUFileListCreate(void);
+void WebLRUFileListRelease(WebLRUFileList *list);
+
+int WebLRUFileListRebuildFileDataUsingRootDirectory(WebLRUFileList *list, const char *path);
+
+unsigned int WebLRUFileListRemoveFileWithPath(WebLRUFileList *list, const char *path);
+void WebLRUFileListTouchFileWithPath(WebLRUFileList *list, const char *path);
+void WebLRUFileListSetFileData(WebLRUFileList *list, const char *path, unsigned long fileSize, CFTimeInterval time);
+
+Boolean WebLRUFileListGetPathOfOldestFile(WebLRUFileList *list, char *buffer, unsigned int length);
+unsigned int WebLRUFileListRemoveOldestFileFromList(WebLRUFileList *list);
+
+Boolean WebLRUFileListContainsItem(WebLRUFileList *list, const char *path);
+unsigned int WebLRUFileListGetFileSize(WebLRUFileList *list, const char *path);
+unsigned int WebLRUFileListCountItems(WebLRUFileList *list);
+unsigned int WebLRUFileListGetTotalSize(WebLRUFileList *list);
+void WebLRUFileListRemoveAllFilesFromList(WebLRUFileList *list);
+
+NSString *WebLRUFileListDescription(WebLRUFileList *list);
diff --git a/WebKit/Misc.subproj/WebLRUFileList.m b/WebKit/Misc.subproj/WebLRUFileList.m
new file mode 100644
index 0000000..735c220
--- /dev/null
+++ b/WebKit/Misc.subproj/WebLRUFileList.m
@@ -0,0 +1,458 @@
+/*
+ WebLRUFileList.m
+ Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+*/
+
+#import <WebKit/WebAssertions.h>
+#import <WebKit/WebKitLogging.h>
+#import <WebKit/WebLRUFileList.h>
+
+#import <stdlib.h>
+#import <sys/types.h>
+#import <sys/stat.h>
+#import <fts.h>
+
+#define RemoveFromHeap (TRUE)
+#define DontRemoveFromHeap (FALSE)
+
+struct WebLRUFileList
+{
+ char *rootDirectory;
+ CFBinaryHeapRef heap;
+ CFMutableDictionaryRef dict;
+ unsigned int count;
+ unsigned int totalSize;
+};
+
+typedef struct NSLRUFileData NSLRUFileData;
+
+struct NSLRUFileData
+{
+ unsigned long fileSize;
+ CFTimeInterval heapTime;
+ CFTimeInterval updatedTime;
+ unsigned int markRemoved;
+ char path[1]; // variable size, big enough to hold path string and trailing nul
+};
+
+static CFComparisonResult compareTimes(const void *val1, const void *val2, void *context);
+static Boolean cStringEqual(const void *val1, const void *val2);
+static CFHashCode cStringHash(const void *val);
+static Boolean NSLRUFileDataEqual(const void *val1, const void *val2);
+
+static NSLRUFileData *WebLRUFileListGetOldestFileData(WebLRUFileList *list, Boolean removeFromHeap);
+
+static void NSLRUFileDataReleaseApplierFunction(const void *key, const void *value, void *context);
+static void NSLRUFileDataRelease(CFAllocatorRef allocator, const void *value);
+
+
+WebLRUFileList *WebLRUFileListCreate(void)
+{
+ CFBinaryHeapCallBacks heapCallbacks = {0, NULL, NULL, NULL, compareTimes};
+ CFBinaryHeapCompareContext heapCompareContext = {0, NULL, NULL, NULL, NULL};
+ CFDictionaryKeyCallBacks dictKeyCallbacks = {0, NULL, NULL, NULL, cStringEqual, cStringHash};
+ CFDictionaryValueCallBacks dictValCallbacks = {0, NULL, NULL, NULL, NSLRUFileDataEqual};
+
+ WebLRUFileList *list = malloc(sizeof(WebLRUFileList));
+
+ list->rootDirectory = NULL;
+ list->heap = CFBinaryHeapCreate(NULL, 0, &heapCallbacks, &heapCompareContext);
+ list->dict = CFDictionaryCreateMutable(NULL, 0, &dictKeyCallbacks, &dictValCallbacks);
+ list->count = 0;
+ list->totalSize = 0;
+
+ return list;
+}
+
+void WebLRUFileListRelease(WebLRUFileList *list)
+{
+ ASSERT(list);
+ free(list->rootDirectory);
+ WebLRUFileListRemoveAllFilesFromList(list);
+ CFRelease(list->heap);
+ CFRelease(list->dict);
+ free(list);
+}
+
+int WebLRUFileListRebuildFileDataUsingRootDirectory(WebLRUFileList *list, const char *path)
+{
+ ASSERT(list);
+ ASSERT(path);
+
+ FTS *fts;
+ FTSENT *ent;
+ char *paths[2];
+ struct stat statInfo;
+
+ if (stat(path, &statInfo) == -1) {
+ return errno;
+ }
+ if ((statInfo.st_mode & S_IFDIR) == 0) {
+ return ENOTDIR;
+ }
+
+ WebLRUFileListRemoveAllFilesFromList(list);
+ free(list->rootDirectory);
+ list->rootDirectory = strdup(path);
+ int pathLength = strlen(path);
+
+ paths[0] = (char *)path;
+ paths[1] = NULL;
+
+ fts = fts_open(paths, FTS_COMFOLLOW | FTS_LOGICAL, NULL);
+
+ while ((ent = fts_read(fts))) {
+ if (ent->fts_statp->st_mode & S_IFREG) {
+ const char *filePath = ent->fts_accpath + pathLength + 1;
+ WebLRUFileListSetFileData(list, filePath, ent->fts_statp->st_size, ent->fts_statp->st_ctimespec.tv_sec - kCFAbsoluteTimeIntervalSince1970);
+ }
+ }
+
+ fts_close(fts);
+
+ return 0;
+}
+
+unsigned int WebLRUFileListRemoveFileWithPath(WebLRUFileList *list, const char *path)
+{
+ ASSERT(list);
+ ASSERT(path);
+
+ unsigned int removedFileSize = 0;
+
+ NSLRUFileData *data = (NSLRUFileData *)CFDictionaryGetValue(list->dict, path);
+ if (data) {
+ CFDictionaryRemoveValue(list->dict, path);
+ data->markRemoved = 1;
+ removedFileSize = data->fileSize;
+ list->totalSize -= data->fileSize;
+ ASSERT(list->count > 0);
+ list->count--;
+ }
+
+ return removedFileSize;
+}
+
+void WebLRUFileListTouchFileWithPath(WebLRUFileList *list, const char *path)
+{
+ ASSERT(list);
+ ASSERT(path);
+
+ NSLRUFileData *data = (NSLRUFileData *)CFDictionaryGetValue(list->dict, path);
+ if (data) {
+ // This is not the same as the "real" mod time of the file on disk
+ // but it is close enough for our purposes
+ data->updatedTime = CFAbsoluteTimeGetCurrent();
+ }
+}
+
+void WebLRUFileListSetFileData(WebLRUFileList *list, const char *path, unsigned long fileSize, CFTimeInterval time)
+{
+ ASSERT(list);
+ ASSERT(path);
+
+ NSLRUFileData *data = (NSLRUFileData *)CFDictionaryGetValue(list->dict, path);
+ if (data) {
+ // update existing data
+ list->totalSize -= data->fileSize;
+ list->totalSize += fileSize;
+ data->fileSize = fileSize;
+ data->updatedTime = time;
+ }
+ else {
+ // create new data object
+ // malloc a block that can accommodate the string
+ // account for the size of the string when
+ // allocating the correct size block.
+ size_t mallocSize = offsetof(NSLRUFileData, path) + strlen(path) + 1;
+ data = malloc(mallocSize);
+ data->fileSize = fileSize;
+ data->heapTime = data->updatedTime = time;
+ data->markRemoved = 0;
+ strcpy(data->path, path);
+ list->totalSize += fileSize;
+ list->count++;
+ CFBinaryHeapAddValue(list->heap, data);
+ CFDictionarySetValue(list->dict, data->path, data);
+ }
+}
+
+Boolean WebLRUFileListGetPathOfOldestFile(WebLRUFileList *list, char *buffer, unsigned int length)
+{
+ ASSERT(list);
+
+ NSLRUFileData *data = WebLRUFileListGetOldestFileData(list, DontRemoveFromHeap);
+
+ if (data) {
+ unsigned pathLength = strlen(data->path);
+ if (length - 1 >= pathLength) {
+ strcpy(buffer, data->path);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+unsigned int WebLRUFileListRemoveOldestFileFromList(WebLRUFileList *list)
+{
+ ASSERT(list);
+
+ if (list->count == 0) {
+ return 0;
+ }
+
+ NSLRUFileData *data = WebLRUFileListGetOldestFileData(list, RemoveFromHeap);
+
+ if (!data) {
+ ERROR("list->count > 0, but no data returned from WebLRUFileListGetOldestFileData");
+ }
+
+ // no need to remove from heap explicitly
+ // WebLRUFileListGetOldestFileData with RemoveFromHeap call does that
+ CFDictionaryRemoveValue(list->dict, data->path);
+ ASSERT(list->count > 0);
+ list->count--;
+ unsigned int removedFileSize = data->fileSize;
+ list->totalSize -= removedFileSize;
+ LOG(FileDatabaseActivity, "\n\t%s : %ld : %.0f : %.0f\n", data->path, data->fileSize, data->heapTime, data->updatedTime);
+ NSLRUFileDataRelease(NULL, data);
+ return removedFileSize;
+}
+
+Boolean WebLRUFileListContainsItem(WebLRUFileList *list, const char *path)
+{
+ ASSERT(list);
+ ASSERT(path);
+
+ if (list->count == 0) {
+ return FALSE;
+ }
+
+ NSLRUFileData *data = (NSLRUFileData *)CFDictionaryGetValue(list->dict, path);
+ if (!data) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+unsigned int WebLRUFileListGetFileSize(WebLRUFileList *list, const char *path)
+{
+ ASSERT(list);
+ ASSERT(path);
+
+ unsigned int result = 0;
+
+ if (list->count == 0) {
+ return result;
+ }
+
+ NSLRUFileData *data = (NSLRUFileData *)CFDictionaryGetValue(list->dict, path);
+ if (!data) {
+ ERROR("list->count > 0, but no data returned from CFDictionaryGetValue with path: %s", path);
+ }
+
+ result = data->fileSize;
+
+ return result;
+}
+
+unsigned int WebLRUFileListCountItems(WebLRUFileList *list)
+{
+ ASSERT(list);
+ return list->count;
+}
+
+unsigned int WebLRUFileListGetTotalSize(WebLRUFileList *list)
+{
+ ASSERT(list);
+ return list->totalSize;
+}
+
+void WebLRUFileListRemoveAllFilesFromList(WebLRUFileList *list)
+{
+ ASSERT(list);
+
+ // use dictionary applier function to free all NSLRUFileData objects
+ CFDictionaryApplyFunction(list->dict, NSLRUFileDataReleaseApplierFunction, NULL);
+
+ CFDictionaryRemoveAllValues(list->dict);
+ CFBinaryHeapRemoveAllValues(list->heap);
+ list->count = 0;
+ list->totalSize = 0;
+}
+
+static CFComparisonResult compareTimes(const void *val1, const void *val2, void *context)
+{
+ ASSERT(val1);
+ ASSERT(val2);
+
+ CFTimeInterval t1 = ((NSLRUFileData *)val1)->heapTime;
+ CFTimeInterval t2 = ((NSLRUFileData *)val2)->heapTime;
+
+ if (t1 > t2) return kCFCompareGreaterThan;
+ if (t1 < t2) return kCFCompareLessThan;
+ return kCFCompareEqualTo;
+}
+
+static Boolean cStringEqual(const void *val1, const void *val2)
+{
+ ASSERT(val1);
+ ASSERT(val2);
+
+ const char *s1 = (const char *)val1;
+ const char *s2 = (const char *)val2;
+ return strcmp(s1, s2) == 0;
+}
+
+// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
+// or anything like that.
+static const unsigned PHI = 0x9e3779b9U;
+
+// This hash algorithm comes from:
+// http://burtleburtle.net/bob/hash/hashfaq.html
+// http://burtleburtle.net/bob/hash/doobs.html
+static CFHashCode cStringHash(const void *val)
+{
+ ASSERT(val);
+
+ const char *s = (const char *)val;
+ int length = strlen(s);
+ int prefixLength = length < 8 ? length : 8;
+ int suffixPosition = length < 16 ? 8 : length - 8;
+ int i;
+
+ unsigned h = PHI;
+ h += length;
+ h += (h << 10);
+ h ^= (h << 6);
+
+ for (i = 0; i < prefixLength; i++) {
+ h += (unsigned char)s[i];
+ h += (h << 10);
+ h ^= (h << 6);
+ }
+ for (i = suffixPosition; i < length; i++) {
+ h += (unsigned char)s[i];
+ h += (h << 10);
+ h ^= (h << 6);
+ }
+
+ h += (h << 3);
+ h ^= (h >> 11);
+ h += (h << 15);
+
+ return h;
+}
+
+static Boolean NSLRUFileDataEqual(const void *val1, const void *val2)
+{
+ ASSERT(val1);
+ ASSERT(val2);
+
+ NSLRUFileData *d1 = (NSLRUFileData *)val1;
+ NSLRUFileData *d2 = (NSLRUFileData *)val2;
+ return (d1->fileSize == d2->fileSize &&
+ d1->heapTime == d2->heapTime &&
+ d1->updatedTime == d2->updatedTime &&
+ d1->markRemoved == d2->markRemoved &&
+ strcmp(d1->path, d2->path) == 0);
+}
+
+static NSLRUFileData *WebLRUFileListGetOldestFileData(WebLRUFileList *list, Boolean removeFromHeap)
+{
+ ASSERT(list);
+
+ // Use the heap count directory to account for the need to do lazy removal of heap objects
+ // that may have been left over by calls to WebLRUFileListRemoveFileWithPath
+ // since whenever WebLRUFileListRemoveFileWithPath is called,
+ // list->count and the heap's count may no longer be equal
+ unsigned int heapCount = CFBinaryHeapGetCount(list->heap);
+ if (heapCount == 0) {
+ return NULL;
+ }
+
+ unsigned i;
+ NSLRUFileData *data;
+
+ for (i = 0; i < heapCount; i++) {
+ data = (NSLRUFileData *)CFBinaryHeapGetMinimum(list->heap);
+ if (data->markRemoved) {
+ // clean up this object that was marked for removal earlier
+ CFBinaryHeapRemoveMinimumValue(list->heap);
+ NSLRUFileDataRelease(NULL, data);
+ }
+ else if (data->heapTime != data->updatedTime) {
+ // update this object
+ // reinsert into heap
+ CFBinaryHeapRemoveMinimumValue(list->heap);
+ data->heapTime = data->updatedTime;
+ CFBinaryHeapAddValue(list->heap, data);
+ }
+ else {
+ // found an object that was neither updated nor marked for removal
+ // return it
+ if (removeFromHeap) {
+ CFBinaryHeapRemoveMinimumValue(list->heap);
+ }
+ return data;
+ }
+ }
+
+ // we "wrapped around"
+ // all nodes were touched after they were added, and we are back at the start
+ // just pop off the object that is on top now.
+ data = (NSLRUFileData *)CFBinaryHeapGetMinimum(list->heap);
+ if (data && removeFromHeap) {
+ ASSERT(data->heapTime == data->updatedTime);
+ CFBinaryHeapRemoveMinimumValue(list->heap);
+ }
+ return data;
+}
+
+static void NSLRUFileDataReleaseApplierFunction(const void *key, const void *value, void *context)
+{
+ ASSERT(value);
+ free((NSLRUFileData *)value);
+}
+
+static void NSLRUFileDataRelease(CFAllocatorRef allocator, const void *value)
+{
+ ASSERT(value);
+ free((NSLRUFileData *)value);
+}
+
+// -----------------------------------------------------
+// debugging
+
+static void NSLRUFileDataBinaryHeapDumpApplierFunction(const void *value, void *context)
+{
+ NSMutableString *string = (NSMutableString *)context;
+ NSLRUFileData *data = (NSLRUFileData *)value;
+ [string appendFormat:@" %s : %6ld : %.0f : %.0f\n", data->path, data->fileSize, data->heapTime, data->updatedTime];
+}
+
+static void NSLRUFileDataDictDumpApplierFunction(const void *key, const void *value, void *context)
+{
+ NSMutableString *string = (NSMutableString *)context;
+ NSLRUFileData *data = (NSLRUFileData *)value;
+ [string appendFormat:@" %s -> %6ld : %.0f : %.0f\n", (const char *)key, data->fileSize, data->heapTime, data->updatedTime];
+}
+
+NSString *WebLRUFileListDescription(WebLRUFileList *list)
+{
+ NSMutableString *string = [NSMutableString string];
+
+ [string appendFormat:@"\nList root path: %s\n", list->rootDirectory];
+ [string appendFormat:@"List count: %d items\n", list->count];
+ [string appendFormat:@"List total size: %d bytes\n", list->totalSize];
+
+ [string appendFormat:@"\nHeap data: %ld items\n", CFBinaryHeapGetCount(list->heap)];
+ CFBinaryHeapApplyFunction(list->heap, NSLRUFileDataBinaryHeapDumpApplierFunction, string);
+
+ [string appendFormat:@"\nDict data: %ld items\n", CFDictionaryGetCount(list->dict)];
+ CFDictionaryApplyFunction(list->dict, NSLRUFileDataDictDumpApplierFunction, string);
+
+ return string;
+}
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 2008c3e..955ae0a 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -295,6 +295,9 @@
BEE18F940472A0CF00CA289C,
BEE18F9B0472B73200CA289C,
BEE52D4C0473032500CA289C,
+ BE07CEAD047538F000CA289C,
+ BE07CEAF047538F000CA289C,
+ BE07CEB1047538F000CA289C,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -409,6 +412,9 @@
BEE18F950472A0CF00CA289C,
BEE18F9C0472B73200CA289C,
BEE52D4D0473032500CA289C,
+ BE07CEAE047538F000CA289C,
+ BE07CEB0047538F000CA289C,
+ BE07CEB2047538F000CA289C,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -482,6 +488,12 @@
F528E3EA031E91AD01CA2ACA,
F5934C8802E894F50197FBCF,
F5934C8902E894F50197FBCF,
+ BE07CEA7047538F000CA289C,
+ BE07CEA8047538F000CA289C,
+ BE07CEA9047538F000CA289C,
+ BE07CEAA047538F000CA289C,
+ BE07CEAB047538F000CA289C,
+ BE07CEAC047538F000CA289C,
2568C72C0174912D0ECA149E,
F5927D4E02D26C5E01CA2DBB,
83730F9803FB1E660004736E,
@@ -2377,6 +2389,78 @@
//BE2
//BE3
//BE4
+ BE07CEA7047538F000CA289C = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ path = WebDatabase.h;
+ refType = 4;
+ };
+ BE07CEA8047538F000CA289C = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ path = WebDatabase.m;
+ refType = 4;
+ };
+ BE07CEA9047538F000CA289C = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ path = WebFileDatabase.h;
+ refType = 4;
+ };
+ BE07CEAA047538F000CA289C = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ path = WebFileDatabase.m;
+ refType = 4;
+ };
+ BE07CEAB047538F000CA289C = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ path = WebLRUFileList.h;
+ refType = 4;
+ };
+ BE07CEAC047538F000CA289C = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ path = WebLRUFileList.m;
+ refType = 4;
+ };
+ BE07CEAD047538F000CA289C = {
+ fileRef = BE07CEA7047538F000CA289C;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ BE07CEAE047538F000CA289C = {
+ fileRef = BE07CEA8047538F000CA289C;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ BE07CEAF047538F000CA289C = {
+ fileRef = BE07CEA9047538F000CA289C;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ BE07CEB0047538F000CA289C = {
+ fileRef = BE07CEAA047538F000CA289C;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ BE07CEB1047538F000CA289C = {
+ fileRef = BE07CEAB047538F000CA289C;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ BE07CEB2047538F000CA289C = {
+ fileRef = BE07CEAC047538F000CA289C;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
BEE18F920472A0CF00CA289C = {
fileEncoding = 30;
isa = PBXFileReference;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list