Title: [150660] trunk/Source/WebKit/win
Revision
150660
Author
ander...@apple.com
Date
2013-05-24 15:05:57 -0700 (Fri, 24 May 2013)

Log Message

Remove unused code to read/write history
https://bugs.webkit.org/show_bug.cgi?id=116738

Reviewed by Brent Fulgham.

* Interfaces/IWebHistory.idl:
Replace loadFromURL and saveToURL with unused1/unused2.

* Interfaces/IWebHistoryPrivate.idl:
Replace data with unused1.

* WebHistory.cpp:
Remove history loading/saving code.

(WebHistory::unused1):
(WebHistory::unused2):
Add implementations.

* WebHistory.h:
(WebHistory):

Modified Paths

Diff

Modified: trunk/Source/WebKit/win/ChangeLog (150659 => 150660)


--- trunk/Source/WebKit/win/ChangeLog	2013-05-24 22:00:21 UTC (rev 150659)
+++ trunk/Source/WebKit/win/ChangeLog	2013-05-24 22:05:57 UTC (rev 150660)
@@ -1,3 +1,26 @@
+2013-05-24  Anders Carlsson  <ander...@apple.com>
+
+        Remove unused code to read/write history
+        https://bugs.webkit.org/show_bug.cgi?id=116738
+
+        Reviewed by Brent Fulgham.
+
+        * Interfaces/IWebHistory.idl:
+        Replace loadFromURL and saveToURL with unused1/unused2.
+
+        * Interfaces/IWebHistoryPrivate.idl:
+        Replace data with unused1.
+
+        * WebHistory.cpp:
+        Remove history loading/saving code.
+
+        (WebHistory::unused1):
+        (WebHistory::unused2):
+        Add implementations.
+
+        * WebHistory.h:
+        (WebHistory):
+
 2013-05-21  Mark Salisbury  <mark.salisb...@hp.com>
 
         [Windows, curl] WebDownloadCurl.cpp should not include SystemTime.h

Modified: trunk/Source/WebKit/win/Interfaces/IWebHistory.idl (150659 => 150660)


--- trunk/Source/WebKit/win/Interfaces/IWebHistory.idl	2013-05-24 22:00:21 UTC (rev 150659)
+++ trunk/Source/WebKit/win/Interfaces/IWebHistory.idl	2013-05-24 22:05:57 UTC (rev 150660)
@@ -80,27 +80,10 @@
     */
     HRESULT setOptionalSharedHistory([in] IWebHistory* history);
 
-    /*!
-        @method loadFromURL:error:
-        @param URL The URL to use to initialize the WebHistory.
-        @param error Set to nil or an NSError instance if an error occurred.
-        @abstract The designated initializer for WebHistory.
-        @result Returns YES if successful, NO otherwise.
-        - (BOOL)loadFromURL:(NSURL *)URL error:(NSError **)error;
-    */
-    HRESULT loadFromURL([in] BSTR url, [out] IWebError** error, [out, retval] BOOL* succeeded);
+    HRESULT unused1();
+    HRESULT unused2();
 
     /*!
-        @method saveToURL:error:
-        @discussion Save history to URL. It is the client's responsibility to call this at appropriate times.
-        @param URL The URL to use to save the WebHistory.
-        @param error Set to nil or an NSError instance if an error occurred.
-        @result Returns YES if successful, NO otherwise.
-        - (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error;
-    */
-    HRESULT saveToURL([in] BSTR url, [out] IWebError** error, [out, retval] BOOL* succeeded);
-
-    /*!
         @method addItems:
         @param newItems An array of WebHistoryItems to add to the WebHistory.
         - (void)addItems:(NSArray *)newItems;

Modified: trunk/Source/WebKit/win/Interfaces/IWebHistoryPrivate.idl (150659 => 150660)


--- trunk/Source/WebKit/win/Interfaces/IWebHistoryPrivate.idl	2013-05-24 22:00:21 UTC (rev 150659)
+++ trunk/Source/WebKit/win/Interfaces/IWebHistoryPrivate.idl	2013-05-24 22:05:57 UTC (rev 150660)
@@ -35,7 +35,7 @@
 interface IWebHistoryPrivate : IUnknown
 {
     HRESULT allItems([in, out] int* count, [out, retval] IWebHistoryItem** items);
-    HRESULT data([out, retval] IStream**);
+    HRESULT unused1();
     HRESULT setVisitedLinkTrackingEnabled([in] BOOL visitedLinkTrackingEnable);
     HRESULT removeAllVisitedLinks();
 }

Modified: trunk/Source/WebKit/win/WebHistory.cpp (150659 => 150660)


--- trunk/Source/WebKit/win/WebHistory.cpp	2013-05-24 22:00:21 UTC (rev 150659)
+++ trunk/Source/WebKit/win/WebHistory.cpp	2013-05-24 22:05:57 UTC (rev 150660)
@@ -38,7 +38,6 @@
 #include <CoreFoundation/CoreFoundation.h>
 #include <WebCore/BString.h>
 #include <WebCore/HistoryItem.h>
-#include <WebCore/HistoryPropertyList.h>
 #include <WebCore/KURL.h>
 #include <WebCore/PageGroup.h>
 #include <WebCore/SharedBuffer.h>
@@ -49,46 +48,6 @@
 using namespace WebCore;
 using namespace std;
 
-CFStringRef DatesArrayKey = CFSTR("WebHistoryDates");
-CFStringRef FileVersionKey = CFSTR("WebHistoryFileVersion");
-
-#define currentFileVersion 1
-
-class WebHistoryWriter : public HistoryPropertyListWriter {
-public:
-    WebHistoryWriter(const WebHistory::DateToEntriesMap&);
-
-private:
-    virtual void writeHistoryItems(BinaryPropertyListObjectStream&);
-
-    const WebHistory::DateToEntriesMap& m_entriesByDate;
-    Vector<WebHistory::DateKey> m_dateKeys;
-};
-
-WebHistoryWriter::WebHistoryWriter(const WebHistory::DateToEntriesMap& entriesByDate)
-    : m_entriesByDate(entriesByDate)
-{
-    copyKeysToVector(m_entriesByDate, m_dateKeys);
-    sort(m_dateKeys.begin(), m_dateKeys.end());
-}
-
-void WebHistoryWriter::writeHistoryItems(BinaryPropertyListObjectStream& stream)
-{
-    for (int dateIndex = m_dateKeys.size() - 1; dateIndex >= 0; --dateIndex) {
-        // get the entries for that date
-        CFArrayRef entries = m_entriesByDate.get(m_dateKeys[dateIndex]).get();
-        CFIndex entriesCount = CFArrayGetCount(entries);
-        for (CFIndex j = entriesCount - 1; j >= 0; --j) {
-            IWebHistoryItem* item = (IWebHistoryItem*) CFArrayGetValueAtIndex(entries, j);
-            COMPtr<WebHistoryItem> webItem(Query, item);
-            if (!webItem)
-                continue;
-
-            writeHistoryItem(stream, webItem->historyItem());
-        }
-    }
-}
-
 static bool areEqualOrClose(double d1, double d2)
 {
     double diff = d1-d2;
@@ -234,181 +193,18 @@
     return S_OK;
 }
 
-HRESULT STDMETHODCALLTYPE WebHistory::loadFromURL( 
-    /* [in] */ BSTR url,
-    /* [out] */ IWebError** error,
-    /* [retval][out] */ BOOL* succeeded)
+HRESULT STDMETHODCALLTYPE WebHistory::unused1()
 {
-    HRESULT hr = S_OK;
-    RetainPtr<CFMutableArrayRef> discardedItems = adoptCF(
-        CFArrayCreateMutable(0, 0, &MarshallingHelpers::kIUnknownArrayCallBacks));
-
-    RetainPtr<CFURLRef> urlRef = adoptCF(MarshallingHelpers::BSTRToCFURLRef(url));
-
-    hr = loadHistoryGutsFromURL(urlRef.get(), discardedItems.get(), error);
-    if (FAILED(hr))
-        goto exit;
-
-    hr = postNotification(kWebHistoryLoadedNotification);
-    if (FAILED(hr))
-        goto exit;
-
-    if (CFArrayGetCount(discardedItems.get()) > 0) {
-        COMPtr<CFDictionaryPropertyBag> userInfo = createUserInfoFromArray(getNotificationString(kWebHistoryItemsDiscardedWhileLoadingNotification), discardedItems.get());
-        hr = postNotification(kWebHistoryItemsDiscardedWhileLoadingNotification, userInfo.get());
-        if (FAILED(hr))
-            goto exit;
-    }
-
-exit:
-    if (succeeded)
-        *succeeded = SUCCEEDED(hr);
-    return hr;
+    ASSERT_NOT_REACHED();
+    return E_FAIL;
 }
 
-static CFDictionaryRef createHistoryListFromStream(CFReadStreamRef stream, CFPropertyListFormat format)
+HRESULT STDMETHODCALLTYPE WebHistory::unused2()
 {
-    return (CFDictionaryRef)CFPropertyListCreateFromStream(0, stream, 0, kCFPropertyListImmutable, &format, 0);
+    ASSERT_NOT_REACHED();
+    return E_FAIL;
 }
 
-HRESULT WebHistory::loadHistoryGutsFromURL(CFURLRef url, CFMutableArrayRef discardedItems, IWebError** /*error*/) //FIXME
-{
-    CFPropertyListFormat format = kCFPropertyListBinaryFormat_v1_0 | kCFPropertyListXMLFormat_v1_0;
-    HRESULT hr = S_OK;
-    int numberOfItemsLoaded = 0;
-
-    RetainPtr<CFReadStreamRef> stream = adoptCF(CFReadStreamCreateWithFile(0, url));
-    if (!stream) 
-        return E_FAIL;
-
-    if (!CFReadStreamOpen(stream.get())) 
-        return E_FAIL;
-
-    RetainPtr<CFDictionaryRef> historyList = adoptCF(createHistoryListFromStream(stream.get(), format));
-    CFReadStreamClose(stream.get());
-
-    if (!historyList) 
-        return E_FAIL;
-
-    CFNumberRef fileVersionObject = (CFNumberRef)CFDictionaryGetValue(historyList.get(), FileVersionKey);
-    int fileVersion;
-    if (!CFNumberGetValue(fileVersionObject, kCFNumberIntType, &fileVersion)) 
-        return E_FAIL;
-
-    if (fileVersion > currentFileVersion) 
-        return E_FAIL;
-    
-    CFArrayRef datesArray = (CFArrayRef)CFDictionaryGetValue(historyList.get(), DatesArrayKey);
-
-    int itemCountLimit;
-    hr = historyItemLimit(&itemCountLimit);
-    if (FAILED(hr))
-        return hr;
-
-    CFAbsoluteTime limitDate;
-    hr = ageLimitDate(&limitDate);
-    if (FAILED(hr))
-        return hr;
-
-    bool ageLimitPassed = false;
-    bool itemLimitPassed = false;
-
-    CFIndex itemCount = CFArrayGetCount(datesArray);
-    for (CFIndex i = 0; i < itemCount; ++i) {
-        CFDictionaryRef itemAsDictionary = (CFDictionaryRef)CFArrayGetValueAtIndex(datesArray, i);
-        COMPtr<WebHistoryItem> item(AdoptCOM, WebHistoryItem::createInstance());
-        hr = item->initFromDictionaryRepresentation((void*)itemAsDictionary);
-        if (FAILED(hr))
-            return hr;
-
-        // item without URL is useless; data on disk must have been bad; ignore
-        BOOL hasURL;
-        hr = item->hasURLString(&hasURL);
-        if (FAILED(hr))
-            return hr;
-        
-        if (hasURL) {
-            // Test against date limit. Since the items are ordered newest to oldest, we can stop comparing
-            // once we've found the first item that's too old.
-            if (!ageLimitPassed) {
-                DATE lastVisitedTime;
-                hr = item->lastVisitedTimeInterval(&lastVisitedTime);
-                if (FAILED(hr))
-                    return hr;
-                if (timeToDate(MarshallingHelpers::DATEToCFAbsoluteTime(lastVisitedTime)) <= limitDate)
-                    ageLimitPassed = true;
-            }
-            if (ageLimitPassed || itemLimitPassed)
-                CFArrayAppendValue(discardedItems, item.get());
-            else {
-                bool added;
-                addItem(item.get(), true, &added); // ref is added inside addItem
-                if (added)
-                    ++numberOfItemsLoaded;
-                if (numberOfItemsLoaded == itemCountLimit)
-                    itemLimitPassed = true;
-            }
-        }
-    }
-    return hr;
-}
-
-HRESULT STDMETHODCALLTYPE WebHistory::saveToURL( 
-    /* [in] */ BSTR url,
-    /* [out] */ IWebError** error,
-    /* [retval][out] */ BOOL* succeeded)
-{
-    HRESULT hr = S_OK;
-    RetainPtr<CFURLRef> urlRef = adoptCF(MarshallingHelpers::BSTRToCFURLRef(url));
-
-    hr = saveHistoryGuts(urlRef.get(), error);
-
-    if (succeeded)
-        *succeeded = SUCCEEDED(hr);
-    if (SUCCEEDED(hr))
-        hr = postNotification(kWebHistorySavedNotification);
-
-    return hr;
-}
-
-HRESULT WebHistory::saveHistoryGuts(CFURLRef url, IWebError** error)
-{
-    HRESULT hr = S_OK;
-
-    // FIXME: Correctly report error when new API is ready.
-    if (error)
-        *error = 0;
-
-    RetainPtr<CFDataRef> data = ""
-
-    if (!data.get())
-        return E_FAIL;
-
-    RetainPtr<CFWriteStreamRef> stream = adoptCF(CFWriteStreamCreateWithFile(kCFAllocatorDefault, url));
-    if (!stream) 
-        return E_FAIL;
-
-    if (!CFWriteStreamOpen(stream.get())) 
-        return E_FAIL;
-
-    const UInt8* dataPtr = CFDataGetBytePtr(data.get());
-    CFIndex length = CFDataGetLength(data.get());
-
-    while (length) {
-        CFIndex bytesWritten = CFWriteStreamWrite(stream.get(), dataPtr, length);
-        if (bytesWritten <= 0) {
-            hr = E_FAIL;
-            break;
-        }
-        dataPtr += bytesWritten;
-        length -= bytesWritten;
-    }
-
-    CFWriteStreamClose(stream.get());
-
-    return hr;
-}
-
 HRESULT STDMETHODCALLTYPE WebHistory::addItems( 
     /* [in] */ int itemCount,
     /* [in] */ IWebHistoryItem** items)
@@ -554,21 +350,6 @@
     return S_OK;
 }
 
-HRESULT WebHistory::data(IStream** stream)
-{
-    if (!stream)
-        return E_POINTER;
-
-    *stream = 0;
-
-    RetainPtr<CFDataRef> historyData = data();
-    if (!historyData)
-        return S_OK;
-
-    COMPtr<MemoryStream> result = MemoryStream::createInstance(SharedBuffer::wrapCFData(historyData.get()));
-    return result.copyRefTo(stream);
-}
-
 HRESULT WebHistory::setVisitedLinkTrackingEnabled(BOOL visitedLinkTrackingEnabled)
 {
     PageGroup::setShouldTrackVisitedLinks(visitedLinkTrackingEnabled);
@@ -1003,13 +784,3 @@
 {
     CFDictionaryApplyFunction(m_entriesByURL.get(), addVisitedLinkToPageGroup, &group);
 }
-
-RetainPtr<CFDataRef> WebHistory::data() const
-{
-    if (m_entriesByDate.isEmpty())
-        return 0;
-
-    WebHistoryWriter writer(m_entriesByDate);
-    writer.writePropertyList();
-    return writer.releaseData();
-}

Modified: trunk/Source/WebKit/win/WebHistory.h (150659 => 150660)


--- trunk/Source/WebKit/win/WebHistory.h	2013-05-24 22:00:21 UTC (rev 150659)
+++ trunk/Source/WebKit/win/WebHistory.h	2013-05-24 22:05:57 UTC (rev 150660)
@@ -62,16 +62,9 @@
     virtual HRESULT STDMETHODCALLTYPE setOptionalSharedHistory( 
         /* [in] */ IWebHistory* history);
     
-    virtual HRESULT STDMETHODCALLTYPE loadFromURL( 
-        /* [in] */ BSTR url,
-        /* [out] */ IWebError** error,
-        /* [retval][out] */ BOOL* succeeded);
+    virtual HRESULT STDMETHODCALLTYPE unused1() OVERRIDE;
+    virtual HRESULT STDMETHODCALLTYPE unused2() OVERRIDE;
     
-    virtual HRESULT STDMETHODCALLTYPE saveToURL( 
-        /* [in] */ BSTR url,
-        /* [out] */ IWebError** error,
-        /* [retval][out] */ BOOL* succeeded);
-    
     virtual HRESULT STDMETHODCALLTYPE addItems( 
         /* [in] */ int itemCount,
         /* [in] */ IWebHistoryItem** items);
@@ -113,8 +106,6 @@
         /* [out][in] */ int* count,
         /* [retval][out] */ IWebHistoryItem** items);
 
-    virtual HRESULT STDMETHODCALLTYPE data(IStream**);
-
     virtual HRESULT STDMETHODCALLTYPE setVisitedLinkTrackingEnabled(BOOL visitedLinkTrackingEnable);
     virtual HRESULT STDMETHODCALLTYPE removeAllVisitedLinks();
 
@@ -140,8 +131,6 @@
         kWebHistorySavedNotification = 5
     };
 
-    HRESULT loadHistoryGutsFromURL(CFURLRef url, CFMutableArrayRef discardedItems, IWebError** error);
-    HRESULT saveHistoryGuts(CFURLRef url, IWebError** error);
     HRESULT postNotification(NotificationType notifyType, IPropertyBag* userInfo = 0);
     HRESULT removeItem(IWebHistoryItem* entry);
     HRESULT addItem(IWebHistoryItem* entry, bool discardDuplicate, bool* added);
@@ -154,7 +143,6 @@
     static CFAbsoluteTime timeToDate(CFAbsoluteTime time);
     BSTR getNotificationString(NotificationType notifyType);
     HRESULT itemForURLString(CFStringRef urlString, IWebHistoryItem** item) const;
-    RetainPtr<CFDataRef> data() const;
 
     ULONG m_refCount;
     RetainPtr<CFMutableDictionaryRef> m_entriesByURL;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to