Changeset 96255 in webkit


Ignore:
Timestamp:
Sep 28, 2011 1:46:36 PM (13 years ago)
Author:
adauria@apple.com
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:
Location:
trunk/Source/WebKit/mac
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r96205 r96255  
     12011-09-28  Anton D'Auria  <adauria@apple.com>
     2
     3        Expose +[WebStorageManager _storageDirectoryPath] as SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=68951
     5
     6        Reviewed by Brady Eidson.
     7
     8        This patch exposes +[WebStorageManager _storageDirectoryPath], which
     9        pulls the path from NSUserDefaults if the preference is set. Otherwise,
     10        it falls back on the default path.
     11
     12        * Storage/WebStorageManager.mm:
     13        (+[WebStorageManager _storageDirectoryPath]): Adding static variable
     14        so that we don't reread user defaults repeatedly.
     15        (WebKitInitializeStorageIfNecessary):
     16        * Storage/WebStorageManagerPrivate.h:
     17
    1182011-09-27  Andy Estes  <aestes@apple.com>
    219
  • trunk/Source/WebKit/mac/Storage/WebStorageManager.mm

    r95901 r96255  
    3838NSString * const WebStorageDirectoryDefaultsKey = @"WebKitLocalStorageDatabasePathPreferenceKey";
    3939NSString * const WebStorageDidModifyOriginNotification = @"WebStorageDidModifyOriginNotification";
    40 
    41 static NSString *storageDirectoryPath();
    4240
    4341@implementation WebStorageManager
     
    9189}
    9290
    93 static NSString *storageDirectoryPath()
     91+ (NSString *)_storageDirectoryPath
    9492{
     93    static NSString *sLocalStoragePath;
     94   
     95    if (sLocalStoragePath)
     96        return sLocalStoragePath;
     97   
    9598    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    96     NSString *storageDirectory = [defaults objectForKey:WebStorageDirectoryDefaultsKey];
    97     if (!storageDirectory || ![storageDirectory isKindOfClass:[NSString class]])
    98         storageDirectory = @"~/Library/WebKit/LocalStorage";
    99    
    100     return [storageDirectory stringByStandardizingPath];
     99    sLocalStoragePath = [defaults objectForKey:WebStorageDirectoryDefaultsKey];
     100    if (!sLocalStoragePath || ![sLocalStoragePath isKindOfClass:[NSString class]]) {
     101        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
     102        NSString *libraryDirectory = [paths objectAtIndex:0];
     103        sLocalStoragePath = [libraryDirectory stringByAppendingPathComponent:@"WebKit/LocalStorage"];
     104        [sLocalStoragePath retain];
     105    }
     106
     107    return sLocalStoragePath;
    101108}
    102109
     
    107114        return;
    108115   
    109     StorageTracker::initializeTracker(storageDirectoryPath(), WebStorageTrackerClient::sharedWebStorageTrackerClient());
     116    StorageTracker::initializeTracker([WebStorageManager _storageDirectoryPath], WebStorageTrackerClient::sharedWebStorageTrackerClient());
    110117       
    111118    initialized = YES;
  • trunk/Source/WebKit/mac/Storage/WebStorageManagerPrivate.h

    r95901 r96255  
    4343- (void)syncFileSystemAndTrackerDatabase;
    4444
     45+ (NSString *)_storageDirectoryPath;
     46
    4547@end
    4648
Note: See TracChangeset for help on using the changeset viewer.