Title: [199829] trunk/Source/WebKit/mac
Revision
199829
Author
ander...@apple.com
Date
2016-04-21 13:05:56 -0700 (Thu, 21 Apr 2016)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (199828 => 199829)


--- trunk/Source/WebKit/mac/ChangeLog	2016-04-21 19:37:30 UTC (rev 199828)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-04-21 20:05:56 UTC (rev 199829)
@@ -1,3 +1,30 @@
+2016-04-21  Anders Carlsson  <ander...@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  <bda...@apple.com>
 
         showCandidates() should take a range and the string should be the whole 

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebApplicationCache.mm (199828 => 199829)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebApplicationCache.mm	2016-04-21 19:37:30 UTC (rev 199828)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebApplicationCache.mm	2016-04-21 20:05:56 UTC (rev 199829)
@@ -25,6 +25,7 @@
 
 #import "WebApplicationCacheInternal.h"
 
+#import "WebKitNSStringExtras.h"
 #import "WebSecurityOriginInternal.h"
 #import <WebCore/ApplicationCache.h>
 #import <WebCore/ApplicationCacheStorage.h>
@@ -32,8 +33,8 @@
 #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 @@
     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 @@
 
 WebCore::ApplicationCacheStorage& webApplicationCacheStorage()
 {
-    return ApplicationCacheStorage::singleton();
+    static ApplicationCacheStorage& storage = ApplicationCacheStorage::create(applicationCachePath(), "ApplicationCache").leakRef();
+
+    return storage;
 }

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (199828 => 199829)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2016-04-21 19:37:30 UTC (rev 199828)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2016-04-21 20:05:56 UTC (rev 199829)
@@ -730,29 +730,6 @@
     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 @@
         if ([standardPreferences storageTrackerEnabled])
 #endif
         WebKitInitializeStorageIfNecessary();
-        WebKitInitializeApplicationCachePathIfNecessary();
         WebKitInitializeApplicationStatisticsStoragePathIfNecessary();
 #if ENABLE(GAMEPAD)
         WebKitInitializeGamepadProviderIfNecessary();
@@ -1002,6 +978,7 @@
     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 @@
     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();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to