Add WTF::move()
[WebKit-https.git] / Source / WebKit2 / UIProcess / mac / LegacySessionStateCoding.cpp
index c7ed79b..d94d638 100644 (file)
@@ -52,7 +52,6 @@ static const CFStringRef sessionHistoryEntriesKey = CFSTR("SessionHistoryEntries
 static const CFStringRef sessionHistoryEntryURLKey = CFSTR("SessionHistoryEntryURL");
 static CFStringRef sessionHistoryEntryTitleKey = CFSTR("SessionHistoryEntryTitle");
 static CFStringRef sessionHistoryEntryOriginalURLKey = CFSTR("SessionHistoryEntryOriginalURL");
-static CFStringRef sessionHistoryEntrySnapshotUUIDKey = CFSTR("SessionHistoryEntrySnapshotUUID");
 static CFStringRef sessionHistoryEntryDataKey = CFSTR("SessionHistoryEntryData");
 
 // Session history entry data.
@@ -185,7 +184,7 @@ public:
     MallocPtr<uint8_t> finishEncoding(size_t& size)
     {
         size = m_bufferSize;
-        return std::move(m_buffer);
+        return WTF::move(m_buffer);
     }
 
 private:
@@ -437,7 +436,7 @@ static RetainPtr<CFDictionaryRef> encodeSessionHistory(const BackForwardListStat
         auto originalURL = item.pageState.mainFrameState.originalURLString.createCFString();
         auto data = encodeSessionHistoryEntryData(item.pageState.mainFrameState);
 
-        auto entryDictionary = createDictionary({ { sessionHistoryEntryURLKey, url.get() }, { sessionHistoryEntryTitleKey, title.get() }, { sessionHistoryEntryDataKey, data.get() }, { sessionHistoryEntrySnapshotUUIDKey, item.snapshotUUID.createCFString().get() }});
+        auto entryDictionary = createDictionary({ { sessionHistoryEntryURLKey, url.get() }, { sessionHistoryEntryTitleKey, title.get() }, { sessionHistoryEntryOriginalURLKey, originalURL.get() }, { sessionHistoryEntryDataKey, data.get() } });
 
         CFArrayAppendValue(entries.get(), entryDictionary.get());
     }
@@ -826,7 +825,10 @@ static void decodeFormData(HistoryEntryDataDecoder& decoder, HTTPBody& formData)
         HTTPBody::Element formDataElement;
         decodeFormDataElement(decoder, formDataElement);
 
-        formData.elements.append(std::move(formDataElement));
+        if (!decoder.isValid())
+            return;
+
+        formData.elements.append(WTF::move(formDataElement));
     }
 
     bool hasGeneratedFiles;
@@ -847,7 +849,11 @@ static void decodeBackForwardTreeNode(HistoryEntryDataDecoder& decoder, FrameSta
         decoder >> childFrameState.urlString;
 
         decodeBackForwardTreeNode(decoder, childFrameState);
-        frameState.children.append(std::move(childFrameState));
+
+        if (!decoder.isValid())
+            return;
+
+        frameState.children.append(WTF::move(childFrameState));
     }
 
     decoder >> frameState.documentSequenceNumber;
@@ -859,7 +865,10 @@ static void decodeBackForwardTreeNode(HistoryEntryDataDecoder& decoder, FrameSta
         String state;
         decoder >> state;
 
-        frameState.documentState.append(std::move(state));
+        if (!decoder.isValid())
+            return;
+
+        frameState.documentState.append(WTF::move(state));
     }
 
     String formContentType;
@@ -870,11 +879,11 @@ static void decodeBackForwardTreeNode(HistoryEntryDataDecoder& decoder, FrameSta
 
     if (hasFormData) {
         HTTPBody httpBody;
-        httpBody.contentType = std::move(formContentType);
+        httpBody.contentType = WTF::move(formContentType);
 
         decodeFormData(decoder, httpBody);
 
-        frameState.httpBody = std::move(httpBody);
+        frameState.httpBody = WTF::move(httpBody);
     }
 
     decoder >> frameState.itemSequenceNumber;
@@ -898,7 +907,7 @@ static void decodeBackForwardTreeNode(HistoryEntryDataDecoder& decoder, FrameSta
         Vector<uint8_t> stateObjectData;
         decoder >> stateObjectData;
 
-        frameState.stateObjectData = std::move(stateObjectData);
+        frameState.stateObjectData = WTF::move(stateObjectData);
     }
 
     decoder >> frameState.target;
@@ -954,9 +963,6 @@ static bool decodeSessionHistoryEntry(CFDictionaryRef entryDictionary, BackForwa
     if (!decodeSessionHistoryEntryData(historyEntryData, backForwardListItemState.pageState.mainFrameState))
         return false;
 
-    if (auto snapshotUUID = WTF::dynamic_cf_cast<CFStringRef>(CFDictionaryGetValue(entryDictionary, sessionHistoryEntrySnapshotUUIDKey)))
-        backForwardListItemState.snapshotUUID = snapshotUUID;
-
     backForwardListItemState.pageState.title = title;
     backForwardListItemState.pageState.mainFrameState.urlString = urlString;
     backForwardListItemState.pageState.mainFrameState.originalURLString = originalURLString;
@@ -975,7 +981,7 @@ static bool decodeSessionHistoryEntries(CFArrayRef entriesArray, Vector<BackForw
         if (!decodeSessionHistoryEntry(entryDictionary, entry))
             return false;
 
-        entries.append(std::move(entry));
+        entries.append(WTF::move(entry));
     }
 
     return true;
@@ -1022,7 +1028,7 @@ static bool decodeV1SessionHistory(CFDictionaryRef sessionHistoryDictionary, Bac
     auto currentIndexNumber = dynamic_cf_cast<CFNumberRef>(CFDictionaryGetValue(sessionHistoryDictionary, sessionHistoryCurrentIndexKey));
     if (!currentIndexNumber) {
         // No current index means the dictionary represents an empty session.
-        backForwardListState.currentIndex = 0;
+        backForwardListState.currentIndex = Nullopt;
         backForwardListState.items = { };
         return true;
     }
@@ -1066,11 +1072,8 @@ static bool decodeSessionHistory(CFDictionaryRef backForwardListDictionary, Back
     return false;
 }
 
-bool decodeLegacySessionState(const API::Data& data, SessionState& sessionState)
+bool decodeLegacySessionState(const uint8_t* bytes, size_t size, SessionState& sessionState)
 {
-    size_t size = data.size();
-    const uint8_t* bytes = data.bytes();
-
     if (size < sizeof(uint32_t))
         return false;