Changeset 106753 in webkit


Ignore:
Timestamp:
Feb 4, 2012 6:53:18 PM (12 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/10660698> Clients cannot prevent caching of individual responses
https://bugs.webkit.org/show_bug.cgi?id=77822

Reviewed by Sam Weinig.

Source/WebKit2:

  • Shared/APIClientTraits.cpp: Added definition of interfaceSizesByVersion for

WKBundlePageResourceLoadClient.

  • Shared/APIClientTraits.h: Added APIClientTraits specialization for WKBundlePageResourceLoadClient.
  • WebProcess/InjectedBundle/API/c/WKBundlePage.h: Added WKBundlePageShouldCacheResponseCallback

typedef, added shouldCacheResponse member to WKBundlePageResourceLoadClient, and bumped
kWKBundlePageResourceLoadClientCurrentVersion to 1.

  • WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp:

(WebKit::InjectedBundlePageResourceLoadClient::shouldCacheResponse): Added. Calls through
to the client if it implements shouldCacheResponse. Returns true otherwise.

  • WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.h:
  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::willCacheResponse): Changed to call
InjectedBundlePageResourceLoadClient::shouldCacheResponse() and return nil if the former
returns false.
(WebKit::WebFrameLoaderClient::shouldCacheResponse): Changed to call
InjectedBundlePageResourceLoadClient::shouldCacheResponse().

Tools:

  • WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:

(WTR::InjectedBundlePage::InjectedBundlePage): Updated for the additional callback.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r106751 r106753  
     12012-02-04  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/10660698> Clients cannot prevent caching of individual responses
     4        https://bugs.webkit.org/show_bug.cgi?id=77822
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Shared/APIClientTraits.cpp: Added definition of interfaceSizesByVersion for
     9        WKBundlePageResourceLoadClient.
     10        * Shared/APIClientTraits.h: Added APIClientTraits specialization for WKBundlePageResourceLoadClient.
     11        * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Added WKBundlePageShouldCacheResponseCallback
     12        typedef, added shouldCacheResponse member to WKBundlePageResourceLoadClient, and bumped
     13        kWKBundlePageResourceLoadClientCurrentVersion to 1.
     14        * WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp:
     15        (WebKit::InjectedBundlePageResourceLoadClient::shouldCacheResponse): Added. Calls through
     16        to the client if it implements shouldCacheResponse. Returns true otherwise.
     17        * WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.h:
     18        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     19        (WebKit::WebFrameLoaderClient::willCacheResponse): Changed to call
     20        InjectedBundlePageResourceLoadClient::shouldCacheResponse() and return nil if the former
     21        returns false.
     22        (WebKit::WebFrameLoaderClient::shouldCacheResponse): Changed to call
     23        InjectedBundlePageResourceLoadClient::shouldCacheResponse().
     24
    1252012-02-04  Sam Weinig  <sam@webkit.org>
    226
  • trunk/Source/WebKit2/Shared/APIClientTraits.cpp

    r99101 r106753  
    3636};
    3737
     38const size_t APIClientTraits<WKBundlePageResourceLoadClient>::interfaceSizesByVersion[] = {
     39    offsetof(WKBundlePageResourceLoadClient, shouldCacheResponse),
     40    sizeof(WKBundlePageResourceLoadClient)
     41};
     42   
    3843const size_t APIClientTraits<WKPageContextMenuClient>::interfaceSizesByVersion[] = {
    3944    offsetof(WKPageContextMenuClient, contextMenuDismissed),
  • trunk/Source/WebKit2/Shared/APIClientTraits.h

    r99101 r106753  
    3232namespace WebKit {
    3333
    34 template <typename ClientInterface> struct APIClientTraits
    35 {
     34template <typename ClientInterface> struct APIClientTraits {
    3635    static const size_t interfaceSizesByVersion[1];
    3736};
    3837template <typename ClientInterface> const size_t APIClientTraits<ClientInterface>::interfaceSizesByVersion[] = { sizeof(ClientInterface) };
    3938
    40 template<> struct APIClientTraits<WKBundlePageLoaderClient>
    41 {
     39template<> struct APIClientTraits<WKBundlePageLoaderClient> {
     40    static const size_t interfaceSizesByVersion[2];
     41};
     42
     43template<> struct APIClientTraits<WKBundlePageResourceLoadClient> {
    4244    static const size_t interfaceSizesByVersion[2];
    4345};
     
    5153};
    5254
    53 template<> struct APIClientTraits<WKPageUIClient>
    54 {
     55template<> struct APIClientTraits<WKPageUIClient> {
    5556    static const size_t interfaceSizesByVersion[2];
    5657};
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

    r99096 r106753  
    165165typedef void (*WKBundlePageDidFinishLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo);
    166166typedef void (*WKBundlePageDidFailLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKErrorRef, const void* clientInfo);
     167typedef bool (*WKBundlePageShouldCacheResponseCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo);
    167168
    168169struct WKBundlePageResourceLoadClient {
    169170    int                                                                 version;
    170171    const void *                                                        clientInfo;
     172
     173    // Version 0.
    171174    WKBundlePageDidInitiateLoadForResourceCallback                      didInitiateLoadForResource;
    172175
     
    178181    WKBundlePageDidFinishLoadForResourceCallback                        didFinishLoadForResource;
    179182    WKBundlePageDidFailLoadForResourceCallback                          didFailLoadForResource;
     183
     184    // Version 1.
     185    WKBundlePageShouldCacheResponseCallback                             shouldCacheResponse;
    180186};
    181187typedef struct WKBundlePageResourceLoadClient WKBundlePageResourceLoadClient;
    182188
    183 enum { kWKBundlePageResourceLoadClientCurrentVersion = 0 };
     189enum { kWKBundlePageResourceLoadClientCurrentVersion = 1 };
    184190
    185191enum {
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp

    r95901 r106753  
    8686}
    8787
     88bool InjectedBundlePageResourceLoadClient::shouldCacheResponse(WebPage* page, WebFrame* frame, uint64_t identifier)
     89{
     90    if (!m_client.shouldCacheResponse)
     91        return true;
     92
     93    return m_client.shouldCacheResponse(toAPI(page), toAPI(frame), identifier, m_client.clientInfo);
     94}
     95
    8896} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.h

    r95901 r106753  
    5353    void didFinishLoadForResource(WebPage*, WebFrame*, uint64_t identifier);
    5454    void didFailLoadForResource(WebPage*, WebFrame*, uint64_t identifier, const WebCore::ResourceError&);
     55    bool shouldCacheResponse(WebPage*, WebFrame*, uint64_t identifier);
    5556};
    5657
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r106492 r106753  
    14171417jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; }
    14181418#endif
     1419
    14191420NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const
    14201421{
    1421     return response;
    1422 }
    1423 
    1424 #endif
     1422    WebPage* webPage = m_frame->page();
     1423    if (!webPage)
     1424        return response;
     1425
     1426    return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(webPage, m_frame, identifier) ? response : nil;
     1427}
     1428
     1429#endif // PLATFORM(MAC)
     1430
    14251431#if PLATFORM(WIN) && USE(CFNETWORK)
    14261432bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length)
    14271433{
    1428     return true;
    1429 }
    1430 
    1431 #endif
     1434    WebPage* webPage = m_frame->page();
     1435    if (!webPage)
     1436        return true;
     1437
     1438    return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(webPage, m_frame, identifier);
     1439}
     1440#endif // PLATFORM(WIN) && USE(CFNETWORK)
    14321441
    14331442bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
  • trunk/Tools/ChangeLog

    r106751 r106753  
     12012-02-04  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/10660698> Clients cannot prevent caching of individual responses
     4        https://bugs.webkit.org/show_bug.cgi?id=77822
     5
     6        Reviewed by Sam Weinig.
     7
     8        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
     9        (WTR::InjectedBundlePage::InjectedBundlePage): Updated for the additional callback.
     10
    1112012-02-04  Sam Weinig  <sam@webkit.org>
    212
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

    r105465 r106753  
    228228        didReceiveContentLengthForResource,
    229229        didFinishLoadForResource,
    230         didFailLoadForResource
     230        didFailLoadForResource,
     231        0, // shouldCacheResponse
    231232    };
    232233    WKBundlePageSetResourceLoadClient(m_page, &resourceLoadClient);
Note: See TracChangeset for help on using the changeset viewer.