Skip to content
Permalink
Browse files
Stop using ApplicationCacheStorage::singleton() in WebKitLegacy
https://bugs.webkit.org/show_bug.cgi?id=156859

Reviewed by Tim Horton.

* WebCoreSupport/WebApplicationCache.mm:
(+[WebApplicationCache initializeWithBundleIdentifier:]):
Change this to just store the bundle identifier.

(applicationCacheBundleIdentifier):
Helper function that returns the bundle identifier for the app cache.

(applicationCachePath):
Return the application cache path.

(webApplicationCacheStorage):
Create a new ApplicationCacheStorage object.

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
Set pageConfiguration.applicationCacheStorage to webApplicationCacheStorage().

(WebKitInitializeApplicationCachePathIfNecessary): Deleted.

Canonical link: https://commits.webkit.org/174964@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199829 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Apr 21, 2016
1 parent c7b2e6d commit 5dc5fc92fd1086033384630e22f1d429449d7a42
Showing with 62 additions and 29 deletions.
  1. +27 −0 Source/WebKit/mac/ChangeLog
  2. +33 −5 Source/WebKit/mac/WebCoreSupport/WebApplicationCache.mm
  3. +2 −24 Source/WebKit/mac/WebView/WebView.mm
@@ -1,3 +1,30 @@
2016-04-21 Anders Carlsson <andersca@apple.com>

Stop using ApplicationCacheStorage::singleton() in WebKitLegacy
https://bugs.webkit.org/show_bug.cgi?id=156859

Reviewed by Tim Horton.

* WebCoreSupport/WebApplicationCache.mm:
(+[WebApplicationCache initializeWithBundleIdentifier:]):
Change this to just store the bundle identifier.

(applicationCacheBundleIdentifier):
Helper function that returns the bundle identifier for the app cache.

(applicationCachePath):
Return the application cache path.

(webApplicationCacheStorage):
Create a new ApplicationCacheStorage object.

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
Set pageConfiguration.applicationCacheStorage to webApplicationCacheStorage().

(WebKitInitializeApplicationCachePathIfNecessary): Deleted.

2016-04-21 Beth Dakin <bdakin@apple.com>

showCandidates() should take a range and the string should be the whole
@@ -25,15 +25,16 @@

#import "WebApplicationCacheInternal.h"

#import "WebKitNSStringExtras.h"
#import "WebSecurityOriginInternal.h"
#import <WebCore/ApplicationCache.h>
#import <WebCore/ApplicationCacheStorage.h>
#import <WebCore/SecurityOrigin.h>
#import <wtf/RetainPtr.h>

#if PLATFORM(IOS)
#import "WebKitNSStringExtras.h"
#import "WebSQLiteDatabaseTrackerClient.h"
#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/SQLiteDatabaseTracker.h>
#endif

@@ -42,6 +43,8 @@
@implementation WebApplicationCache

#if PLATFORM(IOS)
static NSString *overrideBundleIdentifier;

// FIXME: This will be removed when WebKitInitializeApplicationCachePathIfNecessary()
// is moved from WebView.mm to WebKitInitializeApplicationCacheIfNecessary() in this file.
// https://bugs.webkit.org/show_bug.cgi?id=57567
@@ -50,15 +53,38 @@ + (void)initializeWithBundleIdentifier:(NSString *)bundleIdentifier
static BOOL initialized = NO;
if (initialized)
return;

SQLiteDatabaseTracker::setClient(WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient());

webApplicationCacheStorage().setCacheDirectory([NSString _webkit_localCacheDirectoryWithBundleIdentifier:bundleIdentifier]);

ASSERT(!overrideBundleIdentifier);
overrideBundleIdentifier = [bundleIdentifier copy];

initialized = YES;
}
#endif

static NSString *applicationCacheBundleIdentifier()
{
#if PLATFORM(IOS)
if (overrideBundleIdentifier)
return overrideBundleIdentifier;
if (WebCore::IOSApplication::isMobileSafari() || WebCore::IOSApplication::isWebApp())
return @"com.apple.WebAppCache";
#endif

NSString *appName = [[NSBundle mainBundle] bundleIdentifier];
if (!appName)
appName = [[NSProcessInfo processInfo] processName];

ASSERT(appName);
return appName;
}

static NSString *applicationCachePath()
{
return [NSString _webkit_localCacheDirectoryWithBundleIdentifier:applicationCacheBundleIdentifier()];
}

+ (long long)maximumSize
{
return webApplicationCacheStorage().maximumSize();
@@ -115,5 +141,7 @@ + (NSArray *)originsWithCache

WebCore::ApplicationCacheStorage& webApplicationCacheStorage()
{
return ApplicationCacheStorage::singleton();
static ApplicationCacheStorage& storage = ApplicationCacheStorage::create(applicationCachePath(), "ApplicationCache").leakRef();

return storage;
}
@@ -730,29 +730,6 @@ + (void)_reportException:(JSValueRef)exception inContext:(JSContextRef)context
reportException(execState, toJS(execState, exception));
}

static void WebKitInitializeApplicationCachePathIfNecessary()
{
static BOOL initialized = NO;
if (initialized)
return;

NSString *appName = [[NSBundle mainBundle] bundleIdentifier];
if (!appName)
appName = [[NSProcessInfo processInfo] processName];
#if PLATFORM(IOS)
if (WebCore::IOSApplication::isMobileSafari() || WebCore::IOSApplication::isWebApp())
appName = @"com.apple.WebAppCache";
#endif

ASSERT(appName);

NSString* cacheDir = [NSString _webkit_localCacheDirectoryWithBundleIdentifier:appName];

webApplicationCacheStorage().setCacheDirectory(cacheDir);

initialized = YES;
}

static void WebKitInitializeApplicationStatisticsStoragePathIfNecessary()
{
static BOOL initialized = NO;
@@ -962,7 +939,6 @@ - (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSSt
if ([standardPreferences storageTrackerEnabled])
#endif
WebKitInitializeStorageIfNecessary();
WebKitInitializeApplicationCachePathIfNecessary();
WebKitInitializeApplicationStatisticsStoragePathIfNecessary();
#if ENABLE(GAMEPAD)
WebKitInitializeGamepadProviderIfNecessary();
@@ -1002,6 +978,7 @@ - (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSSt
pageConfiguration.alternativeTextClient = new WebAlternativeTextClient(self);
pageConfiguration.loaderClientForMainFrame = new WebFrameLoaderClient;
pageConfiguration.progressTrackerClient = new WebProgressTrackerClient(self);
pageConfiguration.applicationCacheStorage = &webApplicationCacheStorage();
pageConfiguration.databaseProvider = &WebDatabaseProvider::singleton();
pageConfiguration.storageNamespaceProvider = &_private->group->storageNamespaceProvider();
pageConfiguration.userContentProvider = &_private->group->userContentController();
@@ -1245,6 +1222,7 @@ - (id)initSimpleHTMLDocumentWithStyle:(NSString *)style frame:(CGRect)frame pref
pageConfiguration.inspectorClient = new WebInspectorClient(self);
pageConfiguration.loaderClientForMainFrame = new WebFrameLoaderClient;
pageConfiguration.progressTrackerClient = new WebProgressTrackerClient(self);
pageConfiguration.applicationCacheStorage = &webApplicationCacheStorage();
pageConfiguration.databaseProvider = &WebDatabaseProvider::singleton();
pageConfiguration.storageNamespaceProvider = &_private->group->storageNamespaceProvider();
pageConfiguration.userContentProvider = &_private->group->userContentController();

0 comments on commit 5dc5fc9

Please sign in to comment.