<http://webkit.org/b/69386> REGRESSION: Curious Location of StorageTracker.db
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 21:35:14 +0000 (21:35 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 21:35:14 +0000 (21:35 +0000)
Reviewed by Alexey Proskuryakov.

* Storage/WebStorageManager.mm:
(+[WebStorageManager _storageDirectoryPath]): Restore call to
-[NSString stringByStandardizingPath].  Also fix over-release of
sLocalStoragePath if the initial -objectForKey: call returned an
NSString object.  Use pthread_once to be thread-safe.

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

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Storage/WebStorageManager.mm

index 9d641c6..382b6f2 100644 (file)
@@ -1,3 +1,15 @@
+2011-10-05  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/69386> REGRESSION: Curious Location of StorageTracker.db
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Storage/WebStorageManager.mm:
+        (+[WebStorageManager _storageDirectoryPath]): Restore call to
+        -[NSString stringByStandardizingPath].  Also fix over-release of
+        sLocalStoragePath if the initial -objectForKey: call returned an
+        NSString object.  Use pthread_once to be thread-safe.
+
 2011-10-04  Kent Tamura  <tkent@chromium.org>
 
         Introduce feature flags for incomplete input types
index e799d62..56a3d99 100644 (file)
 
 #import <WebCore/SecurityOrigin.h>
 #import <WebCore/StorageTracker.h>
+#import <pthread.h>
 
 using namespace WebCore;
 
 NSString * const WebStorageDirectoryDefaultsKey = @"WebKitLocalStorageDatabasePathPreferenceKey";
 NSString * const WebStorageDidModifyOriginNotification = @"WebStorageDidModifyOriginNotification";
 
+static NSString *sLocalStoragePath;
+static void initializeLocalStoragePath();
+static pthread_once_t registerLocalStoragePath = PTHREAD_ONCE_INIT;
+
 @implementation WebStorageManager
 
 + (WebStorageManager *)sharedWebStorageManager
@@ -90,21 +95,20 @@ NSString * const WebStorageDidModifyOriginNotification = @"WebStorageDidModifyOr
 
 + (NSString *)_storageDirectoryPath
 {
-    static NSString *sLocalStoragePath;
-    
-    if (sLocalStoragePath)
-        return sLocalStoragePath;
-    
+    pthread_once(&registerLocalStoragePath, initializeLocalStoragePath);
+    return sLocalStoragePath;
+}
+
+static void initializeLocalStoragePath() 
+{
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     sLocalStoragePath = [defaults objectForKey:WebStorageDirectoryDefaultsKey];
     if (!sLocalStoragePath || ![sLocalStoragePath isKindOfClass:[NSString class]]) {
         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
         NSString *libraryDirectory = [paths objectAtIndex:0];
         sLocalStoragePath = [libraryDirectory stringByAppendingPathComponent:@"WebKit/LocalStorage"];
-        [sLocalStoragePath retain];
     }
-
-    return sLocalStoragePath;
+    sLocalStoragePath = [[sLocalStoragePath stringByStandardizingPath] retain];
 }
 
 void WebKitInitializeStorageIfNecessary()