Title: [170657] trunk/Source/WebKit2
Revision
170657
Author
ander...@apple.com
Date
2014-07-01 12:34:57 -0700 (Tue, 01 Jul 2014)

Log Message

Implement encodeSessionHistoryEntryData
https://bugs.webkit.org/show_bug.cgi?id=134505

Reviewed by Tim Horton.

* UIProcess/API/C/WKPage.cpp:
(WKPageCopySessionState):
Add back a missing null check for the filter pointer.

* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::encodeSessionHistoryEntryData):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170656 => 170657)


--- trunk/Source/WebKit2/ChangeLog	2014-07-01 19:15:39 UTC (rev 170656)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-01 19:34:57 UTC (rev 170657)
@@ -1,3 +1,17 @@
+2014-07-01  Anders Carlsson  <ander...@apple.com>
+
+        Implement encodeSessionHistoryEntryData
+        https://bugs.webkit.org/show_bug.cgi?id=134505
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageCopySessionState):
+        Add back a missing null check for the filter pointer.
+
+        * UIProcess/mac/LegacySessionStateCoding.cpp:
+        (WebKit::encodeSessionHistoryEntryData):
+
 2014-07-01  Simon Fraser  <simon.fra...@apple.com>
 
         [UI-side compositing] Bad spinner on news.google.com: animations need to be ordered

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (170656 => 170657)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-07-01 19:15:39 UTC (rev 170656)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2014-07-01 19:34:57 UTC (rev 170657)
@@ -352,11 +352,13 @@
 WKDataRef WKPageCopySessionState(WKPageRef pageRef, void *context, WKPageSessionStateFilterCallback filter)
 {
     return toAPI(toImpl(pageRef)->sessionStateData([pageRef, context, filter](WebBackForwardListItem& item) {
-        if (!filter(pageRef, WKPageGetSessionBackForwardListItemValueType(), toAPI(&item), context))
-            return false;
+        if (filter) {
+            if (!filter(pageRef, WKPageGetSessionBackForwardListItemValueType(), toAPI(&item), context))
+                return false;
 
-        if (!filter(pageRef, WKPageGetSessionHistoryURLValueType(), toURLRef(item.originalURL().impl()), context))
-            return false;
+            if (!filter(pageRef, WKPageGetSessionHistoryURLValueType(), toURLRef(item.originalURL().impl()), context))
+                return false;
+        }
 
         return true;
     }).leakRef());

Modified: trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp (170656 => 170657)


--- trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-07-01 19:15:39 UTC (rev 170656)
+++ trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-07-01 19:34:57 UTC (rev 170657)
@@ -28,6 +28,7 @@
 
 #include "APIData.h"
 #include "SessionState.h"
+#include <mutex>
 #include <wtf/MallocPtr.h>
 #include <wtf/cf/TypeCasts.h>
 #include <wtf/text/StringView.h>
@@ -377,8 +378,30 @@
 
 static RetainPtr<CFDataRef> encodeSessionHistoryEntryData(const FrameState& frameState)
 {
+    static CFAllocatorRef fastMallocDeallocator;
 
-    return nullptr;
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        CFAllocatorContext context = {
+            0, // version
+            nullptr, // info
+            nullptr, // retain
+            nullptr, // release
+            nullptr, // copyDescription
+            nullptr, // allocate
+            nullptr, // reallocate
+            [](void *ptr, void *info) {
+                WTF::fastFree(ptr);
+            },
+            nullptr, // preferredSize
+        };
+        fastMallocDeallocator = CFAllocatorCreate(kCFAllocatorDefault, &context);
+    });
+
+    size_t bufferSize;
+    auto buffer = encodeSessionHistoryEntryData(frameState, bufferSize);
+
+    return adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer.get(), bufferSize, fastMallocDeallocator));
 }
 
 static RetainPtr<CFDictionaryRef> createDictionary(std::initializer_list<std::pair<CFStringRef, CFTypeRef>> keyValuePairs)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to