Changeset 162271 in webkit


Ignore:
Timestamp:
Jan 18, 2014 1:14:42 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Flesh out session APIs (still not enabled at API level).
https://bugs.webkit.org/show_bug.cgi?id=126918

Patch by Martin Hock <mhock@apple.com> on 2014-01-18
Reviewed by Alexey Proskuryakov.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::storageSession):
(WebKit::NetworkConnectionToWebProcess::startDownload):
(WebKit::NetworkConnectionToWebProcess::cookiesForDOM):
(WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM):
(WebKit::NetworkConnectionToWebProcess::cookiesEnabled):
(WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue):
(WebKit::NetworkConnectionToWebProcess::getRawCookies):
(WebKit::NetworkConnectionToWebProcess::deleteCookie):

  • NetworkProcess/NetworkConnectionToWebProcess.h:
  • NetworkProcess/NetworkConnectionToWebProcess.messages.in:
  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::ensurePrivateBrowsingSession):
(WebKit::NetworkProcess::destroyPrivateBrowsingSession):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • NetworkProcess/RemoteNetworkingContext.h:
  • NetworkProcess/mac/RemoteNetworkingContext.mm:

(WebKit::RemoteNetworkingContext::storageSession):
(WebKit::RemoteNetworkingContext::ensurePrivateBrowsingSession):

  • NetworkProcess/soup/RemoteNetworkingContextSoup.cpp:

(WebKit::RemoteNetworkingContext::ensurePrivateBrowsingSession):

  • Shared/SessionTracker.cpp: Copied from Source/WebKit2/UIProcess/APISession.cpp.

(WebKit::sessionMap):
(WebKit::identifierBase):
(WebKit::SessionTracker::getSessionMap):
(WebKit::SessionTracker::getIdentifierBase):
(WebKit::SessionTracker::session):
(WebKit::SessionTracker::destroySession):
(WebKit::SessionTracker::setIdentifierBase):

  • Shared/SessionTracker.h: Copied from Source/WebKit2/UIProcess/APISession.h.

(WebKit::SessionTracker::isEphemeralID):

  • Shared/mac/CookieStorageShim.cpp:

(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL):

  • UIProcess/APISession.cpp:

(API::generateID):
(API::Session::defaultSession):
(API::Session::legacyPrivateSession):
(API::Session::Session):
(API::Session::create):
(API::Session::isEphemeral):
(API::Session::getID):

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

(WebKit::WebContext::setAnyPageGroupMightHavePrivateBrowsingEnabled):
(WebKit::WebContext::createNewWebProcess):
(WebKit::WebContext::createWebPage):

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

(WebKit::WebPageProxy::create):
(WebKit::WebPageProxy::WebPageProxy):

  • UIProcess/WebPageProxy.h:

(WebKit::WebPageProxy::sessionID):

  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::createWebPage):

  • UIProcess/WebProcessProxy.h:
  • WebKit2.xcodeproj/project.pbxproj:
  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::setPrivateBrowsingEnabled):

  • WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:

(WebKit::legacySessionID):
(WebKit::WebPlatformStrategies::cookiesForDOM):
(WebKit::WebPlatformStrategies::setCookiesFromDOM):
(WebKit::WebPlatformStrategies::cookiesEnabled):
(WebKit::WebPlatformStrategies::cookieRequestHeaderFieldValue):
(WebKit::WebPlatformStrategies::getRawCookies):
(WebKit::WebPlatformStrategies::deleteCookie):

  • WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
  • WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:

(WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
(WebKit::WebFrameNetworkingContext::storageSession):

  • WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:

(WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::storageSession):

  • WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h:
  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::ensurePrivateBrowsingSession):
(WebKit::WebProcess::destroyPrivateBrowsingSession):

  • WebProcess/WebProcess.h:
  • WebProcess/WebProcess.messages.in:
Location:
trunk/Source/WebKit2
Files:
31 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/CMakeLists.txt

    r162245 r162271  
    205205    Shared/SecurityOriginData.cpp
    206206    Shared/SessionState.cpp
     207    Shared/SessionTracker.cpp
    207208    Shared/ShareableBitmap.cpp
    208209    Shared/ShareableResource.cpp
     
    294295
    295296    UIProcess/APINavigationData.cpp
     297    UIProcess/APISession.cpp
    296298    UIProcess/BackingStore.cpp
    297299    UIProcess/DrawingAreaProxy.cpp
  • trunk/Source/WebKit2/ChangeLog

    r162264 r162271  
     12014-01-18  Martin Hock  <mhock@apple.com>
     2
     3        Flesh out session APIs (still not enabled at API level).
     4        https://bugs.webkit.org/show_bug.cgi?id=126918
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * CMakeLists.txt:
     9        * GNUmakefile.list.am:
     10        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     11        (WebKit::storageSession):
     12        (WebKit::NetworkConnectionToWebProcess::startDownload):
     13        (WebKit::NetworkConnectionToWebProcess::cookiesForDOM):
     14        (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM):
     15        (WebKit::NetworkConnectionToWebProcess::cookiesEnabled):
     16        (WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue):
     17        (WebKit::NetworkConnectionToWebProcess::getRawCookies):
     18        (WebKit::NetworkConnectionToWebProcess::deleteCookie):
     19        * NetworkProcess/NetworkConnectionToWebProcess.h:
     20        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
     21        * NetworkProcess/NetworkProcess.cpp:
     22        (WebKit::NetworkProcess::initializeNetworkProcess):
     23        (WebKit::NetworkProcess::ensurePrivateBrowsingSession):
     24        (WebKit::NetworkProcess::destroyPrivateBrowsingSession):
     25        * NetworkProcess/NetworkProcess.h:
     26        * NetworkProcess/NetworkProcess.messages.in:
     27        * NetworkProcess/RemoteNetworkingContext.h:
     28        * NetworkProcess/mac/RemoteNetworkingContext.mm:
     29        (WebKit::RemoteNetworkingContext::storageSession):
     30        (WebKit::RemoteNetworkingContext::ensurePrivateBrowsingSession):
     31        * NetworkProcess/soup/RemoteNetworkingContextSoup.cpp:
     32        (WebKit::RemoteNetworkingContext::ensurePrivateBrowsingSession):
     33        * Shared/SessionTracker.cpp: Copied from Source/WebKit2/UIProcess/APISession.cpp.
     34        (WebKit::sessionMap):
     35        (WebKit::identifierBase):
     36        (WebKit::SessionTracker::getSessionMap):
     37        (WebKit::SessionTracker::getIdentifierBase):
     38        (WebKit::SessionTracker::session):
     39        (WebKit::SessionTracker::destroySession):
     40        (WebKit::SessionTracker::setIdentifierBase):
     41        * Shared/SessionTracker.h: Copied from Source/WebKit2/UIProcess/APISession.h.
     42        (WebKit::SessionTracker::isEphemeralID):
     43        * Shared/mac/CookieStorageShim.cpp:
     44        (WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL):
     45        * UIProcess/APISession.cpp:
     46        (API::generateID):
     47        (API::Session::defaultSession):
     48        (API::Session::legacyPrivateSession):
     49        (API::Session::Session):
     50        (API::Session::create):
     51        (API::Session::isEphemeral):
     52        (API::Session::getID):
     53        * UIProcess/APISession.h:
     54        * UIProcess/WebContext.cpp:
     55        (WebKit::WebContext::setAnyPageGroupMightHavePrivateBrowsingEnabled):
     56        (WebKit::WebContext::createNewWebProcess):
     57        (WebKit::WebContext::createWebPage):
     58        * UIProcess/WebContext.h:
     59        * UIProcess/WebPageProxy.cpp:
     60        (WebKit::WebPageProxy::create):
     61        (WebKit::WebPageProxy::WebPageProxy):
     62        * UIProcess/WebPageProxy.h:
     63        (WebKit::WebPageProxy::sessionID):
     64        * UIProcess/WebProcessProxy.cpp:
     65        (WebKit::WebProcessProxy::createWebPage):
     66        * UIProcess/WebProcessProxy.h:
     67        * WebKit2.xcodeproj/project.pbxproj:
     68        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     69        (WebKit::InjectedBundle::setPrivateBrowsingEnabled):
     70        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
     71        (WebKit::legacySessionID):
     72        (WebKit::WebPlatformStrategies::cookiesForDOM):
     73        (WebKit::WebPlatformStrategies::setCookiesFromDOM):
     74        (WebKit::WebPlatformStrategies::cookiesEnabled):
     75        (WebKit::WebPlatformStrategies::cookieRequestHeaderFieldValue):
     76        (WebKit::WebPlatformStrategies::getRawCookies):
     77        (WebKit::WebPlatformStrategies::deleteCookie):
     78        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
     79        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
     80        (WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
     81        (WebKit::WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
     82        (WebKit::WebFrameNetworkingContext::storageSession):
     83        * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:
     84        (WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
     85        (WebKit::WebFrameNetworkingContext::storageSession):
     86        * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h:
     87        * WebProcess/WebProcess.cpp:
     88        (WebKit::WebProcess::initializeWebProcess):
     89        (WebKit::WebProcess::ensurePrivateBrowsingSession):
     90        (WebKit::WebProcess::destroyPrivateBrowsingSession):
     91        * WebProcess/WebProcess.h:
     92        * WebProcess/WebProcess.messages.in:
     93
    1942014-01-18  Brian Burg  <bburg@apple.com>
    295
  • trunk/Source/WebKit2/GNUmakefile.list.am

    r162245 r162271  
    443443        Source/WebKit2/Shared/SessionState.cpp \
    444444        Source/WebKit2/Shared/SessionState.h \
     445        Source/WebKit2/Shared/SessionTracker.cpp \
     446        Source/WebKit2/Shared/SessionTracker.h \
    445447        Source/WebKit2/Shared/StatisticsData.cpp \
    446448        Source/WebKit2/Shared/StatisticsData.h \
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r162245 r162271  
    3838#include "NetworkResourceLoaderMessages.h"
    3939#include "RemoteNetworkingContext.h"
     40#include "SessionTracker.h"
    4041#include <WebCore/BlobData.h>
    4142#include <WebCore/PlatformCookieJar.h>
     
    148149}
    149150
    150 static NetworkStorageSession& storageSession(bool privateBrowsingEnabled)
    151 {
    152     if (privateBrowsingEnabled) {
    153         NetworkStorageSession* privateSession = RemoteNetworkingContext::privateBrowsingSession();
     151static NetworkStorageSession& storageSession(uint64_t sessionID)
     152{
     153    if (SessionTracker::isEphemeralID(sessionID)) {
     154        NetworkStorageSession* privateSession = SessionTracker::session(sessionID).get();
    154155        if (privateSession)
    155156            return *privateSession;
     
    161162}
    162163
    163 void NetworkConnectionToWebProcess::startDownload(bool privateBrowsingEnabled, uint64_t downloadID, const ResourceRequest& request)
    164 {
    165     // FIXME: Do something with the private browsing flag.
     164void NetworkConnectionToWebProcess::startDownload(uint64_t sessionID, uint64_t downloadID, const ResourceRequest& request)
     165{
     166    // FIXME: Do something with the session ID.
    166167    NetworkProcess::shared().downloadManager().startDownload(downloadID, request);
    167168}
     
    183184}
    184185
    185 void NetworkConnectionToWebProcess::cookiesForDOM(bool privateBrowsingEnabled, const URL& firstParty, const URL& url, String& result)
    186 {
    187     result = WebCore::cookiesForDOM(storageSession(privateBrowsingEnabled), firstParty, url);
    188 }
    189 
    190 void NetworkConnectionToWebProcess::setCookiesFromDOM(bool privateBrowsingEnabled, const URL& firstParty, const URL& url, const String& cookieString)
    191 {
    192     WebCore::setCookiesFromDOM(storageSession(privateBrowsingEnabled), firstParty, url, cookieString);
    193 }
    194 
    195 void NetworkConnectionToWebProcess::cookiesEnabled(bool privateBrowsingEnabled, const URL& firstParty, const URL& url, bool& result)
    196 {
    197     result = WebCore::cookiesEnabled(storageSession(privateBrowsingEnabled), firstParty, url);
    198 }
    199 
    200 void NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue(bool privateBrowsingEnabled, const URL& firstParty, const URL& url, String& result)
    201 {
    202     result = WebCore::cookieRequestHeaderFieldValue(storageSession(privateBrowsingEnabled), firstParty, url);
    203 }
    204 
    205 void NetworkConnectionToWebProcess::getRawCookies(bool privateBrowsingEnabled, const URL& firstParty, const URL& url, Vector<Cookie>& result)
    206 {
    207     WebCore::getRawCookies(storageSession(privateBrowsingEnabled), firstParty, url, result);
    208 }
    209 
    210 void NetworkConnectionToWebProcess::deleteCookie(bool privateBrowsingEnabled, const URL& url, const String& cookieName)
    211 {
    212     WebCore::deleteCookie(storageSession(privateBrowsingEnabled), url, cookieName);
     186void NetworkConnectionToWebProcess::cookiesForDOM(uint64_t sessionID, const URL& firstParty, const URL& url, String& result)
     187{
     188    result = WebCore::cookiesForDOM(storageSession(sessionID), firstParty, url);
     189}
     190
     191void NetworkConnectionToWebProcess::setCookiesFromDOM(uint64_t sessionID, const URL& firstParty, const URL& url, const String& cookieString)
     192{
     193    WebCore::setCookiesFromDOM(storageSession(sessionID), firstParty, url, cookieString);
     194}
     195
     196void NetworkConnectionToWebProcess::cookiesEnabled(uint64_t sessionID, const URL& firstParty, const URL& url, bool& result)
     197{
     198    result = WebCore::cookiesEnabled(storageSession(sessionID), firstParty, url);
     199}
     200
     201void NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue(uint64_t sessionID, const URL& firstParty, const URL& url, String& result)
     202{
     203    result = WebCore::cookieRequestHeaderFieldValue(storageSession(sessionID), firstParty, url);
     204}
     205
     206void NetworkConnectionToWebProcess::getRawCookies(uint64_t sessionID, const URL& firstParty, const URL& url, Vector<Cookie>& result)
     207{
     208    WebCore::getRawCookies(storageSession(sessionID), firstParty, url, result);
     209}
     210
     211void NetworkConnectionToWebProcess::deleteCookie(uint64_t sessionID, const URL& url, const String& cookieName)
     212{
     213    WebCore::deleteCookie(storageSession(sessionID), url, cookieName);
    213214}
    214215
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h

    r162245 r162271  
    7777    void servePendingRequests(uint32_t resourceLoadPriority);
    7878    void setSerialLoadingEnabled(bool);
    79     void startDownload(bool privateBrowsingEnabled, uint64_t downloadID, const WebCore::ResourceRequest&);
     79    void startDownload(uint64_t sessionID, uint64_t downloadID, const WebCore::ResourceRequest&);
    8080    void convertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
    8181
    82     void cookiesForDOM(bool privateBrowsingEnabled, const WebCore::URL& firstParty, const WebCore::URL&, String& result);
    83     void setCookiesFromDOM(bool privateBrowsingEnabled, const WebCore::URL& firstParty, const WebCore::URL&, const String&);
    84     void cookiesEnabled(bool privateBrowsingEnabled, const WebCore::URL& firstParty, const WebCore::URL&, bool& result);
    85     void cookieRequestHeaderFieldValue(bool privateBrowsingEnabled, const WebCore::URL& firstParty, const WebCore::URL&, String& result);
    86     void getRawCookies(bool privateBrowsingEnabled, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&);
    87     void deleteCookie(bool privateBrowsingEnabled, const WebCore::URL&, const String& cookieName);
     82    void cookiesForDOM(uint64_t sessionID, const WebCore::URL& firstParty, const WebCore::URL&, String& result);
     83    void setCookiesFromDOM(uint64_t sessionID, const WebCore::URL& firstParty, const WebCore::URL&, const String&);
     84    void cookiesEnabled(uint64_t sessionID, const WebCore::URL& firstParty, const WebCore::URL&, bool& result);
     85    void cookieRequestHeaderFieldValue(uint64_t sessionID, const WebCore::URL& firstParty, const WebCore::URL&, String& result);
     86    void getRawCookies(uint64_t sessionID, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&);
     87    void deleteCookie(uint64_t sessionID, const WebCore::URL&, const String& cookieName);
    8888
    8989    void registerBlobURL(const WebCore::URL&, const BlobRegistrationData&);
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in

    r162245 r162271  
    3333    SetSerialLoadingEnabled(bool enabled) -> ()
    3434
    35     StartDownload(bool privateBrowsingEnabled, uint64_t downloadID, WebCore::ResourceRequest request)
     35    StartDownload(uint64_t sessionID, uint64_t downloadID, WebCore::ResourceRequest request)
    3636    ConvertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, WebCore::ResourceRequest request, WebCore::ResourceResponse response)
    3737
    38     CookiesForDOM(bool privateBrowsingEnabled, WebCore::URL firstParty, WebCore::URL url) -> (String result)
    39     SetCookiesFromDOM(bool privateBrowsingEnabled, WebCore::URL firstParty, WebCore::URL url, String cookieString)
    40     CookiesEnabled(bool privateBrowsingEnabled, WebCore::URL firstParty, WebCore::URL url) -> (bool enabled)
    41     CookieRequestHeaderFieldValue(bool privateBrowsingEnabled, WebCore::URL firstParty, WebCore::URL url) -> (String result)
    42     GetRawCookies(bool privateBrowsingEnabled, WebCore::URL firstParty, WebCore::URL url) -> (Vector<WebCore::Cookie> cookies)
    43     DeleteCookie(bool privateBrowsingEnabled, WebCore::URL url, String cookieName)
     38    CookiesForDOM(uint64_t sessionID, WebCore::URL firstParty, WebCore::URL url) -> (String result)
     39    SetCookiesFromDOM(uint64_t sessionID, WebCore::URL firstParty, WebCore::URL url, String cookieString)
     40    CookiesEnabled(uint64_t sessionID, WebCore::URL firstParty, WebCore::URL url) -> (bool enabled)
     41    CookieRequestHeaderFieldValue(uint64_t sessionID, WebCore::URL firstParty, WebCore::URL url) -> (String result)
     42    GetRawCookies(uint64_t sessionID, WebCore::URL firstParty, WebCore::URL url) -> (Vector<WebCore::Cookie> cookies)
     43    DeleteCookie(uint64_t sessionID, WebCore::URL url, String cookieName)
    4444
    4545    RegisterBlobURL(WebCore::URL url, WebKit::BlobRegistrationData data)
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp

    r162245 r162271  
    4040#include "NetworkResourceLoader.h"
    4141#include "RemoteNetworkingContext.h"
     42#include "SessionTracker.h"
    4243#include "StatisticsData.h"
    4344#include "WebContextMessages.h"
     
    158159
    159160#if PLATFORM(MAC) || USE(CFNETWORK)
    160     RemoteNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(parameters.uiProcessBundleIdentifier);
    161 #endif
    162 
     161    SessionTracker::setIdentifierBase(parameters.uiProcessBundleIdentifier);
     162#endif
     163
     164    // FIXME: instead of handling this here, a message should be sent later (scales to multiple sessions)
    163165    if (parameters.privateBrowsingEnabled)
    164         RemoteNetworkingContext::ensurePrivateBrowsingSession();
     166        RemoteNetworkingContext::ensurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID);
    165167
    166168    if (parameters.shouldUseTestingNetworkSession)
     
    213215}
    214216
    215 void NetworkProcess::ensurePrivateBrowsingSession()
    216 {
    217     RemoteNetworkingContext::ensurePrivateBrowsingSession();
    218 }
    219 
    220 void NetworkProcess::destroyPrivateBrowsingSession()
    221 {
    222     RemoteNetworkingContext::destroyPrivateBrowsingSession();
     217void NetworkProcess::ensurePrivateBrowsingSession(uint64_t sessionID)
     218{
     219    RemoteNetworkingContext::ensurePrivateBrowsingSession(sessionID);
     220}
     221
     222void NetworkProcess::destroyPrivateBrowsingSession(uint64_t sessionID)
     223{
     224    SessionTracker::destroySession(sessionID);
    223225}
    224226
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h

    r162245 r162271  
    105105    void initializeNetworkProcess(const NetworkProcessCreationParameters&);
    106106    void createNetworkConnectionToWebProcess();
    107     void ensurePrivateBrowsingSession();
    108     void destroyPrivateBrowsingSession();
     107    void ensurePrivateBrowsingSession(uint64_t sessionID);
     108    void destroyPrivateBrowsingSession(uint64_t sessionID);
    109109    void downloadRequest(uint64_t downloadID, const WebCore::ResourceRequest&);
    110110    void cancelDownload(uint64_t downloadID);
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in

    r162245 r162271  
    3535#endif
    3636
    37     EnsurePrivateBrowsingSession()
    38     DestroyPrivateBrowsingSession()
     37    EnsurePrivateBrowsingSession(uint64_t sessionID)
     38    DestroyPrivateBrowsingSession(uint64_t sessionID)
    3939
    4040    DownloadRequest(uint64_t downloadID, WebCore::ResourceRequest request)
  • trunk/Source/WebKit2/NetworkProcess/RemoteNetworkingContext.h

    r162245 r162271  
    4040    virtual ~RemoteNetworkingContext();
    4141
    42     static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
    43     static void ensurePrivateBrowsingSession();
    44     static void destroyPrivateBrowsingSession();
    45 
    46     static WebCore::NetworkStorageSession* privateBrowsingSession();
     42    // FIXME: remove platform-specific code and use SessionTracker
     43    static void ensurePrivateBrowsingSession(uint64_t sessionID);
    4744
    4845    virtual bool shouldClearReferrerOnHTTPSToHTTPRedirect() const override { return m_shouldClearReferrerOnHTTPSToHTTPRedirect; }
  • trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm

    r162245 r162271  
    2727#import "RemoteNetworkingContext.h"
    2828
     29#import "SessionTracker.h"
    2930#import "WebErrors.h"
    3031#import <WebCore/ResourceError.h>
     
    3738namespace WebKit {
    3839
    39 static std::unique_ptr<NetworkStorageSession>& privateBrowsingStorageSession()
    40 {
    41     ASSERT(isMainThread());
    42     static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
    43     return session;
    44 }
    4540
    4641RemoteNetworkingContext::~RemoteNetworkingContext()
     
    6661{
    6762    if (m_privateBrowsingEnabled) {
    68         NetworkStorageSession* privateSession = privateBrowsingStorageSession().get();
     63        NetworkStorageSession* privateSession = SessionTracker::session(SessionTracker::legacyPrivateSessionID).get();
    6964        if (privateSession)
    7065            return *privateSession;
     
    7570
    7671    return NetworkStorageSession::defaultStorageSession();
    77 }
    78 
    79 NetworkStorageSession* RemoteNetworkingContext::privateBrowsingSession()
    80 {
    81     return privateBrowsingStorageSession().get();
    8272}
    8373
     
    9282}
    9383
    94 static String& privateBrowsingStorageSessionIdentifierBase()
     84void RemoteNetworkingContext::ensurePrivateBrowsingSession(uint64_t sessionID)
    9585{
    96     ASSERT(isMainThread());
    97     static NeverDestroyed<String> base;
    98     return base;
    99 }
    100 
    101 void RemoteNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(const String& identifier)
    102 {
    103     privateBrowsingStorageSessionIdentifierBase() = identifier;
    104 }
    105 
    106 void RemoteNetworkingContext::ensurePrivateBrowsingSession()
    107 {
    108     if (privateBrowsingStorageSession())
     86    if (SessionTracker::session(sessionID))
    10987        return;
    11088
    111     ASSERT(!privateBrowsingStorageSessionIdentifierBase().isNull());
    112     RetainPtr<CFStringRef> cfIdentifier = String(privateBrowsingStorageSessionIdentifierBase() + ".PrivateBrowsing").createCFString();
    113 
    114     privateBrowsingStorageSession() = std::move(NetworkStorageSession::createPrivateBrowsingSession(privateBrowsingStorageSessionIdentifierBase()));
    115 }
    116 
    117 void RemoteNetworkingContext::destroyPrivateBrowsingSession()
    118 {
    119     privateBrowsingStorageSession() = nullptr;
     89    ASSERT(!SessionTracker::getIdentifierBase().isNull());
     90    SessionTracker::session(sessionID) = NetworkStorageSession::createPrivateBrowsingSession(SessionTracker::getIdentifierBase() + '.' + String::number(sessionID));
    12091}
    12192
  • trunk/Source/WebKit2/NetworkProcess/soup/RemoteNetworkingContextSoup.cpp

    r162245 r162271  
    5353}
    5454
    55 void RemoteNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(const String&)
     55void RemoteNetworkingContext::ensurePrivateBrowsingSession(uint64_t sessionID)
    5656{
    5757    notImplemented();
    58 }
    59 
    60 void RemoteNetworkingContext::ensurePrivateBrowsingSession()
    61 {
    62     notImplemented();
    63 }
    64 
    65 void RemoteNetworkingContext::destroyPrivateBrowsingSession()
    66 {
    6758}
    6859
     
    7263}
    7364
    74 NetworkStorageSession* RemoteNetworkingContext::privateBrowsingSession()
    75 {
    76     notImplemented();
    77     return &NetworkStorageSession::defaultStorageSession();
    78 }
    79 
    8065}
    8166
  • trunk/Source/WebKit2/Shared/SessionTracker.cpp

    r162270 r162271  
    2525
    2626#include "config.h"
    27 #include "APISession.h"
     27#include "SessionTracker.h"
    2828
    29 namespace API {
     29#include <wtf/MainThread.h>
     30#include <wtf/NeverDestroyed.h>
    3031
    31 Session::Session(bool isEphemeral)
    32     : m_isEphemeral(isEphemeral)
     32using namespace WebCore;
     33
     34namespace WebKit {
     35
     36static HashMap<uint64_t, std::unique_ptr<NetworkStorageSession>>& sessionMap()
    3337{
     38    ASSERT(isMainThread());
     39
     40    static NeverDestroyed<HashMap<uint64_t, std::unique_ptr<NetworkStorageSession>>> map;
     41    return map.get();
    3442}
    3543
    36 PassRefPtr<Session> Session::create(bool isEphemeral)
     44static String& identifierBase()
    3745{
    38     return adoptRef(new Session(isEphemeral));
     46    ASSERT(isMainThread());
     47
     48    static NeverDestroyed<String> base;
     49    return base;
    3950}
    4051
    41 bool Session::isEphemeral()
     52const HashMap<uint64_t, std::unique_ptr<NetworkStorageSession>>& SessionTracker::getSessionMap()
    4253{
    43     return m_isEphemeral;
     54    return sessionMap();
    4455}
    4556
    46 Session::~Session()
     57const String& SessionTracker::getIdentifierBase()
    4758{
     59    return identifierBase();
    4860}
    4961
    50 } // namespace API
     62std::unique_ptr<NetworkStorageSession>& SessionTracker::session(uint64_t sessionID)
     63{
     64    return sessionMap().add(sessionID, nullptr).iterator->value;
     65}
     66
     67void SessionTracker::destroySession(uint64_t sessionID)
     68{
     69    ASSERT(isMainThread());
     70
     71    sessionMap().remove(sessionID);
     72}
     73
     74void SessionTracker::setIdentifierBase(const String& identifier)
     75{
     76    ASSERT(isMainThread());
     77
     78    identifierBase() = identifier;
     79}
     80
     81} // namespace WebKit
  • trunk/Source/WebKit2/Shared/SessionTracker.h

    r162270 r162271  
    2424 */
    2525
    26 #ifndef APISession_h
    27 #define APISession_h
     26#ifndef SessionTracker_h
     27#define SessionTracker_h
    2828
    29 #include "APIObject.h"
    30 #include <wtf/PassRefPtr.h>
     29#include <WebCore/NetworkStorageSession.h>
     30#include <wtf/HashMap.h>
     31#include <wtf/Noncopyable.h>
     32#include <wtf/text/CString.h>
    3133
    32 namespace API {
     34namespace WebKit {
    3335
    34 class Session : public API::ObjectImpl<API::Object::Type::Session> {
     36class SessionTracker {
     37    WTF_MAKE_NONCOPYABLE(SessionTracker);
    3538public:
    36     static PassRefPtr<Session> create(bool isEphemeral);
    37     bool isEphemeral();
    38     virtual ~Session();
    39 
    40 private:
    41     explicit Session(bool isEphemeral);
    42     bool m_isEphemeral;
     39    static const uint64_t defaultSessionID = 1;
     40    static const uint64_t legacyPrivateSessionID = 2;
     41    static bool isEphemeralID(uint64_t sessionID) { return sessionID != SessionTracker::defaultSessionID; }
     42    static const HashMap<uint64_t, std::unique_ptr<WebCore::NetworkStorageSession>>& getSessionMap();
     43    static const String& getIdentifierBase();
     44    static std::unique_ptr<WebCore::NetworkStorageSession>& session(uint64_t sessionID);
     45    static void destroySession(uint64_t sessionID);
     46    static void setIdentifierBase(const String&);
    4347};
    4448
    45 } // namespace API
     49} // namespace WebKit
    4650
    47 #endif // APISession_h
     51#endif // SessionTracker_h
  • trunk/Source/WebKit2/Shared/mac/CookieStorageShim.cpp

    r161045 r162271  
    3232#include "NetworkConnectionToWebProcess.h"
    3333#include "NetworkProcessConnection.h"
     34#include "SessionTracker.h"
    3435#include "WebCoreArgumentCoders.h"
    3536#include "WebProcess.h"
     
    4849    String cookies;
    4950    URL firstPartyForCookiesURL;
    50     if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(false, firstPartyForCookiesURL, inRequestURL), Messages::NetworkConnectionToWebProcess::CookiesForDOM::Reply(cookies), 0))
     51    if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(SessionTracker::defaultSessionID, firstPartyForCookiesURL, inRequestURL), Messages::NetworkConnectionToWebProcess::CookiesForDOM::Reply(cookies), 0))
    5152        return 0;
    5253
  • trunk/Source/WebKit2/UIProcess/APISession.cpp

    r162245 r162271  
    2727#include "APISession.h"
    2828
     29#include <wtf/MainThread.h>
     30
    2931namespace API {
     32
     33static uint64_t generateID(bool isEphemeral)
     34{
     35    ASSERT(isMainThread());
     36
     37    static uint64_t uniqueSessionID = WebKit::SessionTracker::legacyPrivateSessionID;
     38    ASSERT(isEphemeral);
     39    return ++uniqueSessionID;
     40}
     41
     42Session& Session::defaultSession()
     43{
     44    ASSERT(isMainThread());
     45
     46    static Session* defaultSession = new Session(false, WebKit::SessionTracker::defaultSessionID);
     47    return *defaultSession;
     48}
     49
     50Session& Session::legacyPrivateSession()
     51{
     52    ASSERT(isMainThread());
     53
     54    static Session* legacyPrivateSession = new Session(true, WebKit::SessionTracker::legacyPrivateSessionID);
     55    return *legacyPrivateSession;
     56}
    3057
    3158Session::Session(bool isEphemeral)
    3259    : m_isEphemeral(isEphemeral)
     60    , m_sessionID(generateID(isEphemeral))
     61{
     62}
     63
     64Session::Session(bool isEphemeral, uint64_t sessionID)
     65    : m_isEphemeral(isEphemeral)
     66    , m_sessionID(sessionID)
    3367{
    3468}
     
    3670PassRefPtr<Session> Session::create(bool isEphemeral)
    3771{
     72    // FIXME: support creation of non-default, non-ephemeral sessions
    3873    return adoptRef(new Session(isEphemeral));
    3974}
    4075
    41 bool Session::isEphemeral()
     76bool Session::isEphemeral() const
    4277{
    4378    return m_isEphemeral;
     79}
     80
     81uint64_t Session::getID() const
     82{
     83    return m_sessionID;
    4484}
    4585
  • trunk/Source/WebKit2/UIProcess/APISession.h

    r162245 r162271  
    2828
    2929#include "APIObject.h"
     30#include "SessionTracker.h"
    3031#include <wtf/PassRefPtr.h>
    3132
     
    3536public:
    3637    static PassRefPtr<Session> create(bool isEphemeral);
    37     bool isEphemeral();
     38    static Session& defaultSession();
     39    static Session& legacyPrivateSession();
     40    bool isEphemeral() const;
     41    uint64_t getID() const;
    3842    virtual ~Session();
    3943
    4044private:
    4145    explicit Session(bool isEphemeral);
     46    Session(bool isEphemeral, uint64_t sessionID);
    4247    bool m_isEphemeral;
     48    uint64_t m_sessionID;
    4349};
    4450
  • trunk/Source/WebKit2/UIProcess/WebContext.cpp

    r162245 r162271  
    3333#include "MutableDictionary.h"
    3434#include "SandboxExtension.h"
     35#include "SessionTracker.h"
    3536#include "StatisticsData.h"
    3637#include "TextChecker.h"
     
    468469    if (usesNetworkProcess() && networkProcess()) {
    469470        if (privateBrowsingEnabled)
    470             networkProcess()->send(Messages::NetworkProcess::EnsurePrivateBrowsingSession(), 0);
     471            networkProcess()->send(Messages::NetworkProcess::EnsurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID), 0);
    471472        else
    472             networkProcess()->send(Messages::NetworkProcess::DestroyPrivateBrowsingSession(), 0);
     473            networkProcess()->send(Messages::NetworkProcess::DestroyPrivateBrowsingSession(SessionTracker::legacyPrivateSessionID), 0);
    473474    }
    474475#endif // ENABLED(NETWORK_PROCESS)
    475476
    476477    if (privateBrowsingEnabled)
    477         sendToAllProcesses(Messages::WebProcess::EnsurePrivateBrowsingSession());
     478        sendToAllProcesses(Messages::WebProcess::EnsurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID));
    478479    else
    479         sendToAllProcesses(Messages::WebProcess::DestroyPrivateBrowsingSession());
     480        sendToAllProcesses(Messages::WebProcess::DestroyPrivateBrowsingSession(SessionTracker::legacyPrivateSessionID));
    480481}
    481482
     
    598599
    599600    if (WebPreferences::anyPageGroupsAreUsingPrivateBrowsing())
    600         process->send(Messages::WebProcess::EnsurePrivateBrowsingSession(), 0);
     601        process->send(Messages::WebProcess::EnsurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID), 0);
    601602
    602603    m_processes.append(process);
     
    741742}
    742743
    743 PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient& pageClient, WebPageGroup* pageGroup, WebPageProxy* relatedPage)
     744PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient& pageClient, WebPageGroup* pageGroup, API::Session& session, WebPageProxy* relatedPage)
    744745{
    745746    RefPtr<WebProcessProxy> process;
     
    757758    }
    758759
    759     return process->createWebPage(pageClient, pageGroup ? *pageGroup : m_defaultPageGroup.get());
     760    return process->createWebPage(pageClient, pageGroup ? *pageGroup : m_defaultPageGroup.get(), session);
     761}
     762
     763PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient& pageClient, WebPageGroup* pageGroup, WebPageProxy* relatedPage)
     764{
     765    WebPageGroup* group = pageGroup ? pageGroup : &m_defaultPageGroup.get();
     766    return createWebPage(pageClient, group, group->preferences()->privateBrowsingEnabled() ? API::Session::legacyPrivateSession() : API::Session::defaultSession(), relatedPage);
    760767}
    761768
  • trunk/Source/WebKit2/UIProcess/WebContext.h

    r162245 r162271  
    150150    StorageManager& storageManager() const { return *m_storageManager; }
    151151
     152    PassRefPtr<WebPageProxy> createWebPage(PageClient&, WebPageGroup*, API::Session&, WebPageProxy* relatedPage = 0);
    152153    PassRefPtr<WebPageProxy> createWebPage(PageClient&, WebPageGroup*, WebPageProxy* relatedPage = 0);
    153154
     
    292293    static void willStartUsingPrivateBrowsing();
    293294    static void willStopUsingPrivateBrowsing();
     295
     296    static bool isEphemeralSession(uint64_t sessionID);
    294297
    295298#if USE(SOUP)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r162245 r162271  
    229229#endif // !LOG_DISABLED
    230230
    231 PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, uint64_t pageID)
    232 {
    233     return adoptRef(new WebPageProxy(pageClient, process, pageGroup, pageID));
    234 }
    235 
    236 WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, uint64_t pageID)
     231PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, API::Session& session, uint64_t pageID)
     232{
     233    return adoptRef(new WebPageProxy(pageClient, process, pageGroup, session, pageID));
     234}
     235
     236WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, WebPageGroup& pageGroup, API::Session& session, uint64_t pageID)
    237237    : m_pageClient(pageClient)
    238238    , m_process(process)
     
    280280#endif
    281281    , m_pageID(pageID)
     282    , m_session(session)
    282283    , m_isPageSuspended(false)
    283284#if PLATFORM(MAC)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r162245 r162271  
    2828
    2929#include "APIObject.h"
     30#include "APISession.h"
    3031#include "AutoCorrectionCallback.h"
    3132#include "Connection.h"
     
    7576#include <wtf/PassOwnPtr.h>
    7677#include <wtf/PassRefPtr.h>
     78#include <wtf/Ref.h>
    7779#include <wtf/RefPtr.h>
    7880#include <wtf/Vector.h>
     
    328330public:
    329331
    330     static PassRefPtr<WebPageProxy> create(PageClient&, WebProcessProxy&, WebPageGroup&, uint64_t pageID);
     332    static PassRefPtr<WebPageProxy> create(PageClient&, WebProcessProxy&, WebPageGroup&, API::Session&, uint64_t pageID);
    331333    virtual ~WebPageProxy();
    332334
    333335    uint64_t pageID() const { return m_pageID; }
     336    uint64_t sessionID() const { return m_session->getID(); }
    334337
    335338    WebFrameProxy* mainFrame() const { return m_mainFrame.get(); }
     
    856859       
    857860private:
    858     WebPageProxy(PageClient&, WebProcessProxy&, WebPageGroup&, uint64_t pageID);
     861    WebPageProxy(PageClient&, WebProcessProxy&, WebPageGroup&, API::Session&, uint64_t pageID);
    859862    void platformInitialize();
    860863
     
    13131316
    13141317    uint64_t m_pageID;
     1318    Ref<API::Session> m_session;
    13151319
    13161320    bool m_isPageSuspended;
  • trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp

    r162245 r162271  
    168168}
    169169
    170 PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, WebPageGroup& pageGroup)
     170PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, WebPageGroup& pageGroup, API::Session& session)
    171171{
    172172    uint64_t pageID = generatePageID();
    173     RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, *this, pageGroup, pageID);
     173    RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, *this, pageGroup, session, pageID);
    174174    m_pageMap.set(pageID, webPage.get());
    175175    globalPageMap().set(pageID, webPage.get());
  • trunk/Source/WebKit2/UIProcess/WebProcessProxy.h

    r162245 r162271  
    2727#define WebProcessProxy_h
    2828
     29#include "APISession.h"
    2930#include "ChildProcessProxy.h"
    3031#include "MessageReceiverMap.h"
     
    7879
    7980    static WebPageProxy* webPage(uint64_t pageID);
    80     PassRefPtr<WebPageProxy> createWebPage(PageClient&, WebPageGroup&);
     81    PassRefPtr<WebPageProxy> createWebPage(PageClient&, WebPageGroup&, API::Session&);
    8182    void addExistingWebPage(WebPageProxy*, uint64_t pageID);
    8283    void removeWebPage(uint64_t pageID);
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r162259 r162271  
    788788                728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 728E86EF1795188C0087879E /* WebColorPickerMac.h */; };
    789789                728E86F21795188C0087879E /* WebColorPickerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 728E86F01795188C0087879E /* WebColorPickerMac.mm */; };
     790                753E3E0D1887398500188496 /* SessionTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 753E3E0B1887397300188496 /* SessionTracker.cpp */; };
     791                753E3E0E1887398900188496 /* SessionTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 753E3E091887394B00188496 /* SessionTracker.h */; };
    790792                755422BD18062BB20046F6A8 /* WKOriginDataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 755422B918062B9C0046F6A8 /* WKOriginDataManager.cpp */; };
    791793                755422C418062BF90046F6A8 /* WebOriginDataManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 755422BE18062BE40046F6A8 /* WebOriginDataManagerProxy.cpp */; };
     
    24692471                728E86EF1795188C0087879E /* WebColorPickerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorPickerMac.h; sourceTree = "<group>"; };
    24702472                728E86F01795188C0087879E /* WebColorPickerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebColorPickerMac.mm; sourceTree = "<group>"; };
     2473                753E3E091887394B00188496 /* SessionTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SessionTracker.h; sourceTree = "<group>"; };
     2474                753E3E0B1887397300188496 /* SessionTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SessionTracker.cpp; sourceTree = "<group>"; };
    24712475                755422B918062B9C0046F6A8 /* WKOriginDataManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKOriginDataManager.cpp; sourceTree = "<group>"; };
    24722476                755422BA18062B9C0046F6A8 /* WKOriginDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOriginDataManager.h; sourceTree = "<group>"; };
     
    37293733                                518D2CC812D51DFB003BB93B /* SessionState.cpp */,
    37303734                                518D2CC912D51DFB003BB93B /* SessionState.h */,
     3735                                753E3E0B1887397300188496 /* SessionTracker.cpp */,
     3736                                753E3E091887394B00188496 /* SessionTracker.h */,
    37313737                                1A6420E212DCE2FF00CAAE2C /* ShareableBitmap.cpp */,
    37323738                                1A6420E312DCE2FF00CAAE2C /* ShareableBitmap.h */,
     
    66546660                                BC40760C124FF0270068F20A /* WKURLRequest.h in Headers */,
    66556661                                BC407629124FF0400068F20A /* WKURLRequestNS.h in Headers */,
     6662                                753E3E0E1887398900188496 /* SessionTracker.h in Headers */,
    66566663                                BC40760E124FF0270068F20A /* WKURLResponse.h in Headers */,
    66576664                                759CCD5A1808F6160078E8A8 /* WebOriginDataManagerProxy.h in Headers */,
     
    79127919                                BC498630124D18C100D834E1 /* WKBundleHitTestResult.cpp in Sources */,
    79137920                                6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */,
     7921                                753E3E0D1887398500188496 /* SessionTracker.cpp in Sources */,
    79147922                                BC7043CD12F75EE0006472B9 /* WKBundleNavigationAction.cpp in Sources */,
    79157923                                BC4BEFE2120A1A4C00FBA0C7 /* WKBundleNodeHandle.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r162245 r162271  
    3333#include "LayerTreeHost.h"
    3434#include "NotificationPermissionRequestManager.h"
     35#include "SessionTracker.h"
    3536#include "WKAPICast.h"
    3637#include "WKBundleAPICast.h"
     
    300301#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
    301302    if (enabled)
    302         WebFrameNetworkingContext::ensurePrivateBrowsingSession();
     303        WebFrameNetworkingContext::ensurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID);
    303304    else
    304         WebFrameNetworkingContext::destroyPrivateBrowsingSession();
     305        SessionTracker::destroySession(SessionTracker::legacyPrivateSessionID);
    305306#endif
    306307    const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp

    r162245 r162271  
    3131#include "NetworkResourceLoadParameters.h"
    3232#include "PluginInfoStore.h"
     33#include "SessionTracker.h"
    3334#include "StorageNamespaceImpl.h"
    3435#include "WebContextMessages.h"
     
    7374namespace WebKit {
    7475
     76#if ENABLE(NETWORK_PROCESS)
     77static uint64_t legacySessionID(const NetworkStorageSession &session)
     78{
     79    return session.isPrivateBrowsingSession() ? SessionTracker::legacyPrivateSessionID : SessionTracker::defaultSessionID;
     80}
     81#endif
     82
    7583void WebPlatformStrategies::initialize()
    7684{
     
    134142    if (WebProcess::shared().usesNetworkProcess()) {
    135143        String result;
    136         if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesForDOM(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesForDOM::Reply(result), 0))
     144        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesForDOM(legacySessionID(session), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesForDOM::Reply(result), 0))
    137145            return String();
    138146        return result;
     
    147155#if ENABLE(NETWORK_PROCESS)
    148156    if (WebProcess::shared().usesNetworkProcess()) {
    149         WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::SetCookiesFromDOM(session.isPrivateBrowsingSession(), firstParty, url, cookieString), 0);
     157        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::SetCookiesFromDOM(legacySessionID(session), firstParty, url, cookieString), 0);
    150158        return;
    151159    }
     
    160168    if (WebProcess::shared().usesNetworkProcess()) {
    161169        bool result;
    162         if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesEnabled(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesEnabled::Reply(result), 0))
     170        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesEnabled(legacySessionID(session), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesEnabled::Reply(result), 0))
    163171            return false;
    164172        return result;
     
    174182    if (WebProcess::shared().usesNetworkProcess()) {
    175183        String result;
    176         if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue::Reply(result), 0))
     184        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(legacySessionID(session), firstParty, url), Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue::Reply(result), 0))
    177185            return String();
    178186        return result;
     
    187195#if ENABLE(NETWORK_PROCESS)
    188196    if (WebProcess::shared().usesNetworkProcess()) {
    189         if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::GetRawCookies(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::GetRawCookies::Reply(rawCookies), 0))
     197        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::GetRawCookies(legacySessionID(session), firstParty, url), Messages::NetworkConnectionToWebProcess::GetRawCookies::Reply(rawCookies), 0))
    190198            return false;
    191199        return true;
     
    200208#if ENABLE(NETWORK_PROCESS)
    201209    if (WebProcess::shared().usesNetworkProcess()) {
    202         WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::DeleteCookie(session.isPrivateBrowsingSession(), url, cookieName), 0);
     210        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::DeleteCookie(legacySessionID(session), url, cookieName), 0);
    203211        return;
    204212    }
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h

    r162245 r162271  
    4040    }
    4141
    42     static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
    43     static void ensurePrivateBrowsingSession();
    44     static void destroyPrivateBrowsingSession();
     42    // FIXME: remove platform-specific code and use SessionTracker
     43    static void ensurePrivateBrowsingSession(uint64_t sessionID);
     44
    4545    static void setCookieAcceptPolicyForAllContexts(HTTPCookieAcceptPolicy);
    4646
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm

    r162245 r162271  
    2525
    2626#include "config.h"
     27
     28#include "SessionTracker.h"
    2729#include "WebCookieManager.h"
    2830#include "WebFrameNetworkingContext.h"
     
    3537#include <WebCore/Settings.h>
    3638#include <WebKitSystemInterface.h>
    37 #include <wtf/NeverDestroyed.h>
    3839
    3940using namespace WebCore;
    4041
    4142namespace WebKit {
    42 
    43 static std::unique_ptr<NetworkStorageSession>& privateSession()
     43   
     44void WebFrameNetworkingContext::ensurePrivateBrowsingSession(uint64_t sessionID)
    4445{
    45     static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
    46     return session;
    47 }
    48 
    49 static String& identifierBase()
    50 {
    51     static NeverDestroyed<String> base;
    52     return base;
    53 }
    54    
    55 void WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(const String& base)
    56 {
    57     ASSERT(isMainThread());
    58 
    59     identifierBase() = base;
    60 }
    61 
    62 void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
    63 {
    64     ASSERT(isMainThread());
    65 
    66     if (privateSession())
     46    if (SessionTracker::session(sessionID))
    6747        return;
    6848
    6949    String base;
    70     if (identifierBase().isNull())
     50    if (SessionTracker::getIdentifierBase().isNull())
    7151        base = [[NSBundle mainBundle] bundleIdentifier];
    7252    else
    73         base = identifierBase();
     53        base = SessionTracker::getIdentifierBase();
    7454
    75     privateSession() = NetworkStorageSession::createPrivateBrowsingSession(base);
    76 }
    77 
    78 void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
    79 {
    80     ASSERT(isMainThread());
    81 
    82     privateSession() = nullptr;
     55    SessionTracker::session(sessionID) = NetworkStorageSession::createPrivateBrowsingSession(base + '.' + String::number(sessionID));
    8356}
    8457
     
    9063        WKSetHTTPCookieAcceptPolicy(cookieStorage.get(), policy);
    9164
    92     if (privateSession())
    93         WKSetHTTPCookieAcceptPolicy(privateSession()->cookieStorage().get(), policy);
     65    for (const auto& session : SessionTracker::getSessionMap().values()) {
     66        if (session)
     67            WKSetHTTPCookieAcceptPolicy(session->cookieStorage().get(), policy);
     68    }
    9469}
    9570   
     
    126101
    127102    if (frame() && frame()->settings().privateBrowsingEnabled())
    128         return *privateSession();
     103        return *SessionTracker::session(SessionTracker::legacyPrivateSessionID);
    129104
    130105    return NetworkStorageSession::defaultStorageSession();
    131106}
    132    
    133107WebFrameLoaderClient* WebFrameNetworkingContext::webFrameLoaderClient() const
    134108{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp

    r162245 r162271  
    2828#include "WebFrameNetworkingContext.h"
    2929
     30#include "SessionTracker.h"
    3031#include "WebFrame.h"
    3132#include "WebPage.h"
     
    3738namespace WebKit {
    3839
    39 static std::unique_ptr<NetworkStorageSession>& privateSession()
    40 {
    41     static NeverDestroyed<std::unique_ptr<NetworkStorageSession>> session;
    42     return session;
    43 }
    44 
    45 void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
     40void WebFrameNetworkingContext::ensurePrivateBrowsingSession(uint64_t sessionID)
    4641{
    4742    ASSERT(isMainThread());
    4843
    49     if (privateSession())
     44    if (SessionTracker::session(sessionID))
    5045        return;
    5146
    52     privateSession() = NetworkStorageSession::createPrivateBrowsingSession();
    53 }
    54 
    55 void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
    56 {
    57     ASSERT(isMainThread());
    58 
    59     privateSession() = nullptr;
     47    SessionTracker::session(sessionID) = NetworkStorageSession::createPrivateBrowsingSession(String::number(sessionID));
    6048}
    6149
     
    7159{
    7260    if (frame() && frame()->settings().privateBrowsingEnabled())
    73         return *privateSession();
     61        return *SessionTracker::session(SessionTracker::legacyPrivateSessionID);
    7462
    7563    return NetworkStorageSession::defaultStorageSession();
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h

    r162245 r162271  
    4343    }
    4444
    45     static void ensurePrivateBrowsingSession();
    46     static void destroyPrivateBrowsingSession();
     45    static void ensurePrivateBrowsingSession(uint64_t sessionID);
    4746
    4847    WebFrameLoaderClient* webFrameLoaderClient() const;
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r162245 r162271  
    3434#include "Logging.h"
    3535#include "PluginProcessConnectionManager.h"
     36#include "SessionTracker.h"
    3637#include "StatisticsData.h"
    3738#include "UserData.h"
     
    336337
    337338#if PLATFORM(MAC) || USE(CFNETWORK)
    338     WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(parameters.uiProcessBundleIdentifier);
     339    SessionTracker::setIdentifierBase(parameters.uiProcessBundleIdentifier);
    339340#endif
    340341
     
    453454}
    454455
    455 void WebProcess::ensurePrivateBrowsingSession()
     456void WebProcess::ensurePrivateBrowsingSession(uint64_t sessionID)
    456457{
    457458#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
    458     WebFrameNetworkingContext::ensurePrivateBrowsingSession();
    459 #endif
    460 }
    461 
    462 void WebProcess::destroyPrivateBrowsingSession()
     459    WebFrameNetworkingContext::ensurePrivateBrowsingSession(sessionID);
     460#endif
     461}
     462
     463void WebProcess::destroyPrivateBrowsingSession(uint64_t sessionID)
    463464{
    464465#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
    465     WebFrameNetworkingContext::destroyPrivateBrowsingSession();
     466    SessionTracker::destroySession(sessionID);
    466467#endif
    467468}
  • trunk/Source/WebKit2/WebProcess/WebProcess.h

    r162245 r162271  
    166166    void setCacheModel(uint32_t);
    167167
    168     void ensurePrivateBrowsingSession();
    169     void destroyPrivateBrowsingSession();
    170    
     168    void ensurePrivateBrowsingSession(uint64_t sessionID);
     169    void destroyPrivateBrowsingSession(uint64_t sessionID);
     170
    171171    void pageDidEnterWindow(uint64_t pageID);
    172172    void pageWillLeaveWindow(uint64_t pageID);
  • trunk/Source/WebKit2/WebProcess/WebProcess.messages.in

    r162245 r162271  
    5252#endif
    5353
    54     // Private browsing session is per process. Individual pages or page groups may use the private session or the default one as appropriate.
    55     EnsurePrivateBrowsingSession()
    56     DestroyPrivateBrowsingSession()
     54    // Legacy private browsing session is per process. Individual pages or page groups may use the private session or the default one as appropriate.
     55    EnsurePrivateBrowsingSession(uint64_t sessionID)
     56    DestroyPrivateBrowsingSession(uint64_t sessionID)
    5757
    5858    # Plug-ins.
Note: See TracChangeset for help on using the changeset viewer.