Changeset 170719 in webkit


Ignore:
Timestamp:
Jul 2, 2014 1:43:17 PM (10 years ago)
Author:
andersca@apple.com
Message:

Begin ripping out the old session state code
https://bugs.webkit.org/show_bug.cgi?id=134556

Reviewed by Andreas Kling.

  • UIProcess/WebBackForwardList.h:
  • UIProcess/WebPageProxy.h:
  • UIProcess/cf/WebBackForwardListCF.cpp: Removed.
  • UIProcess/cf/WebPageProxyCF.cpp:

(WebKit::WebPageProxy::sessionStateData): Deleted.
(WebKit::WebPageProxy::restoreFromSessionStateData): Deleted.

  • WebKit2.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebKit2
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r170716 r170719  
     12014-07-02  Anders Carlsson  <andersca@apple.com>
     2
     3        Begin ripping out the old session state code
     4        https://bugs.webkit.org/show_bug.cgi?id=134556
     5
     6        Reviewed by Andreas Kling.
     7
     8        * UIProcess/WebBackForwardList.h:
     9        * UIProcess/WebPageProxy.h:
     10        * UIProcess/cf/WebBackForwardListCF.cpp: Removed.
     11        * UIProcess/cf/WebPageProxyCF.cpp:
     12        (WebKit::WebPageProxy::sessionStateData): Deleted.
     13        (WebKit::WebPageProxy::restoreFromSessionStateData): Deleted.
     14        * WebKit2.xcodeproj/project.pbxproj:
     15
    1162014-07-02  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebKit2/UIProcess/WebBackForwardList.h

    r170664 r170719  
    7373    PassRefPtr<API::Array> forwardListAsAPIArrayWithLimit(unsigned limit) const;
    7474
    75 #if USE(CF)
    76     CFDictionaryRef createCFDictionaryRepresentation(std::function<bool (WebBackForwardListItem&)>) const;
    77     bool restoreFromCFDictionaryRepresentation(CFDictionaryRef);
    78     bool restoreFromV0CFDictionaryRepresentation(CFDictionaryRef);
    79     bool restoreFromV1CFDictionaryRepresentation(CFDictionaryRef);
    80 #endif
    81 
    8275    BackForwardListState backForwardListState(const std::function<bool (WebBackForwardListItem&)>&) const;
    8376    void restoreFromState(BackForwardListState);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r170716 r170719  
    552552
    553553    SessionState sessionState(const std::function<bool (WebBackForwardListItem&)>& = nullptr) const;
    554     PassRefPtr<API::Data> sessionStateData(std::function<bool (WebBackForwardListItem&)>) const;
    555     uint64_t restoreFromSessionStateData(API::Data*);
    556554    uint64_t restoreFromSessionState(SessionState);
    557555
  • trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp

    r170660 r170719  
    2727#include "WebPageProxy.h"
    2828
    29 #include "APIData.h"
    30 #include "DataReference.h"
    31 #include "LegacySessionState.h"
    32 #include "Logging.h"
    33 #include "WebBackForwardList.h"
    34 #include "WebPageMessages.h"
    35 #include "WebProcessProxy.h"
    36 #include <CoreFoundation/CFPropertyList.h>
    3729#include <wtf/RetainPtr.h>
    3830#include <wtf/cf/TypeCasts.h>
     
    4133
    4234namespace WebKit {
    43 
    44 static CFStringRef sessionHistoryKey = CFSTR("SessionHistory");
    45 static CFStringRef provisionalURLKey = CFSTR("ProvisionalURL");
    46 
    47 static const UInt32 CurrentSessionStateDataVersion = 2;
    48 
    49 PassRefPtr<API::Data> WebPageProxy::sessionStateData(std::function<bool (WebBackForwardListItem&)> filter) const
    50 {
    51     const void* keys[2];
    52     const void* values[2];
    53     CFIndex numValues = 0;
    54 
    55     RetainPtr<CFDictionaryRef> sessionHistoryDictionary = adoptCF(m_backForwardList->createCFDictionaryRepresentation(std::move(filter)));
    56     if (sessionHistoryDictionary) {
    57         keys[numValues] = sessionHistoryKey;
    58         values[numValues] = sessionHistoryDictionary.get();
    59         ++numValues;
    60     }
    61 
    62     RetainPtr<CFStringRef> provisionalURLString;
    63     if (m_mainFrame) {
    64         String provisionalURL = m_pageLoadState.pendingAPIRequestURL();
    65         if (provisionalURL.isEmpty())
    66             provisionalURL = m_mainFrame->provisionalURL();
    67         if (!provisionalURL.isEmpty()) {
    68             provisionalURLString = provisionalURL.createCFString();
    69             keys[numValues] = provisionalURLKey;
    70             values[numValues] = provisionalURLString.get();
    71             ++numValues;
    72         }
    73     }
    74 
    75     if (!numValues)
    76         return 0;
    77 
    78     RetainPtr<CFDictionaryRef> stateDictionary = adoptCF(CFDictionaryCreate(0, keys, values, numValues, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
    79 
    80     RetainPtr<CFWriteStreamRef> writeStream = adoptCF(CFWriteStreamCreateWithAllocatedBuffers(0, 0));
    81     if (!writeStream)
    82         return 0;
    83    
    84     if (!CFWriteStreamOpen(writeStream.get()))
    85         return 0;
    86    
    87     if (!CFPropertyListWrite(stateDictionary.get(), writeStream.get(), kCFPropertyListBinaryFormat_v1_0, 0, 0))
    88         return 0;
    89        
    90     RetainPtr<CFDataRef> stateCFData = adoptCF((CFDataRef)CFWriteStreamCopyProperty(writeStream.get(), kCFStreamPropertyDataWritten));
    91 
    92     CFIndex length = CFDataGetLength(stateCFData.get());
    93     Vector<unsigned char> stateVector(length + sizeof(UInt32));
    94    
    95     // Put the session state version number at the start of the buffer
    96     stateVector.data()[0] = (CurrentSessionStateDataVersion & 0xFF000000) >> 24;
    97     stateVector.data()[1] = (CurrentSessionStateDataVersion & 0x00FF0000) >> 16;
    98     stateVector.data()[2] = (CurrentSessionStateDataVersion & 0x0000FF00) >> 8;
    99     stateVector.data()[3] = (CurrentSessionStateDataVersion & 0x000000FF);
    100    
    101     // Copy in the actual session state data
    102     CFDataGetBytes(stateCFData.get(), CFRangeMake(0, length), stateVector.data() + sizeof(UInt32));
    103    
    104     return API::Data::create(stateVector);
    105 }
    106 
    107 uint64_t WebPageProxy::restoreFromSessionStateData(API::Data* apiData)
    108 {
    109     if (!apiData || apiData->size() < sizeof(UInt32))
    110         return 0;
    111 
    112     const unsigned char* buffer = apiData->bytes();
    113     UInt32 versionHeader = (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3];
    114    
    115     if (versionHeader != CurrentSessionStateDataVersion) {
    116         LOG(SessionState, "Unrecognized version header for session state data - cannot restore");
    117         return 0;
    118     }
    119    
    120     RetainPtr<CFDataRef> data = adoptCF(CFDataCreate(0, apiData->bytes() + sizeof(UInt32), apiData->size() - sizeof(UInt32)));
    121 
    122     CFErrorRef propertyListError = 0;
    123     auto propertyList = adoptCF(CFPropertyListCreateWithData(0, data.get(), kCFPropertyListImmutable, 0, &propertyListError));
    124     if (propertyListError) {
    125         CFRelease(propertyListError);
    126         LOG(SessionState, "Could not read session state property list");
    127         return 0;
    128     }
    129 
    130     if (!propertyList)
    131         return 0;
    132        
    133     if (CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID()) {
    134         LOG(SessionState, "SessionState property list is not a CFDictionaryRef (%i) - its CFTypeID is %i", (int)CFDictionaryGetTypeID(), (int)CFGetTypeID(propertyList.get()));
    135         return 0;
    136     }
    137 
    138     CFDictionaryRef backForwardListDictionary = 0;
    139     if (CFTypeRef value = CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyList.get()), sessionHistoryKey)) {
    140         if (CFGetTypeID(value) != CFDictionaryGetTypeID())
    141             LOG(SessionState, "SessionState dictionary has a SessionHistory key, but the value is not a dictionary");
    142         else
    143             backForwardListDictionary = static_cast<CFDictionaryRef>(value);
    144     }
    145 
    146     CFStringRef provisionalURL = 0;
    147     if (CFTypeRef value = CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyList.get()), provisionalURLKey)) {
    148         if (CFGetTypeID(value) != CFStringGetTypeID())
    149             LOG(SessionState, "SessionState dictionary has a ProvisionalValue key, but the value is not a string");
    150         else
    151             provisionalURL = static_cast<CFStringRef>(value);
    152     }
    153 
    154     auto transaction = m_pageLoadState.transaction();
    155 
    156     if (backForwardListDictionary) {
    157         if (!m_backForwardList->restoreFromCFDictionaryRepresentation(backForwardListDictionary))
    158             LOG(SessionState, "Failed to restore back/forward list from SessionHistory dictionary");
    159         else {
    160             const BackForwardListItemVector& entries = m_backForwardList->entries();
    161             if (size_t size = entries.size()) {
    162                 for (size_t i = 0; i < size; ++i)
    163                     process().registerNewWebBackForwardListItem(entries[i].get());
    164 
    165                 LegacySessionState state(m_backForwardList->entries(), m_backForwardList->currentIndex());
    166                 if (provisionalURL)
    167                     process().send(Messages::WebPage::RestoreSession(state), m_pageID);
    168                 else {
    169                     if (WebBackForwardListItem* item = m_backForwardList->currentItem())
    170                         m_pageLoadState.setPendingAPIRequestURL(transaction, item->url());
    171 
    172                     uint64_t navigationID = generateNavigationID();
    173                     process().send(Messages::WebPage::RestoreSessionAndNavigateToCurrentItem(navigationID, state), m_pageID);
    174                     return navigationID;
    175                 }
    176             }
    177         }
    178     }
    179 
    180     if (provisionalURL)
    181         return loadRequest(URL(URL(), provisionalURL));
    182 
    183     return 0;
    184 }
    18535
    18636static RetainPtr<CFStringRef> autosaveKey(const String& name)
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r170659 r170719  
    934934                51B15A8413843A3900321AD8 /* EnvironmentUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */; };
    935935                51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */; };
    936                 51B3005012529D0E000B5CA0 /* WebBackForwardListCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */; };
    937936                51B3005112529D0E000B5CA0 /* WebPageProxyCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */; };
    938937                51BA24441858EE3000EA2811 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA24431858EE3000EA2811 /* AsyncTask.h */; };
     
    29532952                51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EnvironmentUtilities.cpp; path = unix/EnvironmentUtilities.cpp; sourceTree = "<group>"; };
    29542953                51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EnvironmentUtilities.h; path = unix/EnvironmentUtilities.h; sourceTree = "<group>"; };
    2955                 51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebBackForwardListCF.cpp; path = cf/WebBackForwardListCF.cpp; sourceTree = "<group>"; };
    29562954                51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPageProxyCF.cpp; path = cf/WebPageProxyCF.cpp; sourceTree = "<group>"; };
    29572955                51BA24431858EE3000EA2811 /* AsyncTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncTask.h; sourceTree = "<group>"; };
     
    53805378                        isa = PBXGroup;
    53815379                        children = (
    5382                                 51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */,
    53835380                                51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */,
    53845381                        );
     
    90669063                                C5E1AFEE16B21025006CC1F2 /* APIWebArchiveResource.cpp in Sources */,
    90679064                                BC72BA1D11E64907001EB4EA /* WebBackForwardList.cpp in Sources */,
    9068                                 51B3005012529D0E000B5CA0 /* WebBackForwardListCF.cpp in Sources */,
    90699065                                1AC133741857C21E00F3EC05 /* APIGeometry.cpp in Sources */,
    90709066                                518D2CAD12D5153B003BB93B /* WebBackForwardListItem.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.