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

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:16:17 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 14c28e8918ec8a5ad4f79360ec57db85dd6a9815
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 18 20:46:55 2002 +0000

    	Fixed: 3131714 - System becomes unresponsive while downloading
    
    	While downloading a file, Safari and the Finder take up 30%-40% of the CPU each. This is happening because for every chunk of data we write to disk, we call -[NSWorkspace noteFileSystemChanged:]. noteFileSystemChanged is inefficient. It sends 2 AppleEvents each with 60 timeouts. The event also causes the Finder to do a lot of work.
    
    	We should:
    	- Send 1 AppleEvent ourselves with no timeout since we don't care about the reply
    	- Call the notification/event less often. The only benefit of sending the event for every chunk written is that the file size updates in the Finder. Not worth the performance impact.
    
            Reviewed by kocienda.
    
            * Downloads.subproj/WebDownloadHandler.m:
            (-[WebDownloadHandler cleanUpAfterFailure]): call _web_noteFileChangedAtPath
            (-[WebDownloadHandler createFileIfNecessary]): call _web_noteFileChangedAtPath
            (-[WebDownloadHandler writeDataForkData:resourceForkData:]): don't call noteFileSystemChanged
            (-[WebDownloadHandler finishedLoading]): call _web_noteFileChangedAtPath
            * Misc.subproj/WebNSWorkspaceExtras.h: Added.
            * Misc.subproj/WebNSWorkspaceExtras.m: Added.
            (-[NSWorkspace _web_noteFileChangedAtPath:]): Notifies the Finder (or any other app that cares) that we added, removed or changed the attributes of a file. This method is better than calling noteFileSystemChanged: because noteFileSystemChanged: sends 2 apple events both with a 60 second timeout. This method returns immediately.
            * WebKit.pbproj/project.pbxproj:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3121 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index a973c1c..d91d964 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,25 @@
+2002-12-18  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed: 3131714 - System becomes unresponsive while downloading
+
+	While downloading a file, Safari and the Finder take up 30%-40% of the CPU each. This is happening because for every chunk of data we write to disk, we call -[NSWorkspace noteFileSystemChanged:]. noteFileSystemChanged is inefficient. It calls 2 AppleEvents each with 60 timeouts. The event also cause the Finder to do a lot of work.
+
+	We should:
+	- Send 1 AppleEvent ourselves with no timeout since we don't care about the reply
+	- Call the notification/event less often. The only benefit of sending the event for every chunk written is that the file size updates in the Finder. Not worth the performance impact.
+
+        Reviewed by kocienda.
+
+        * Downloads.subproj/WebDownloadHandler.m:
+        (-[WebDownloadHandler cleanUpAfterFailure]): call _web_noteFileChangedAtPath
+        (-[WebDownloadHandler createFileIfNecessary]): call _web_noteFileChangedAtPath
+        (-[WebDownloadHandler writeDataForkData:resourceForkData:]): don't call noteFileSystemChanged
+        (-[WebDownloadHandler finishedLoading]): call _web_noteFileChangedAtPath
+        * Misc.subproj/WebNSWorkspaceExtras.h: Added.
+        * Misc.subproj/WebNSWorkspaceExtras.m: Added.
+        (-[NSWorkspace _web_noteFileChangedAtPath:]): Notifies the Finder (or any other app that cares) that we added, removed or changed the attributes of a file. This method is better than calling noteFileSystemChanged: because noteFileSystemChanged: sends 2 apple events both with a 60 second timeout. This method returns immediately.
+        * WebKit.pbproj/project.pbxproj:
+
 2002-12-18  Darin Adler  <darin at apple.com>
 
         Reviewed by Maciej.
diff --git a/WebKit/Downloads.subproj/WebDownload.m b/WebKit/Downloads.subproj/WebDownload.m
index a1d5244..992a481 100644
--- a/WebKit/Downloads.subproj/WebDownload.m
+++ b/WebKit/Downloads.subproj/WebDownload.m
@@ -15,6 +15,7 @@
 #import <WebKit/WebKitErrors.h>
 #import <WebKit/WebKitLogging.h>
 #import <WebKit/WebMacBinaryDecoder.h>
+#import <WebKit/WebNSWorkspaceExtras.h>
 
 #import <WebFoundation/WebError.h>
 #import <WebFoundation/WebNSFileManagerExtras.h>
@@ -138,7 +139,7 @@
     
     [[NSFileManager defaultManager] removeFileAtPath:path handler:nil];
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:path];
+    [[NSWorkspace sharedWorkspace] _web_noteFileChangedAtPath:path];
 }
 
 - (WebError *)createFileIfNecessary
@@ -189,9 +190,9 @@
         return [self errorWithCode:WebErrorCannotCreateFile];
     }
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:path];
+    [[NSWorkspace sharedWorkspace] _web_noteFileChangedAtPath:path];
 
-    OSErr result = FSPathMakeRef([path UTF8String], &fileRef, nil);
+    OSErr result = FSPathMakeRef((const UInt8 *)[fileManager fileSystemRepresentationWithPath:path], &fileRef, NULL);
     if (result == noErr) {
         fileRefPtr = &fileRef;
     } else {
@@ -259,8 +260,6 @@
         return [self errorWithCode:WebErrorCannotWriteToFile];
     }
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:[dataSource downloadPath]];
-
     return nil;
 }
 
@@ -350,7 +349,7 @@
 
     [self closeFile];
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:[dataSource downloadPath]];
+    [[NSWorkspace sharedWorkspace] _web_noteFileChangedAtPath:[dataSource downloadPath]];
 
     LOG(Download, "Download complete. Saved to: %@", [dataSource downloadPath]);
 
diff --git a/WebKit/Downloads.subproj/WebDownloadHandler.m b/WebKit/Downloads.subproj/WebDownloadHandler.m
index a1d5244..992a481 100644
--- a/WebKit/Downloads.subproj/WebDownloadHandler.m
+++ b/WebKit/Downloads.subproj/WebDownloadHandler.m
@@ -15,6 +15,7 @@
 #import <WebKit/WebKitErrors.h>
 #import <WebKit/WebKitLogging.h>
 #import <WebKit/WebMacBinaryDecoder.h>
+#import <WebKit/WebNSWorkspaceExtras.h>
 
 #import <WebFoundation/WebError.h>
 #import <WebFoundation/WebNSFileManagerExtras.h>
@@ -138,7 +139,7 @@
     
     [[NSFileManager defaultManager] removeFileAtPath:path handler:nil];
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:path];
+    [[NSWorkspace sharedWorkspace] _web_noteFileChangedAtPath:path];
 }
 
 - (WebError *)createFileIfNecessary
@@ -189,9 +190,9 @@
         return [self errorWithCode:WebErrorCannotCreateFile];
     }
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:path];
+    [[NSWorkspace sharedWorkspace] _web_noteFileChangedAtPath:path];
 
-    OSErr result = FSPathMakeRef([path UTF8String], &fileRef, nil);
+    OSErr result = FSPathMakeRef((const UInt8 *)[fileManager fileSystemRepresentationWithPath:path], &fileRef, NULL);
     if (result == noErr) {
         fileRefPtr = &fileRef;
     } else {
@@ -259,8 +260,6 @@
         return [self errorWithCode:WebErrorCannotWriteToFile];
     }
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:[dataSource downloadPath]];
-
     return nil;
 }
 
@@ -350,7 +349,7 @@
 
     [self closeFile];
 
-    [[NSWorkspace sharedWorkspace] noteFileSystemChanged:[dataSource downloadPath]];
+    [[NSWorkspace sharedWorkspace] _web_noteFileChangedAtPath:[dataSource downloadPath]];
 
     LOG(Download, "Download complete. Saved to: %@", [dataSource downloadPath]);
 
diff --git a/WebKit/Misc.subproj/WebNSWorkspaceExtras.h b/WebKit/Misc.subproj/WebNSWorkspaceExtras.h
new file mode 100644
index 0000000..be82fdb
--- /dev/null
+++ b/WebKit/Misc.subproj/WebNSWorkspaceExtras.h
@@ -0,0 +1,19 @@
+//
+//  WebNSWorkspaceExtras.h
+//  WebKit
+//
+//  Created by Chris Blumenberg on Wed Dec 18 2002.
+//  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+ at interface NSWorkspace (WebNSWorkspaceExtras)
+
+// Notifies the Finder (or any other app that cares) that we added, removed or changed the attributes of a file.
+// This method is better than calling noteFileSystemChanged: because noteFileSystemChanged: sends 2 apple events
+// both with a 60 second timeout. This method returns immediately.
+- (void)_web_noteFileChangedAtPath:(NSString *)path;
+
+ at end
diff --git a/WebKit/Misc.subproj/WebNSWorkspaceExtras.m b/WebKit/Misc.subproj/WebNSWorkspaceExtras.m
new file mode 100644
index 0000000..6c8f57f
--- /dev/null
+++ b/WebKit/Misc.subproj/WebNSWorkspaceExtras.m
@@ -0,0 +1,72 @@
+//
+//  WebNSWorkspaceExtras.m
+//  WebKit
+//
+//  Created by Chris Blumenberg on Wed Dec 18 2002.
+//  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+//
+
+#import "WebNSWorkspaceExtras.h"
+
+#import <WebFoundation/WebAssertions.h>
+
+ at implementation NSWorkspace (WebNSWorkspaceExtras)
+
+- (void)_web_noteFileChangedAtPath:(NSString *)path
+{
+    ASSERT(path);
+    
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    
+    NSString *directoryPath = [path stringByDeletingLastPathComponent];
+    const char *dirRep = [fileManager fileSystemRepresentationWithPath:directoryPath];
+
+    // Send the notificaition that directory contents have changed.
+    FNNotifyByPath(dirRep, kFNDirectoryModifiedMessage, kNilOptions);
+
+    // Send a Finder event so the file attributes (including icon) update in the Finder.
+
+    // Make the Finder the target of the event.
+    OSType finderSignature = 'MACS';
+    NSAppleEventDescriptor *target;
+    target = [NSAppleEventDescriptor descriptorWithDescriptorType:typeApplSignature
+                                                            bytes:&finderSignature
+                                                           length:sizeof(OSType)];
+
+    // Make the event.
+    NSAppleEventDescriptor *event;
+    event = [NSAppleEventDescriptor appleEventWithEventClass:kAEFinderSuite
+                                                     eventID:kAESync
+                                            targetDescriptor:target
+                                                    returnID:0
+                                               transactionID:0];
+
+    const char *fileRep = [[NSFileManager defaultManager] fileSystemRepresentationWithPath:path];
+    FSRef fref;
+    OSStatus error = FSPathMakeRef(fileRep, &fref, NULL);
+    if(error){
+        return;
+    }
+
+    AliasHandle	alias;
+    error = FSNewAlias(NULL, &fref, &alias);
+    if(error){
+        return;
+    }
+
+    // Make the file the direct object of the event.
+    NSAppleEventDescriptor *aliasDesc;
+    aliasDesc = [NSAppleEventDescriptor descriptorWithDescriptorType:typeAlias
+                                                               bytes:*alias
+                                                              length:GetHandleSize((Handle)alias)];
+    [event setParamDescriptor:aliasDesc forKeyword:keyDirectObject];
+    
+    DisposeHandle((Handle)alias);
+
+    // Since we don't care about the result, send the event without waiting for a reply.
+    // This allows us to continue without having to block until we receive the reply.
+    AESendMessage([event aeDesc], NULL, kAENoReply, 0);
+}
+
+
+ at end
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 2791a2a..cc1212a 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -299,6 +299,7 @@
 				39446093020F50ED0ECA1767,
 				511D5554033FD51000CA2ACD,
 				516F297003A6C45A00CA2D3A,
+				832B2D1603B10990009CF105,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -412,6 +413,7 @@
 				35081DAD02B6D4E40ACA2ACA,
 				394460A5020F50ED0ECA1767,
 				394460A6020F50ED0ECA1767,
+				832B2D1703B10990009CF105,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -501,6 +503,8 @@
 				F508946A02B71D59018A9CD4,
 				9345DDAE0365FB27008635CE,
 				9345DDAF0365FB27008635CE,
+				832B2D1403B10990009CF105,
+				832B2D1503B10990009CF105,
 				F560BEBC030DAF4401C1A526,
 				F560BEBD030DAF4401C1A526,
 				F59668C802AD2923018635CA,
@@ -1594,6 +1598,30 @@
 			settings = {
 			};
 		};
+		832B2D1403B10990009CF105 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = WebNSWorkspaceExtras.h;
+			refType = 4;
+		};
+		832B2D1503B10990009CF105 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = WebNSWorkspaceExtras.m;
+			refType = 4;
+		};
+		832B2D1603B10990009CF105 = {
+			fileRef = 832B2D1403B10990009CF105;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		832B2D1703B10990009CF105 = {
+			fileRef = 832B2D1503B10990009CF105;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		832E269E036F952E005E2B4F = {
 			children = (
 				83413E8B0375BCD3004719BE,

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list