Disable Caches in Safari's Develop menu does not disable caches.
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Mar 2016 20:08:59 +0000 (20:08 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Mar 2016 20:08:59 +0000 (20:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=64483

Reviewed by Antti Koivisto.

Source/WebCore:

Moved feature from Settings to Page.

* history/PageCache.cpp:
(WebCore::canCachePage): Use function on Page instead of Settings.
(WebCore::PageCache::take): Ditto.
(WebCore::PageCache::get): Ditto.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::subresourceCachePolicy): Ditto.
(WebCore::FrameLoader::addExtraFieldsToRequest): Ditto.
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::cachePolicy): Ditto.

* page/Page.h:
(WebCore::Page::isResourceCachingDisabled): Added.
(WebCore::Page::setResourceCachingDisabled): Added.

* page/Settings.in: Removed resourceCachingDisabled.

Source/WebKit/mac:

Removed unneeded WebPreferences property; we don't need this for Legacy WebKit.

* WebView/WebPreferenceKeysPrivate.h: Removed
WebKitResourceCachingDisabledPreferenceKey.
* WebView/WebPreferences.mm:
(-[WebPreferences isResourceCachingDisabled]): Deleted.
(-[WebPreferences setResourceCachingDisabled:]): Deleted.
* WebView/WebPreferencesPrivate.h: Removed resourceCachingDisabled property.
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]): Removed code to update resourceCachingDisabled.

Source/WebKit2:

Moved functions from WKPreferences to WKPage.

* Shared/WebPreferencesDefinitions.h: Removed ResourceCachingDisabled.

* UIProcess/API/C/WKPage.cpp:
(WKPageGetResourceCachingDisabled): Added.
(WKPageSetResourceCachingDisabled): Added.
* UIProcess/API/C/WKPagePrivate.h: Added above functions.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetResourceCachingDisabled): Deleted.
(WKPreferencesGetResourceCachingDisabled): Deleted.
* UIProcess/API/C/WKPreferencesRefPrivate.h: Deleted above functions.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setResourceCachingDisabled): Added.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::isResourceCachingDisabled): Added.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences): Removed code to set the setting
for resourceCachingDisabled..
(WebKit::WebPage::setResourceCachingDisabled): Added.
* WebProcess/WebPage/WebPage.h: Declared setResourceCachingDisabled.
* WebProcess/WebPage/WebPage.messages.in: Added SetResourceCachingDisabled.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198476 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/history/PageCache.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/Settings.in
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

index e29f750..6b6dd85 100644 (file)
@@ -1,3 +1,28 @@
+2016-03-20  Darin Adler  <darin@apple.com>
+
+        Disable Caches in Safari's Develop menu does not disable caches.
+        https://bugs.webkit.org/show_bug.cgi?id=64483
+
+        Reviewed by Antti Koivisto.
+
+        Moved feature from Settings to Page.
+
+        * history/PageCache.cpp:
+        (WebCore::canCachePage): Use function on Page instead of Settings.
+        (WebCore::PageCache::take): Ditto.
+        (WebCore::PageCache::get): Ditto.
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::subresourceCachePolicy): Ditto.
+        (WebCore::FrameLoader::addExtraFieldsToRequest): Ditto.
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::cachePolicy): Ditto.
+
+        * page/Page.h:
+        (WebCore::Page::isResourceCachingDisabled): Added.
+        (WebCore::Page::setResourceCachingDisabled): Added.
+
+        * page/Settings.in: Removed resourceCachingDisabled.
+
 2016-03-20  Dan Bernstein  <mitz@apple.com>
 
         Update build settings
index 17f5a27..b9d8b8a 100644 (file)
@@ -193,7 +193,7 @@ static bool canCachePage(Page& page)
     DiagnosticLoggingClient& diagnosticLoggingClient = mainFrame.diagnosticLoggingClient();
     bool isCacheable = canCacheFrame(mainFrame, diagnosticLoggingClient, indentLevel + 1);
     
-    if (!page.settings().usesPageCache() || page.settings().resourceCachingDisabled()) {
+    if (!page.settings().usesPageCache() || page.isResourceCachingDisabled()) {
         PCLOG("   -Page settings says b/f cache disabled");
         logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::isDisabledKey());
         isCacheable = false;
@@ -423,7 +423,7 @@ std::unique_ptr<CachedPage> PageCache::take(HistoryItem& item, Page* page)
     m_items.remove(&item);
     std::unique_ptr<CachedPage> cachedPage = WTFMove(item.m_cachedPage);
 
-    if (cachedPage->hasExpired() || (page && page->settings().resourceCachingDisabled())) {
+    if (cachedPage->hasExpired() || (page && page->isResourceCachingDisabled())) {
         LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item.url().string().ascii().data());
         logPageCacheFailureDiagnosticMessage(page, DiagnosticLoggingKeys::expiredKey());
         return nullptr;
@@ -441,7 +441,7 @@ CachedPage* PageCache::get(HistoryItem& item, Page* page)
         return nullptr;
     }
 
-    if (cachedPage->hasExpired() || (page && page->settings().resourceCachingDisabled())) {
+    if (cachedPage->hasExpired() || (page && page->isResourceCachingDisabled())) {
         LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item.url().string().ascii().data());
         logPageCacheFailureDiagnosticMessage(page, DiagnosticLoggingKeys::expiredKey());
         remove(item);
index 380bf3f..fb604eb 100644 (file)
@@ -2155,8 +2155,10 @@ FrameLoadType FrameLoader::loadType() const
     
 CachePolicy FrameLoader::subresourceCachePolicy() const
 {
-    if (m_frame.settings().resourceCachingDisabled())
-        return CachePolicyReload;
+    if (Page* page = m_frame.page()) {
+        if (page->isResourceCachingDisabled())
+            return CachePolicyReload;
+    }
 
     if (m_isComplete)
         return CachePolicyVerify;
@@ -2564,7 +2566,8 @@ void FrameLoader::addExtraFieldsToMainResourceRequest(ResourceRequest& request)
 
 void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadType loadType, bool mainResource)
 {
-    bool cachingDisabled = frame().settings().resourceCachingDisabled();
+    Page* page = frame().page();
+    bool cachingDisabled = page && page->isResourceCachingDisabled();
 
     if (cachingDisabled)
         request.setCachePolicy(ReloadIgnoringCacheData);
index e8c117a..61e50c2 100644 (file)
@@ -930,12 +930,14 @@ CachePolicy CachedResourceLoader::cachePolicy(CachedResource::Type type) const
     if (!frame)
         return CachePolicyVerify;
 
-    if (frame->settings().resourceCachingDisabled())
-        return CachePolicyReload;
-
     if (type != CachedResource::MainResource)
         return frame->loader().subresourceCachePolicy();
-    
+
+    if (Page* page = frame->page()) {
+        if (page->isResourceCachingDisabled())
+            return CachePolicyReload;
+    }
+
     switch (frame->loader().loadType()) {
     case FrameLoadType::ReloadFromOrigin:
     case FrameLoadType::Reload:
index 6bd449e..317ad63 100644 (file)
@@ -514,6 +514,9 @@ public:
     String captionUserPreferencesStyleSheet();
     void setCaptionUserPreferencesStyleSheet(const String&);
 
+    bool isResourceCachingDisabled() const { return m_resourceCachingDisabled; }
+    void setResourceCachingDisabled(bool disabled) { m_resourceCachingDisabled = disabled; }
+
 private:
     WEBCORE_EXPORT void initGroup();
 
@@ -694,8 +697,8 @@ private:
     
     bool m_allowsMediaDocumentInlinePlayback { false };
     bool m_showAllPlugins { false };
-
     bool m_controlledByAutomation { false };
+    bool m_resourceCachingDisabled { false };
 };
 
 inline PageGroup& Page::group()
index afda3e9..04f1387 100644 (file)
@@ -251,5 +251,3 @@ httpEquivEnabled initial=true
 # enforces all frame sandbox flags (see enum SandboxFlag in SecurityContext.h), and also disables <meta http-equiv>
 # processing and subframe loading.
 contentDispositionAttachmentSandboxEnabled initial=false
-
-resourceCachingDisabled initial=false
index ced0a8b..1e82ee5 100644 (file)
@@ -1,3 +1,21 @@
+2016-03-20  Darin Adler  <darin@apple.com>
+
+        Disable Caches in Safari's Develop menu does not disable caches.
+        https://bugs.webkit.org/show_bug.cgi?id=64483
+
+        Reviewed by Antti Koivisto.
+
+        Removed unneeded WebPreferences property; we don't need this for Legacy WebKit.
+
+        * WebView/WebPreferenceKeysPrivate.h: Removed
+        WebKitResourceCachingDisabledPreferenceKey.
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences isResourceCachingDisabled]): Deleted.
+        (-[WebPreferences setResourceCachingDisabled:]): Deleted.
+        * WebView/WebPreferencesPrivate.h: Removed resourceCachingDisabled property.
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]): Removed code to update resourceCachingDisabled.
+
 2016-03-20  Dan Bernstein  <mitz@apple.com>
 
         Update build settings
index 23477a3..669d54e 100644 (file)
 #define WebKitMediaKeysStorageDirectoryKey @"WebKitMediaKeysStorageDirectory"
 #define WebKitShadowDOMEnabledPreferenceKey @"WebKitShadowDOMEnabled"
 #define WebKitCustomElementsEnabledPreferenceKey @"WebKitCustomElementsEnabled"
-#define WebKitResourceCachingDisabledPreferenceKey @"WebKitResourceCachingDisabled"
 
 #if !TARGET_OS_IPHONE
 // These are private both because callers should be using the cover methods and because the
index 1bc7496..051041f 100644 (file)
@@ -2700,16 +2700,6 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey:WebKitCustomElementsEnabledPreferenceKey];
 }
 
-- (BOOL)isResourceCachingDisabled
-{
-    return [self _boolValueForKey:WebKitResourceCachingDisabledPreferenceKey];
-}
-
-- (void)setResourceCachingDisabled:(BOOL)flag
-{
-    [self _setBoolValue:flag forKey:WebKitResourceCachingDisabledPreferenceKey];
-}
-
 @end
 
 @implementation WebPreferences (WebInternal)
index 86ef71e..e2857b4 100644 (file)
@@ -484,6 +484,5 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 @property (nonatomic) BOOL javaScriptMarkupEnabled;
 @property (nonatomic) BOOL mediaDataLoadsAutomatically;
 @property (nonatomic) BOOL attachmentElementEnabled;
-@property (nonatomic, getter=isResourceCachingDisabled) BOOL resourceCachingDisabled;
 
 @end
index 781db2b..a1472f5 100644 (file)
@@ -2516,8 +2516,6 @@ static bool needsSelfRetainWhileLoadingQuirk()
 #if ENABLE(ATTACHMENT_ELEMENT)
     settings.setAttachmentElementEnabled([preferences attachmentElementEnabled]);
 #endif
-
-    settings.setResourceCachingDisabled(preferences.resourceCachingDisabled);
 }
 
 static inline IMP getMethod(id o, SEL s)
index cce7b57..c58b0bb 100644 (file)
@@ -1,3 +1,35 @@
+2016-03-20  Darin Adler  <darin@apple.com>
+
+        Disable Caches in Safari's Develop menu does not disable caches.
+        https://bugs.webkit.org/show_bug.cgi?id=64483
+
+        Reviewed by Antti Koivisto.
+
+        Moved functions from WKPreferences to WKPage.
+
+        * Shared/WebPreferencesDefinitions.h: Removed ResourceCachingDisabled.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageGetResourceCachingDisabled): Added.
+        (WKPageSetResourceCachingDisabled): Added.
+        * UIProcess/API/C/WKPagePrivate.h: Added above functions.
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetResourceCachingDisabled): Deleted.
+        (WKPreferencesGetResourceCachingDisabled): Deleted.
+        * UIProcess/API/C/WKPreferencesRefPrivate.h: Deleted above functions.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setResourceCachingDisabled): Added.
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::isResourceCachingDisabled): Added.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences): Removed code to set the setting
+        for resourceCachingDisabled..
+        (WebKit::WebPage::setResourceCachingDisabled): Added.
+        * WebProcess/WebPage/WebPage.h: Declared setResourceCachingDisabled.
+        * WebProcess/WebPage/WebPage.messages.in: Added SetResourceCachingDisabled.
+
 2016-03-20  Dan Bernstein  <mitz@apple.com>
 
         Update build settings
index 8846617..6e00345 100644 (file)
     macro(MockCaptureDevicesEnabled, mockCaptureDevicesEnabled, Bool, bool, false) \
     macro(ShadowDOMEnabled, shadowDOMEnabled, Bool, bool, true) \
     macro(CustomElementsEnabled, customElementsEnabled, Bool, bool, false) \
-    macro(ResourceCachingDisabled, resourceCachingDisabled, Bool, bool, false) \
     FOR_EACH_ADDITIONAL_WEBKIT_BOOL_PREFERENCE(macro) \
     \
 
index 18f47b2..a2aafb3 100644 (file)
@@ -2724,6 +2724,16 @@ void WKPageCallAfterNextPresentationUpdate(WKPageRef pageRef, void* context, WKP
     });
 }
 
+bool WKPageGetResourceCachingDisabled(WKPageRef page)
+{
+    return toImpl(page)->isResourceCachingDisabled();
+}
+
+void WKPageSetResourceCachingDisabled(WKPageRef page, bool disabled)
+{
+    toImpl(page)->setResourceCachingDisabled(disabled);
+}
+
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 // -- DEPRECATED --
index 5886ba2..483b108 100644 (file)
@@ -142,6 +142,9 @@ WK_EXPORT void WKPageLoadURLWithShouldOpenExternalURLsPolicy(WKPageRef page, WKU
 typedef void (*WKPagePostPresentationUpdateFunction)(WKErrorRef, void*);
 WK_EXPORT void WKPageCallAfterNextPresentationUpdate(WKPageRef page, void* context, WKPagePostPresentationUpdateFunction function);
 
+WK_EXPORT bool WKPageGetResourceCachingDisabled(WKPageRef page);
+WK_EXPORT void WKPageSetResourceCachingDisabled(WKPageRef page, bool disabled);
+
 #ifdef __cplusplus
 }
 #endif
index 45cfe2f..87c2809 100644 (file)
@@ -1506,13 +1506,3 @@ bool WKPreferencesGetCustomElementsEnabled(WKPreferencesRef preferencesRef)
 {
     return toImpl(preferencesRef)->shadowDOMEnabled();
 }
-
-void WKPreferencesSetResourceCachingDisabled(WKPreferencesRef preferencesRef, bool flag)
-{
-    toImpl(preferencesRef)->setResourceCachingDisabled(flag);
-}
-
-bool WKPreferencesGetResourceCachingDisabled(WKPreferencesRef preferencesRef)
-{
-    return toImpl(preferencesRef)->resourceCachingDisabled();
-}
index f768f39..c2fb40a 100644 (file)
@@ -419,10 +419,6 @@ WK_EXPORT bool WKPreferencesGetShadowDOMEnabled(WKPreferencesRef);
 WK_EXPORT void WKPreferencesSetCustomElementsEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetCustomElementsEnabled(WKPreferencesRef);
 
-// Defaults to false
-WK_EXPORT void WKPreferencesSetResourceCachingDisabled(WKPreferencesRef, bool flag);
-WK_EXPORT bool WKPreferencesGetResourceCachingDisabled(WKPreferencesRef);
-
 #ifdef __cplusplus
 }
 #endif
index f3c924e..9bac754 100644 (file)
@@ -6222,4 +6222,17 @@ void WebPageProxy::didRestoreScrollPosition()
     m_pageClient.didRestoreScrollPosition();
 }
 
+void WebPageProxy::setResourceCachingDisabled(bool disabled)
+{
+    if (m_isResourceCachingDisabled == disabled)
+        return;
+
+    m_isResourceCachingDisabled = disabled;
+
+    if (!isValid())
+        return;
+
+    m_process->send(Messages::WebPage::SetResourceCachingDisabled(disabled), m_pageID);
+}
+
 } // namespace WebKit
index 7e8d10b..f74c6c0 100644 (file)
@@ -1098,6 +1098,9 @@ public:
 
     void setFocus(bool focused);
 
+    bool isResourceCachingDisabled() const { return m_isResourceCachingDisabled; }
+    void setResourceCachingDisabled(bool);
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&);
     void platformInitialize();
@@ -1794,6 +1797,8 @@ private:
 
     WebCore::MediaProducer::MediaStateFlags m_mediaState { WebCore::MediaProducer::IsNotPlaying };
 
+    bool m_isResourceCachingDisabled { false };
+
 #if ENABLE(MEDIA_SESSION)
     bool m_hasMediaSessionWithActiveMediaElements { false };
 #endif
index 5aae713..3da4928 100644 (file)
@@ -3045,8 +3045,6 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
 
     settings.setShouldDispatchJavaScriptWindowOnErrorEvents(true);
 
-    settings.setResourceCachingDisabled(store.getBoolValueForKey(WebPreferencesKey::resourceCachingDisabledKey()));
-
 #if USE(APPLE_INTERNAL_SDK)
 #include <WebKitAdditions/WebPagePreferences.cpp>
 #endif
@@ -5263,4 +5261,9 @@ void WebPage::didRestoreScrollPosition()
     send(Messages::WebPageProxy::DidRestoreScrollPosition());
 }
 
+void WebPage::setResourceCachingDisabled(bool disabled)
+{
+    m_page->setResourceCachingDisabled(disabled);
+}
+
 } // namespace WebKit
index fb927e6..30a98f4 100644 (file)
@@ -1194,6 +1194,8 @@ private:
     void didEndRequestInstallMissingMediaPlugins(uint32_t result);
 #endif
 
+    void setResourceCachingDisabled(bool);
+
     uint64_t m_pageID;
 
     std::unique_ptr<WebCore::Page> m_page;
index 9419ec2..d32d01b 100644 (file)
@@ -427,4 +427,6 @@ messages -> WebPage LegacyReceiver {
 #if ENABLE(VIDEO) && USE(GSTREAMER)
     DidEndRequestInstallMissingMediaPlugins(uint32_t result)
 #endif
+
+    SetResourceCachingDisabled(bool disabled)
 }