Changeset 163121 in webkit


Ignore:
Timestamp:
Jan 30, 2014 3:02:39 PM (10 years ago)
Author:
jpfau@apple.com
Message:

Add a method for schemes to be registered as supporting cache partitioning
https://bugs.webkit.org/show_bug.cgi?id=127739

Reviewed by Darin Adler.

Source/WebCore:

Currently, this assumes that schemes supporting cache partitioning
also support (scheme, host) doubles for the scheme. Furthermore,
the scheme is currently discarded when partitioning and is only
checked to ensure that partitioning is supported for that scheme: it
is assumed that all origins with the same host double should be binned
together, regardless of scheme.

  • WebCore.exp.in:
  • page/SecurityOrigin.cpp:

(WebCore::SecurityOrigin::cachePartition):

  • platform/SchemeRegistry.cpp:

(WebCore::CachePartitioningSchemes):
(WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned):
(WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme):

  • platform/SchemeRegistry.h:

Source/WebKit2:

Pipe information about cache partitioned scheme through WebKit2.

  • Shared/WebProcessCreationParameters.cpp:

(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):

  • Shared/WebProcessCreationParameters.h:
  • UIProcess/API/C/WKContext.cpp:

(WKContextRegisterURLSchemeAsCachePartitioned):

  • UIProcess/API/C/WKContextPrivate.h:
  • UIProcess/WebContext.cpp:

(WebKit::WebContext::createNewWebProcess):
(WebKit::WebContext::registerURLSchemeAsCachePartitioned):

  • UIProcess/WebContext.h:
  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::registerURLSchemeAsCachePartitioned):

  • WebProcess/WebProcess.h:
  • WebProcess/WebProcess.messages.in:
Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163118 r163121  
     12014-01-27  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        Add a method for schemes to be registered as supporting cache partitioning
     4        https://bugs.webkit.org/show_bug.cgi?id=127739
     5
     6        Reviewed by Darin Adler.
     7
     8        Currently, this assumes that schemes supporting cache partitioning
     9        also support (scheme, host) doubles for the scheme. Furthermore,
     10        the scheme is currently discarded when partitioning and is only
     11        checked to ensure that partitioning is supported for that scheme: it
     12        is assumed that all origins with the same host double should be binned
     13        together, regardless of scheme.
     14
     15        * WebCore.exp.in:
     16        * page/SecurityOrigin.cpp:
     17        (WebCore::SecurityOrigin::cachePartition):
     18        * platform/SchemeRegistry.cpp:
     19        (WebCore::CachePartitioningSchemes):
     20        (WebCore::SchemeRegistry::registerURLSchemeAsCachePartitioned):
     21        (WebCore::SchemeRegistry::shouldPartitionCacheForURLScheme):
     22        * platform/SchemeRegistry.h:
     23
    1242014-01-30  Jer Noble  <jer.noble@apple.com>
    225
  • trunk/Source/WebCore/WebCore.exp.in

    r163113 r163121  
    387387__ZN7WebCore14SchemeRegistry34registerURLSchemeAsDisplayIsolatedERKN3WTF6StringE
    388388__ZN7WebCore14SchemeRegistry34shouldLoadURLSchemeAsEmptyDocumentERKN3WTF6StringE
     389__ZN7WebCore14SchemeRegistry35registerURLSchemeAsCachePartitionedERKN3WTF6StringE
    389390__ZN7WebCore14SchemeRegistry40setDomainRelaxationForbiddenForURLSchemeEbRKN3WTF6StringE
    390391__ZN7WebCore14SchemeRegistry41allowsLocalStorageAccessInPrivateBrowsingERKN3WTF6StringE
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r156692 r163121  
    445445        return String();
    446446
    447     if (m_protocol != "http" && m_protocol != "https")
    448         return String();
    449 
    450     return host();
     447    if (isHTTPFamily())
     448        return host();
     449
     450    if (SchemeRegistry::shouldPartitionCacheForURLScheme(m_protocol))
     451        return host();
     452
     453    return String();
    451454}
    452455#endif
  • trunk/Source/WebCore/page/SecurityOrigin.h

    r156550 r163121  
    216216    bool passesFileCheck(const SecurityOrigin*) const;
    217217    bool isThirdParty(const SecurityOrigin*) const;
     218
     219    // This method checks that the scheme for this origin is an HTTP-family
     220    // scheme, e.g. HTTP and HTTPS.
     221    bool isHTTPFamily() const { return m_protocol == "http" || m_protocol == "https"; }
    218222   
    219223    enum ShouldAllowFromThirdParty { AlwaysAllowFromThirdParty, MaybeAllowFromThirdParty };
  • trunk/Source/WebCore/platform/SchemeRegistry.cpp

    r156795 r163121  
    2727#include "SchemeRegistry.h"
    2828#include <wtf/MainThread.h>
     29#include <wtf/NeverDestroyed.h>
    2930
    3031namespace WebCore {
     
    165166}
    166167
     168#if ENABLE(CACHE_PARTITIONING)
     169static URLSchemesMap& cachePartitioningSchemes()
     170{
     171    static NeverDestroyed<URLSchemesMap> schemes;
     172    return schemes;
     173}
     174#endif
     175
    167176bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
    168177{
     
    324333}
    325334
     335#if ENABLE(CACHE_PARTITIONING)
     336void SchemeRegistry::registerURLSchemeAsCachePartitioned(const String& scheme)
     337{
     338    cachePartitioningSchemes().add(scheme);
     339}
     340
     341bool SchemeRegistry::shouldPartitionCacheForURLScheme(const String& scheme)
     342{
     343    if (scheme.isEmpty())
     344        return false;
     345    return cachePartitioningSchemes().contains(scheme);
     346}
     347#endif
     348
    326349} // namespace WebCore
  • trunk/Source/WebCore/platform/SchemeRegistry.h

    r150169 r163121  
    9292    // Schemes whose responses can be cached indefinitely.
    9393    static bool shouldCacheResponsesFromURLSchemeIndefinitely(const String& scheme);
     94
     95#if ENABLE(CACHE_PARTITIONING)
     96    // Schemes whose requests should be partitioned in the cache
     97    static void registerURLSchemeAsCachePartitioned(const String& scheme);
     98    static bool shouldPartitionCacheForURLScheme(const String& scheme);
     99#endif
    94100};
    95101
  • trunk/Source/WebKit2/ChangeLog

    r163116 r163121  
     12014-01-27  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        Add a method for schemes to be registered as supporting cache partitioning
     4        https://bugs.webkit.org/show_bug.cgi?id=127739
     5
     6        Reviewed by Darin Adler.
     7
     8        Pipe information about cache partitioned scheme through WebKit2.
     9
     10        * Shared/WebProcessCreationParameters.cpp:
     11        (WebKit::WebProcessCreationParameters::encode):
     12        (WebKit::WebProcessCreationParameters::decode):
     13        * Shared/WebProcessCreationParameters.h:
     14        * UIProcess/API/C/WKContext.cpp:
     15        (WKContextRegisterURLSchemeAsCachePartitioned):
     16        * UIProcess/API/C/WKContextPrivate.h:
     17        * UIProcess/WebContext.cpp:
     18        (WebKit::WebContext::createNewWebProcess):
     19        (WebKit::WebContext::registerURLSchemeAsCachePartitioned):
     20        * UIProcess/WebContext.h:
     21        * WebProcess/WebProcess.cpp:
     22        (WebKit::WebProcess::initializeWebProcess):
     23        (WebKit::WebProcess::registerURLSchemeAsCachePartitioned):
     24        * WebProcess/WebProcess.h:
     25        * WebProcess/WebProcess.messages.in:
     26
    1272014-01-30  Tim Horton  <timothy_horton@apple.com>
    228
  • trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp

    r162904 r163121  
    7171    encoder << urlSchemesRegisteredAsDisplayIsolated;
    7272    encoder << urlSchemesRegisteredAsCORSEnabled;
     73#if ENABLE(CACHE_PARTITIONING)
     74    encoder << urlSchemesRegisteredAsCachePartitioned;
     75#endif
    7376#if ENABLE(CUSTOM_PROTOCOLS)
    7477    encoder << urlSchemesRegisteredForCustomProtocols;
     
    163166    if (!decoder.decode(parameters.urlSchemesRegisteredAsCORSEnabled))
    164167        return false;
     168#if ENABLE(CACHE_PARTITIONING)
     169    if (!decoder.decode(parameters.urlSchemesRegisteredAsCachePartitioned))
     170        return false;
     171#endif
    165172#if ENABLE(CUSTOM_PROTOCOLS)
    166173    if (!decoder.decode(parameters.urlSchemesRegisteredForCustomProtocols))
  • trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h

    r162904 r163121  
    7979    Vector<String> urlSchemesRegisteredAsDisplayIsolated;
    8080    Vector<String> urlSchemesRegisteredAsCORSEnabled;
     81#if ENABLE(CACHE_PARTITIONING)
     82    Vector<String> urlSchemesRegisteredAsCachePartitioned;
     83#endif
    8184#if ENABLE(CUSTOM_PROTOCOLS)
    8285    Vector<String> urlSchemesRegisteredForCustomProtocols;
  • trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp

    r162904 r163121  
    187187}
    188188
     189void WKContextRegisterURLSchemeAsCachePartitioned(WKContextRef contextRef, WKStringRef urlScheme)
     190{
     191#if ENABLE(CACHE_PARTITIONING)
     192    toImpl(contextRef)->registerURLSchemeAsCachePartitioned(toImpl(urlScheme)->string());
     193#else
     194    UNUSED_PARAM(contextRef);
     195    UNUSED_PARAM(urlScheme);
     196#endif
     197}
     198
    189199void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef, WKStringRef urlScheme)
    190200{
  • trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h

    r162904 r163121  
    5353WK_EXPORT void WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKStringRef urlScheme);
    5454
     55WK_EXPORT void WKContextRegisterURLSchemeAsCachePartitioned(WKContextRef context, WKStringRef urlScheme);
     56
    5557WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef context, WKStringRef urlScheme);
    5658
  • trunk/Source/WebKit2/UIProcess/WebContext.cpp

    r162904 r163121  
    577577    copyToVector(m_schemesToRegisterAsDisplayIsolated, parameters.urlSchemesRegisteredAsDisplayIsolated);
    578578    copyToVector(m_schemesToRegisterAsCORSEnabled, parameters.urlSchemesRegisteredAsCORSEnabled);
     579#if ENABLE(CACHE_PARTITIONING)
     580    copyToVector(m_schemesToRegisterAsCachePartitioned, parameters.urlSchemesRegisteredAsCachePartitioned);
     581#endif
    579582
    580583    parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath;
     
    939942#endif
    940943
     944#if ENABLE(CACHE_PARTITIONING)
     945void WebContext::registerURLSchemeAsCachePartitioned(const String& urlScheme)
     946{
     947    m_schemesToRegisterAsCachePartitioned.add(urlScheme);
     948    sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsCachePartitioned(urlScheme));
     949}
     950#endif
     951
    941952void WebContext::setCacheModel(CacheModel cacheModel)
    942953{
  • trunk/Source/WebKit2/UIProcess/WebContext.h

    r162904 r163121  
    190190    void registerURLSchemeAsDisplayIsolated(const String&);
    191191    void registerURLSchemeAsCORSEnabled(const String&);
     192#if ENABLE(CACHE_PARTITIONING)
     193    void registerURLSchemeAsCachePartitioned(const String&);
     194#endif
    192195
    193196    void addVisitedLink(const String&);
     
    453456    HashSet<String> m_schemesToRegisterAsDisplayIsolated;
    454457    HashSet<String> m_schemesToRegisterAsCORSEnabled;
     458#if ENABLE(CACHE_PARTITIONING)
     459    HashSet<String> m_schemesToRegisterAsCachePartitioned;
     460#endif
    455461
    456462    bool m_alwaysUsesComplexTextCodePath;
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r163079 r163121  
    328328        registerURLSchemeAsCORSEnabled(parameters.urlSchemesRegisteredAsCORSEnabled[i]);
    329329
     330#if ENABLE(CACHE_PARTITIONING)
     331    for (auto& scheme : parameters.urlSchemesRegisteredAsCachePartitioned)
     332        registerURLSchemeAsCORSEnabled(scheme);
     333#endif
     334
    330335    setDefaultRequestTimeoutInterval(parameters.defaultRequestTimeoutInterval);
    331336
     
    429434    SchemeRegistry::registerURLSchemeAsCORSEnabled(urlScheme);
    430435}
     436
     437#if ENABLE(CACHE_PARTITIONING)
     438void WebProcess::registerURLSchemeAsCachePartitioned(const String& urlScheme) const
     439{
     440    SchemeRegistry::registerURLSchemeAsCachePartitioned(urlScheme);
     441}
     442#endif
    431443
    432444void WebProcess::setDefaultRequestTimeoutInterval(double timeoutInterval)
  • trunk/Source/WebKit2/WebProcess/WebProcess.h

    r163079 r163121  
    204204    void registerURLSchemeAsDisplayIsolated(const String&) const;
    205205    void registerURLSchemeAsCORSEnabled(const String&) const;
     206#if ENABLE(CACHE_PARTITIONING)
     207    void registerURLSchemeAsCachePartitioned(const String&) const;
     208#endif
    206209    void setDefaultRequestTimeoutInterval(double);
    207210    void setAlwaysUsesComplexTextCodePath(bool);
  • trunk/Source/WebKit2/WebProcess/WebProcess.messages.in

    r162904 r163121  
    4343    RegisterURLSchemeAsDisplayIsolated(String scheme)
    4444    RegisterURLSchemeAsCORSEnabled(String scheme)
     45#if ENABLE(CACHE_PARTITIONING)
     46    RegisterURLSchemeAsCachePartitioned(String scheme)
     47#endif
    4548    SetDefaultRequestTimeoutInterval(double timeoutInterval)
    4649    SetAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText)
Note: See TracChangeset for help on using the changeset viewer.