Title: [96255] trunk/Source/WebKit/mac
Revision
96255
Author
[email protected]
Date
2011-09-28 13:46:36 -0700 (Wed, 28 Sep 2011)

Log Message

Expose +[WebStorageManager _storageDirectoryPath] as SPI
https://bugs.webkit.org/show_bug.cgi?id=68951

Reviewed by Brady Eidson.

This patch exposes +[WebStorageManager _storageDirectoryPath], which
pulls the path from NSUserDefaults if the preference is set. Otherwise,
it falls back on the default path.

* Storage/WebStorageManager.mm:
(+[WebStorageManager _storageDirectoryPath]): Adding static variable
so that we don't reread user defaults repeatedly.
(WebKitInitializeStorageIfNecessary):
* Storage/WebStorageManagerPrivate.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (96254 => 96255)


--- trunk/Source/WebKit/mac/ChangeLog	2011-09-28 20:21:33 UTC (rev 96254)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-09-28 20:46:36 UTC (rev 96255)
@@ -1,3 +1,20 @@
+2011-09-28  Anton D'Auria  <[email protected]>
+
+        Expose +[WebStorageManager _storageDirectoryPath] as SPI
+        https://bugs.webkit.org/show_bug.cgi?id=68951
+
+        Reviewed by Brady Eidson.
+
+        This patch exposes +[WebStorageManager _storageDirectoryPath], which
+        pulls the path from NSUserDefaults if the preference is set. Otherwise,
+        it falls back on the default path.
+
+        * Storage/WebStorageManager.mm:
+        (+[WebStorageManager _storageDirectoryPath]): Adding static variable
+        so that we don't reread user defaults repeatedly.
+        (WebKitInitializeStorageIfNecessary):
+        * Storage/WebStorageManagerPrivate.h:
+
 2011-09-27  Andy Estes  <[email protected]>
 
         WebKitLinkedOnOrAfter() check is ineffective for Solar Walk app-specific hack.

Modified: trunk/Source/WebKit/mac/Storage/WebStorageManager.mm (96254 => 96255)


--- trunk/Source/WebKit/mac/Storage/WebStorageManager.mm	2011-09-28 20:21:33 UTC (rev 96254)
+++ trunk/Source/WebKit/mac/Storage/WebStorageManager.mm	2011-09-28 20:46:36 UTC (rev 96255)
@@ -38,8 +38,6 @@
 NSString * const WebStorageDirectoryDefaultsKey = @"WebKitLocalStorageDatabasePathPreferenceKey";
 NSString * const WebStorageDidModifyOriginNotification = @"WebStorageDidModifyOriginNotification";
 
-static NSString *storageDirectoryPath();
-
 @implementation WebStorageManager
 
 + (WebStorageManager *)sharedWebStorageManager
@@ -90,14 +88,23 @@
     StorageTracker::tracker().syncFileSystemAndTrackerDatabase();
 }
 
-static NSString *storageDirectoryPath()
++ (NSString *)_storageDirectoryPath
 {
+    static NSString *sLocalStoragePath;
+    
+    if (sLocalStoragePath)
+        return sLocalStoragePath;
+    
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    NSString *storageDirectory = [defaults objectForKey:WebStorageDirectoryDefaultsKey];
-    if (!storageDirectory || ![storageDirectory isKindOfClass:[NSString class]])
-        storageDirectory = @"~/Library/WebKit/LocalStorage";
-    
-    return [storageDirectory stringByStandardizingPath];
+    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;
 }
 
 void WebKitInitializeStorageIfNecessary()
@@ -106,7 +113,7 @@
     if (initialized)
         return;
     
-    StorageTracker::initializeTracker(storageDirectoryPath(), WebStorageTrackerClient::sharedWebStorageTrackerClient());
+    StorageTracker::initializeTracker([WebStorageManager _storageDirectoryPath], WebStorageTrackerClient::sharedWebStorageTrackerClient());
         
     initialized = YES;
 }

Modified: trunk/Source/WebKit/mac/Storage/WebStorageManagerPrivate.h (96254 => 96255)


--- trunk/Source/WebKit/mac/Storage/WebStorageManagerPrivate.h	2011-09-28 20:21:33 UTC (rev 96254)
+++ trunk/Source/WebKit/mac/Storage/WebStorageManagerPrivate.h	2011-09-28 20:46:36 UTC (rev 96255)
@@ -42,5 +42,7 @@
 - (void)syncLocalStorage;
 - (void)syncFileSystemAndTrackerDatabase;
 
++ (NSString *)_storageDirectoryPath;
+
 @end
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to