Changeset 170719 in webkit
- Timestamp:
- Jul 2, 2014 1:43:17 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r170716 r170719 1 2014-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 1 16 2014-07-02 Anders Carlsson <andersca@apple.com> 2 17 -
trunk/Source/WebKit2/UIProcess/WebBackForwardList.h
r170664 r170719 73 73 PassRefPtr<API::Array> forwardListAsAPIArrayWithLimit(unsigned limit) const; 74 74 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 #endif81 82 75 BackForwardListState backForwardListState(const std::function<bool (WebBackForwardListItem&)>&) const; 83 76 void restoreFromState(BackForwardListState); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r170716 r170719 552 552 553 553 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*);556 554 uint64_t restoreFromSessionState(SessionState); 557 555 -
trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
r170660 r170719 27 27 #include "WebPageProxy.h" 28 28 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>37 29 #include <wtf/RetainPtr.h> 38 30 #include <wtf/cf/TypeCasts.h> … … 41 33 42 34 namespace 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) const50 {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 buffer96 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 data102 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 else143 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 else151 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 }185 35 186 36 static RetainPtr<CFStringRef> autosaveKey(const String& name) -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r170659 r170719 934 934 51B15A8413843A3900321AD8 /* EnvironmentUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */; }; 935 935 51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */; }; 936 51B3005012529D0E000B5CA0 /* WebBackForwardListCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */; };937 936 51B3005112529D0E000B5CA0 /* WebPageProxyCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */; }; 938 937 51BA24441858EE3000EA2811 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA24431858EE3000EA2811 /* AsyncTask.h */; }; … … 2953 2952 51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EnvironmentUtilities.cpp; path = unix/EnvironmentUtilities.cpp; sourceTree = "<group>"; }; 2954 2953 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>"; };2956 2954 51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPageProxyCF.cpp; path = cf/WebPageProxyCF.cpp; sourceTree = "<group>"; }; 2957 2955 51BA24431858EE3000EA2811 /* AsyncTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncTask.h; sourceTree = "<group>"; }; … … 5380 5378 isa = PBXGroup; 5381 5379 children = ( 5382 51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */,5383 5380 51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */, 5384 5381 ); … … 9066 9063 C5E1AFEE16B21025006CC1F2 /* APIWebArchiveResource.cpp in Sources */, 9067 9064 BC72BA1D11E64907001EB4EA /* WebBackForwardList.cpp in Sources */, 9068 51B3005012529D0E000B5CA0 /* WebBackForwardListCF.cpp in Sources */,9069 9065 1AC133741857C21E00F3EC05 /* APIGeometry.cpp in Sources */, 9070 9066 518D2CAD12D5153B003BB93B /* WebBackForwardListItem.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.