Commit 321e25f7 authored by andersca@apple.com's avatar andersca@apple.com

WebCore:

2008-04-28  Anders Carlsson  <andersca@apple.com>

        Reviewed by Sam, Mark, Adele and Darin.

        Add a (currently not called) method for opening the application cache database.
        
        * WebCore.base.exp:
        * loader/appcache/ApplicationCacheStorage.cpp:
        (WebCore::ApplicationCacheStorage::setCacheDirectory):
        (WebCore::ApplicationCacheStorage::openDatabase):
        * loader/appcache/ApplicationCacheStorage.h:

WebKit/mac:

2008-04-28  Anders Carlsson  <andersca@apple.com>

        Reviewed by Sam, Mark, Adele and Darin.

        Initialize the application cache path.
        
        * WebView/WebView.mm:
        (WebKitInitializeApplicationCachePathIfNecessary):
        (-[WebView _commonInitializationWithFrameName:groupName:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 86484824
2008-04-28 Anders Carlsson <andersca@apple.com>
Reviewed by Sam, Mark, Adele and Darin.
Add a (currently not called) method for opening the application cache database.
* WebCore.base.exp:
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::setCacheDirectory):
(WebCore::ApplicationCacheStorage::openDatabase):
* loader/appcache/ApplicationCacheStorage.h:
2008-04-28 Alice Liu <alice.liu@apple.com>
Reviewed by Darin.
......@@ -252,6 +252,7 @@ __ZN7WebCore12TextEncodingC1ERKNS_6StringE
__ZN7WebCore12TextIterator11rangeLengthEPKNS_5RangeEb
__ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_7ElementEiib
__ZN7WebCore12applyCommandEN3WTF10PassRefPtrINS_11EditCommandEEE
__ZN7WebCore12cacheStorageEv
__ZN7WebCore12createMarkupEPKNS_4NodeENS_13EChildrenOnlyEPN3WTF6VectorIPS0_Lm0EEE
__ZN7WebCore12createMarkupEPKNS_5RangeEPN3WTF6VectorIPNS_4NodeELm0EEENS_23EAnnotateForInterchangeEb
__ZN7WebCore12gcControllerEv
......@@ -394,6 +395,7 @@ __ZN7WebCore21isBackForwardLoadTypeENS_13FrameLoadTypeE
__ZN7WebCore21reportThreadViolationEPKc
__ZN7WebCore22createFragmentFromTextEPNS_5RangeERKNS_6StringE
__ZN7WebCore22externalRepresentationEPNS_12RenderObjectE
__ZN7WebCore23ApplicationCacheStorage17setCacheDirectoryERKNS_6StringE
__ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbbbbNS_10EditActionE
__ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE
__ZN7WebCore24createFragmentFromMarkupEPNS_8DocumentERKNS_6StringES4_
......
......@@ -31,6 +31,31 @@
namespace WebCore {
void ApplicationCacheStorage::setCacheDirectory(const String& cacheDirectory)
{
ASSERT(m_cacheDirectory.isNull());
ASSERT(!cacheDirectory.isNull());
m_cacheDirectory = cacheDirectory;
}
void ApplicationCacheStorage::openDatabase(bool createIfDoesNotExist)
{
if (m_database.isOpen())
return;
// The cache directory should never be null, but if it for some weird reason is we bail out.
if (m_cacheDirectory.isNull())
return;
String applicationCachePath = pathByAppendingComponent(m_cacheDirectory, "ApplicationCache.db");
if (!createIfDoesNotExist && !fileExists(applicationCachePath))
return;
makeAllDirectories(m_cacheDirectory);
m_database.open(applicationCachePath);
}
ApplicationCacheStorage& cacheStorage()
{
static ApplicationCacheStorage storage;
......
......@@ -34,6 +34,15 @@
namespace WebCore {
class ApplicationCacheStorage {
public:
void setCacheDirectory(const String&);
public:
void openDatabase(bool createIfDoesNotExist);
String m_cacheDirectory;
SQLiteDatabase m_database;
};
ApplicationCacheStorage& cacheStorage();
......
2008-04-28 Anders Carlsson <andersca@apple.com>
Reviewed by Sam, Mark, Adele and Darin.
Initialize the application cache path.
* WebView/WebView.mm:
(WebKitInitializeApplicationCachePathIfNecessary):
(-[WebView _commonInitializationWithFrameName:groupName:]):
2008-04-28 Alice Liu <alice.liu@apple.com>
Reviewed by Darin.
......
......@@ -93,6 +93,7 @@
#import <JavaScriptCore/RefPtr.h>
#import <JavaScriptCore/array_object.h>
#import <JavaScriptCore/date_object.h>
#import <WebCore/ApplicationCacheStorage.h>
#import <WebCore/Cache.h>
#import <WebCore/ColorMac.h>
#import <WebCore/Document.h>
......@@ -128,6 +129,7 @@
#import <mach-o/dyld.h>
#import <objc/objc-auto.h>
#import <objc/objc-runtime.h>
#import <sys/param.h>
using namespace WebCore;
using namespace KJS;
......@@ -1804,6 +1806,36 @@ WebFrameLoadDelegateImplementationCache* WebViewGetFrameLoadDelegateImplementati
[types release];
}
static void WebKitInitializeApplicationCachePathIfNecessary()
{
static BOOL initialized = NO;
if (initialized)
return;
NSString *appName = [[NSBundle mainBundle] bundleIdentifier];
if (!appName)
appName = [[NSProcessInfo processInfo] processName];
ASSERT(appName);
NSString* cacheDir = nil;
#ifdef BUILDING_ON_TIGER
NSString *cacheDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
#else
char cacheDirectory[MAXPATHLEN];
size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, MAXPATHLEN);
if (cacheDirectoryLen)
cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
#endif
cacheDir = [cacheDir stringByAppendingPathComponent:appName];
cacheStorage().setCacheDirectory(cacheDir);
initialized = YES;
}
- (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName
{
WebPreferences *standardPreferences = [WebPreferences standardPreferences];
......@@ -1826,7 +1858,8 @@ WebFrameLoadDelegateImplementationCache* WebViewGetFrameLoadDelegateImplementati
WebCore::InitializeLoggingChannelsIfNecessary();
[WebHistoryItem initWindowWatcherIfNecessary];
WebKitInitializeDatabasesIfNecessary();
WebKitInitializeApplicationCachePathIfNecessary();
_private->page = new Page(new WebChromeClient(self), new WebContextMenuClient(self), new WebEditorClient(self), new WebDragClient(self), new WebInspectorClient(self));
WebPreferences *prefs = [self preferences];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment