Title: [162623] trunk
Revision
162623
Author
commit-qu...@webkit.org
Date
2014-01-23 10:20:38 -0800 (Thu, 23 Jan 2014)

Log Message

[Curl] There is no way to specify cache folder.
https://bugs.webkit.org/show_bug.cgi?id=125028

Patch by pe...@outlook.com <pe...@outlook.com> on 2014-01-23
Reviewed by Brent Fulgham.

Source/WebCore:

Fixed logical test, disc cache should be disabled if creating cache folder fails.

* platform/network/curl/CurlCacheManager.cpp:
(WebCore::CurlCacheManager::setCacheDirectory):

Source/WebKit/win:

Added interface methods to set and get cache folder location.

* Interfaces/IWebCache.idl:
* WebCache.cpp:
(WebCache::disabled):
(WebCache::cacheFolder):
(WebCache::setCacheFolder):
* WebCache.h:

Tools:

Enable disc cache in WinLauncher by setting cache folder location.

* WinLauncher/WinLauncher.cpp:
(getAppDataFolder): Added function to get app data folder.
(setCacheFolder): Added function to set cache folder.
(createCrashReport): Use new getAppDataFolder function.
(wWinMain): Use function setCacheFolder to set cache folder location.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (162622 => 162623)


--- trunk/Source/WebCore/ChangeLog	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Source/WebCore/ChangeLog	2014-01-23 18:20:38 UTC (rev 162623)
@@ -1,3 +1,15 @@
+2014-01-23  pe...@outlook.com  <pe...@outlook.com>
+
+        [Curl] There is no way to specify cache folder.
+        https://bugs.webkit.org/show_bug.cgi?id=125028
+
+        Reviewed by Brent Fulgham.
+
+        Fixed logical test, disc cache should be disabled if creating cache folder fails.
+
+        * platform/network/curl/CurlCacheManager.cpp:
+        (WebCore::CurlCacheManager::setCacheDirectory):
+
 2014-01-23  Brady Eidson  <beid...@apple.com>
 
         Unreviewed build fix.

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp (162622 => 162623)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2014-01-23 18:20:38 UTC (rev 162623)
@@ -73,7 +73,7 @@
     }
 
     if (!fileExists(m_cacheDir)) {
-        if (makeAllDirectories(m_cacheDir)) {
+        if (!makeAllDirectories(m_cacheDir)) {
             LOG(Network, "Cache Error: Could not open or create cache directory! CacheManager disabled.\n");
             m_disabled = true;
             return;

Modified: trunk/Source/WebKit/win/ChangeLog (162622 => 162623)


--- trunk/Source/WebKit/win/ChangeLog	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Source/WebKit/win/ChangeLog	2014-01-23 18:20:38 UTC (rev 162623)
@@ -1,3 +1,19 @@
+2014-01-23  pe...@outlook.com  <pe...@outlook.com>
+
+        [Curl] There is no way to specify cache folder.
+        https://bugs.webkit.org/show_bug.cgi?id=125028
+
+        Reviewed by Brent Fulgham.
+
+        Added interface methods to set and get cache folder location.
+
+        * Interfaces/IWebCache.idl:
+        * WebCache.cpp:
+        (WebCache::disabled):
+        (WebCache::cacheFolder):
+        (WebCache::setCacheFolder):
+        * WebCache.h:
+
 2014-01-21  pe...@outlook.com  <pe...@outlook.com>
 
         [WinCairo][Curl] Download request has incorrect user agent string.

Modified: trunk/Source/WebKit/win/Interfaces/IWebCache.idl (162622 => 162623)


--- trunk/Source/WebKit/win/Interfaces/IWebCache.idl	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Source/WebKit/win/Interfaces/IWebCache.idl	2014-01-23 18:20:38 UTC (rev 162623)
@@ -41,4 +41,6 @@
     HRESULT empty();
     HRESULT setDisabled([in] BOOL disabled);
     HRESULT disabled([out, retval] BOOL*);
+    HRESULT cacheFolder([out, retval] BSTR* location);
+    HRESULT setCacheFolder([in] BSTR location);
 }

Modified: trunk/Source/WebKit/win/WebCache.cpp (162622 => 162623)


--- trunk/Source/WebKit/win/WebCache.cpp	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Source/WebKit/win/WebCache.cpp	2014-01-23 18:20:38 UTC (rev 162623)
@@ -29,9 +29,14 @@
 
 #include "CFDictionaryPropertyBag.h"
 #include <WebCore/ApplicationCacheStorage.h>
+#include <WebCore/BString.h>
 #include <WebCore/MemoryCache.h>
 #include <WebCore/CrossOriginPreflightResultCache.h>
 
+#if USE(CURL)
+#include <WebCore/CurlCacheManager.h>
+#endif
+
 // WebCache ---------------------------------------------------------------------------
 
 WebCache::WebCache()
@@ -229,3 +234,25 @@
     *disabled = WebCore::memoryCache()->disabled();
     return S_OK;
 }
+
+HRESULT WebCache::cacheFolder(BSTR* location)
+{
+#if USE(CURL)
+    String cacheFolder = WebCore::CurlCacheManager::getInstance().getCacheDirectory();
+    *location = WebCore::BString(cacheFolder).release();
+    return S_OK;
+#else
+    return E_NOTIMPL;
+#endif
+}
+
+HRESULT WebCache::setCacheFolder(BSTR location)
+{
+#if USE(CURL)
+    String cacheFolder(location, SysStringLen(location));
+    WebCore::CurlCacheManager::getInstance().setCacheDirectory(cacheFolder);
+    return S_OK;
+#else
+    return E_NOTIMPL;
+#endif
+}

Modified: trunk/Source/WebKit/win/WebCache.h (162622 => 162623)


--- trunk/Source/WebKit/win/WebCache.h	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Source/WebKit/win/WebCache.h	2014-01-23 18:20:38 UTC (rev 162623)
@@ -47,7 +47,7 @@
         /* [in][out] */ int* count,
         /* [retval][out] */ IPropertyBag **s);
     
-    virtual HRESULT STDMETHODCALLTYPE empty( void);
+    virtual HRESULT STDMETHODCALLTYPE empty(void);
     
     virtual HRESULT STDMETHODCALLTYPE setDisabled( 
         /* [in] */ BOOL disabled);
@@ -55,6 +55,10 @@
     virtual HRESULT STDMETHODCALLTYPE disabled(
         /* [out][retval] */ BOOL*);
 
+    virtual HRESULT STDMETHODCALLTYPE cacheFolder(/* [out, retval] */ BSTR* location);
+
+    virtual HRESULT STDMETHODCALLTYPE setCacheFolder(/* [in] */ BSTR location);
+
 protected:
     ULONG m_refCount;
 };

Modified: trunk/Tools/ChangeLog (162622 => 162623)


--- trunk/Tools/ChangeLog	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Tools/ChangeLog	2014-01-23 18:20:38 UTC (rev 162623)
@@ -1,3 +1,18 @@
+2014-01-23  pe...@outlook.com  <pe...@outlook.com>
+
+        [Curl] There is no way to specify cache folder.
+        https://bugs.webkit.org/show_bug.cgi?id=125028
+
+        Reviewed by Brent Fulgham.
+
+        Enable disc cache in WinLauncher by setting cache folder location.
+
+        * WinLauncher/WinLauncher.cpp:
+        (getAppDataFolder): Added function to get app data folder.
+        (setCacheFolder): Added function to set cache folder.
+        (createCrashReport): Use new getAppDataFolder function.
+        (wWinMain): Use function setCacheFolder to set cache folder location.
+
 2014-01-23  Daniel Bates  <daba...@apple.com>
 
         build-webkit --sdk=iphonesimulator doesn't think it's building iOS

Modified: trunk/Tools/WinLauncher/WinLauncher.cpp (162622 => 162623)


--- trunk/Tools/WinLauncher/WinLauncher.cpp	2014-01-23 18:15:55 UTC (rev 162622)
+++ trunk/Tools/WinLauncher/WinLauncher.cpp	2014-01-23 18:20:38 UTC (rev 162623)
@@ -77,6 +77,7 @@
 typedef _com_ptr_t<_com_IIID<IWebPreferencesPrivate, &__uuidof(IWebPreferencesPrivate)>> IWebPreferencesPrivatePtr;
 typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr;
 typedef _com_ptr_t<_com_IIID<IWebViewPrivate, &__uuidof(IWebViewPrivate)>> IWebViewPrivatePtr;
+typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr;
 
 // Global Variables:
 HINSTANCE hInst;                                // current instance
@@ -390,6 +391,21 @@
     return TRUE;
 }
 
+static bool getAppDataFolder(_bstr_t& directory)
+{
+    wchar_t appDataDirectory[MAX_PATH];
+    if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
+        return false;
+
+    wchar_t executablePath[MAX_PATH];
+    ::GetModuleFileNameW(0, executablePath, MAX_PATH);
+    ::PathRemoveExtensionW(executablePath);
+
+    directory = _bstr_t(appDataDirectory) + L"\\" + ::PathFindFileNameW(executablePath);
+
+    return true;
+}
+
 static bool setToDefaultPreferences()
 {
     HRESULT hr = gStandardPreferences->QueryInterface(IID_IWebPreferencesPrivate, reinterpret_cast<void**>(&gPrefsPrivate.GetInterfacePtr()));
@@ -416,18 +432,32 @@
     return true;
 }
 
+static bool setCacheFolder()
+{
+    IWebCachePtr webCache;
+
+    HRESULT hr = WebKitCreateInstance(CLSID_WebCache, 0, __uuidof(webCache), reinterpret_cast<void**>(&webCache.GetInterfacePtr()));
+    if (FAILED(hr))
+        return false;
+
+    _bstr_t appDataFolder;
+    if (!getAppDataFolder(appDataFolder))
+        return false;
+
+    appDataFolder += L"\\cache";
+    webCache->setCacheFolder(appDataFolder);
+
+    return true;
+}
+
 void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
 {
-    wchar_t appDataDirectory[MAX_PATH];
-    if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
+    _bstr_t directory;
+
+    if (!getAppDataFolder(directory))
         return;
 
-    wchar_t executablePath[MAX_PATH];
-    ::GetModuleFileNameW(0, executablePath, MAX_PATH);
-    ::PathRemoveExtensionW(executablePath);
-
-    std::wstring directory = std::wstring(appDataDirectory) + L"\\" + PathFindFileNameW(executablePath);
-    if (::SHCreateDirectoryEx(0, directory.c_str(), 0) != ERROR_SUCCESS
+    if (::SHCreateDirectoryEx(0, directory, 0) != ERROR_SUCCESS
         && ::GetLastError() != ERROR_FILE_EXISTS
         && ::GetLastError() != ERROR_ALREADY_EXISTS)
         return;
@@ -548,6 +578,9 @@
     if (FAILED(hr))
         goto exit;
 
+    if (!setCacheFolder())
+        goto exit;
+
     gWebHost = new WinLauncherWebHost();
     gWebHost->AddRef();
     hr = gWebView->setFrameLoadDelegate(gWebHost);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to