Changeset 150660 in webkit


Ignore:
Timestamp:
May 24, 2013 3:05:57 PM (11 years ago)
Author:
andersca@apple.com
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):

Location:
trunk/Source/WebKit/win
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/win/ChangeLog

    r150499 r150660  
     12013-05-24  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove unused code to read/write history
     4        https://bugs.webkit.org/show_bug.cgi?id=116738
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * Interfaces/IWebHistory.idl:
     9        Replace loadFromURL and saveToURL with unused1/unused2.
     10
     11        * Interfaces/IWebHistoryPrivate.idl:
     12        Replace data with unused1.
     13
     14        * WebHistory.cpp:
     15        Remove history loading/saving code.
     16
     17        (WebHistory::unused1):
     18        (WebHistory::unused2):
     19        Add implementations.
     20
     21        * WebHistory.h:
     22        (WebHistory):
     23
    1242013-05-21  Mark Salisbury  <mark.salisbury@hp.com>
    225
  • trunk/Source/WebKit/win/Interfaces/IWebHistory.idl

    r30180 r150660  
    8181    HRESULT setOptionalSharedHistory([in] IWebHistory* history);
    8282
    83     /*!
    84         @method loadFromURL:error:
    85         @param URL The URL to use to initialize the WebHistory.
    86         @param error Set to nil or an NSError instance if an error occurred.
    87         @abstract The designated initializer for WebHistory.
    88         @result Returns YES if successful, NO otherwise.
    89         - (BOOL)loadFromURL:(NSURL *)URL error:(NSError **)error;
    90     */
    91     HRESULT loadFromURL([in] BSTR url, [out] IWebError** error, [out, retval] BOOL* succeeded);
    92 
    93     /*!
    94         @method saveToURL:error:
    95         @discussion Save history to URL. It is the client's responsibility to call this at appropriate times.
    96         @param URL The URL to use to save the WebHistory.
    97         @param error Set to nil or an NSError instance if an error occurred.
    98         @result Returns YES if successful, NO otherwise.
    99         - (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error;
    100     */
    101     HRESULT saveToURL([in] BSTR url, [out] IWebError** error, [out, retval] BOOL* succeeded);
     83    HRESULT unused1();
     84    HRESULT unused2();
    10285
    10386    /*!
  • trunk/Source/WebKit/win/Interfaces/IWebHistoryPrivate.idl

    r49564 r150660  
    3636{
    3737    HRESULT allItems([in, out] int* count, [out, retval] IWebHistoryItem** items);
    38     HRESULT data([out, retval] IStream**);
     38    HRESULT unused1();
    3939    HRESULT setVisitedLinkTrackingEnabled([in] BOOL visitedLinkTrackingEnable);
    4040    HRESULT removeAllVisitedLinks();
  • trunk/Source/WebKit/win/WebHistory.cpp

    r149716 r150660  
    3939#include <WebCore/BString.h>
    4040#include <WebCore/HistoryItem.h>
    41 #include <WebCore/HistoryPropertyList.h>
    4241#include <WebCore/KURL.h>
    4342#include <WebCore/PageGroup.h>
     
    4948using namespace WebCore;
    5049using namespace std;
    51 
    52 CFStringRef DatesArrayKey = CFSTR("WebHistoryDates");
    53 CFStringRef FileVersionKey = CFSTR("WebHistoryFileVersion");
    54 
    55 #define currentFileVersion 1
    56 
    57 class WebHistoryWriter : public HistoryPropertyListWriter {
    58 public:
    59     WebHistoryWriter(const WebHistory::DateToEntriesMap&);
    60 
    61 private:
    62     virtual void writeHistoryItems(BinaryPropertyListObjectStream&);
    63 
    64     const WebHistory::DateToEntriesMap& m_entriesByDate;
    65     Vector<WebHistory::DateKey> m_dateKeys;
    66 };
    67 
    68 WebHistoryWriter::WebHistoryWriter(const WebHistory::DateToEntriesMap& entriesByDate)
    69     : m_entriesByDate(entriesByDate)
    70 {
    71     copyKeysToVector(m_entriesByDate, m_dateKeys);
    72     sort(m_dateKeys.begin(), m_dateKeys.end());
    73 }
    74 
    75 void WebHistoryWriter::writeHistoryItems(BinaryPropertyListObjectStream& stream)
    76 {
    77     for (int dateIndex = m_dateKeys.size() - 1; dateIndex >= 0; --dateIndex) {
    78         // get the entries for that date
    79         CFArrayRef entries = m_entriesByDate.get(m_dateKeys[dateIndex]).get();
    80         CFIndex entriesCount = CFArrayGetCount(entries);
    81         for (CFIndex j = entriesCount - 1; j >= 0; --j) {
    82             IWebHistoryItem* item = (IWebHistoryItem*) CFArrayGetValueAtIndex(entries, j);
    83             COMPtr<WebHistoryItem> webItem(Query, item);
    84             if (!webItem)
    85                 continue;
    86 
    87             writeHistoryItem(stream, webItem->historyItem());
    88         }
    89     }
    90 }
    9150
    9251static bool areEqualOrClose(double d1, double d2)
     
    235194}
    236195
    237 HRESULT STDMETHODCALLTYPE WebHistory::loadFromURL(
    238     /* [in] */ BSTR url,
    239     /* [out] */ IWebError** error,
    240     /* [retval][out] */ BOOL* succeeded)
    241 {
    242     HRESULT hr = S_OK;
    243     RetainPtr<CFMutableArrayRef> discardedItems = adoptCF(
    244         CFArrayCreateMutable(0, 0, &MarshallingHelpers::kIUnknownArrayCallBacks));
    245 
    246     RetainPtr<CFURLRef> urlRef = adoptCF(MarshallingHelpers::BSTRToCFURLRef(url));
    247 
    248     hr = loadHistoryGutsFromURL(urlRef.get(), discardedItems.get(), error);
    249     if (FAILED(hr))
    250         goto exit;
    251 
    252     hr = postNotification(kWebHistoryLoadedNotification);
    253     if (FAILED(hr))
    254         goto exit;
    255 
    256     if (CFArrayGetCount(discardedItems.get()) > 0) {
    257         COMPtr<CFDictionaryPropertyBag> userInfo = createUserInfoFromArray(getNotificationString(kWebHistoryItemsDiscardedWhileLoadingNotification), discardedItems.get());
    258         hr = postNotification(kWebHistoryItemsDiscardedWhileLoadingNotification, userInfo.get());
    259         if (FAILED(hr))
    260             goto exit;
    261     }
    262 
    263 exit:
    264     if (succeeded)
    265         *succeeded = SUCCEEDED(hr);
    266     return hr;
    267 }
    268 
    269 static CFDictionaryRef createHistoryListFromStream(CFReadStreamRef stream, CFPropertyListFormat format)
    270 {
    271     return (CFDictionaryRef)CFPropertyListCreateFromStream(0, stream, 0, kCFPropertyListImmutable, &format, 0);
    272 }
    273 
    274 HRESULT WebHistory::loadHistoryGutsFromURL(CFURLRef url, CFMutableArrayRef discardedItems, IWebError** /*error*/) //FIXME
    275 {
    276     CFPropertyListFormat format = kCFPropertyListBinaryFormat_v1_0 | kCFPropertyListXMLFormat_v1_0;
    277     HRESULT hr = S_OK;
    278     int numberOfItemsLoaded = 0;
    279 
    280     RetainPtr<CFReadStreamRef> stream = adoptCF(CFReadStreamCreateWithFile(0, url));
    281     if (!stream)
    282         return E_FAIL;
    283 
    284     if (!CFReadStreamOpen(stream.get()))
    285         return E_FAIL;
    286 
    287     RetainPtr<CFDictionaryRef> historyList = adoptCF(createHistoryListFromStream(stream.get(), format));
    288     CFReadStreamClose(stream.get());
    289 
    290     if (!historyList)
    291         return E_FAIL;
    292 
    293     CFNumberRef fileVersionObject = (CFNumberRef)CFDictionaryGetValue(historyList.get(), FileVersionKey);
    294     int fileVersion;
    295     if (!CFNumberGetValue(fileVersionObject, kCFNumberIntType, &fileVersion))
    296         return E_FAIL;
    297 
    298     if (fileVersion > currentFileVersion)
    299         return E_FAIL;
    300    
    301     CFArrayRef datesArray = (CFArrayRef)CFDictionaryGetValue(historyList.get(), DatesArrayKey);
    302 
    303     int itemCountLimit;
    304     hr = historyItemLimit(&itemCountLimit);
    305     if (FAILED(hr))
    306         return hr;
    307 
    308     CFAbsoluteTime limitDate;
    309     hr = ageLimitDate(&limitDate);
    310     if (FAILED(hr))
    311         return hr;
    312 
    313     bool ageLimitPassed = false;
    314     bool itemLimitPassed = false;
    315 
    316     CFIndex itemCount = CFArrayGetCount(datesArray);
    317     for (CFIndex i = 0; i < itemCount; ++i) {
    318         CFDictionaryRef itemAsDictionary = (CFDictionaryRef)CFArrayGetValueAtIndex(datesArray, i);
    319         COMPtr<WebHistoryItem> item(AdoptCOM, WebHistoryItem::createInstance());
    320         hr = item->initFromDictionaryRepresentation((void*)itemAsDictionary);
    321         if (FAILED(hr))
    322             return hr;
    323 
    324         // item without URL is useless; data on disk must have been bad; ignore
    325         BOOL hasURL;
    326         hr = item->hasURLString(&hasURL);
    327         if (FAILED(hr))
    328             return hr;
    329        
    330         if (hasURL) {
    331             // Test against date limit. Since the items are ordered newest to oldest, we can stop comparing
    332             // once we've found the first item that's too old.
    333             if (!ageLimitPassed) {
    334                 DATE lastVisitedTime;
    335                 hr = item->lastVisitedTimeInterval(&lastVisitedTime);
    336                 if (FAILED(hr))
    337                     return hr;
    338                 if (timeToDate(MarshallingHelpers::DATEToCFAbsoluteTime(lastVisitedTime)) <= limitDate)
    339                     ageLimitPassed = true;
    340             }
    341             if (ageLimitPassed || itemLimitPassed)
    342                 CFArrayAppendValue(discardedItems, item.get());
    343             else {
    344                 bool added;
    345                 addItem(item.get(), true, &added); // ref is added inside addItem
    346                 if (added)
    347                     ++numberOfItemsLoaded;
    348                 if (numberOfItemsLoaded == itemCountLimit)
    349                     itemLimitPassed = true;
    350             }
    351         }
    352     }
    353     return hr;
    354 }
    355 
    356 HRESULT STDMETHODCALLTYPE WebHistory::saveToURL(
    357     /* [in] */ BSTR url,
    358     /* [out] */ IWebError** error,
    359     /* [retval][out] */ BOOL* succeeded)
    360 {
    361     HRESULT hr = S_OK;
    362     RetainPtr<CFURLRef> urlRef = adoptCF(MarshallingHelpers::BSTRToCFURLRef(url));
    363 
    364     hr = saveHistoryGuts(urlRef.get(), error);
    365 
    366     if (succeeded)
    367         *succeeded = SUCCEEDED(hr);
    368     if (SUCCEEDED(hr))
    369         hr = postNotification(kWebHistorySavedNotification);
    370 
    371     return hr;
    372 }
    373 
    374 HRESULT WebHistory::saveHistoryGuts(CFURLRef url, IWebError** error)
    375 {
    376     HRESULT hr = S_OK;
    377 
    378     // FIXME: Correctly report error when new API is ready.
    379     if (error)
    380         *error = 0;
    381 
    382     RetainPtr<CFDataRef> data = this->data();
    383 
    384     if (!data.get())
    385         return E_FAIL;
    386 
    387     RetainPtr<CFWriteStreamRef> stream = adoptCF(CFWriteStreamCreateWithFile(kCFAllocatorDefault, url));
    388     if (!stream)
    389         return E_FAIL;
    390 
    391     if (!CFWriteStreamOpen(stream.get()))
    392         return E_FAIL;
    393 
    394     const UInt8* dataPtr = CFDataGetBytePtr(data.get());
    395     CFIndex length = CFDataGetLength(data.get());
    396 
    397     while (length) {
    398         CFIndex bytesWritten = CFWriteStreamWrite(stream.get(), dataPtr, length);
    399         if (bytesWritten <= 0) {
    400             hr = E_FAIL;
    401             break;
    402         }
    403         dataPtr += bytesWritten;
    404         length -= bytesWritten;
    405     }
    406 
    407     CFWriteStreamClose(stream.get());
    408 
    409     return hr;
     196HRESULT STDMETHODCALLTYPE WebHistory::unused1()
     197{
     198    ASSERT_NOT_REACHED();
     199    return E_FAIL;
     200}
     201
     202HRESULT STDMETHODCALLTYPE WebHistory::unused2()
     203{
     204    ASSERT_NOT_REACHED();
     205    return E_FAIL;
    410206}
    411207
     
    553349
    554350    return S_OK;
    555 }
    556 
    557 HRESULT WebHistory::data(IStream** stream)
    558 {
    559     if (!stream)
    560         return E_POINTER;
    561 
    562     *stream = 0;
    563 
    564     RetainPtr<CFDataRef> historyData = data();
    565     if (!historyData)
    566         return S_OK;
    567 
    568     COMPtr<MemoryStream> result = MemoryStream::createInstance(SharedBuffer::wrapCFData(historyData.get()));
    569     return result.copyRefTo(stream);
    570351}
    571352
     
    1004785    CFDictionaryApplyFunction(m_entriesByURL.get(), addVisitedLinkToPageGroup, &group);
    1005786}
    1006 
    1007 RetainPtr<CFDataRef> WebHistory::data() const
    1008 {
    1009     if (m_entriesByDate.isEmpty())
    1010         return 0;
    1011 
    1012     WebHistoryWriter writer(m_entriesByDate);
    1013     writer.writePropertyList();
    1014     return writer.releaseData();
    1015 }
  • trunk/Source/WebKit/win/WebHistory.h

    r82326 r150660  
    6363        /* [in] */ IWebHistory* history);
    6464   
    65     virtual HRESULT STDMETHODCALLTYPE loadFromURL(
    66         /* [in] */ BSTR url,
    67         /* [out] */ IWebError** error,
    68         /* [retval][out] */ BOOL* succeeded);
    69    
    70     virtual HRESULT STDMETHODCALLTYPE saveToURL(
    71         /* [in] */ BSTR url,
    72         /* [out] */ IWebError** error,
    73         /* [retval][out] */ BOOL* succeeded);
     65    virtual HRESULT STDMETHODCALLTYPE unused1() OVERRIDE;
     66    virtual HRESULT STDMETHODCALLTYPE unused2() OVERRIDE;
    7467   
    7568    virtual HRESULT STDMETHODCALLTYPE addItems(
     
    114107        /* [retval][out] */ IWebHistoryItem** items);
    115108
    116     virtual HRESULT STDMETHODCALLTYPE data(IStream**);
    117 
    118109    virtual HRESULT STDMETHODCALLTYPE setVisitedLinkTrackingEnabled(BOOL visitedLinkTrackingEnable);
    119110    virtual HRESULT STDMETHODCALLTYPE removeAllVisitedLinks();
     
    141132    };
    142133
    143     HRESULT loadHistoryGutsFromURL(CFURLRef url, CFMutableArrayRef discardedItems, IWebError** error);
    144     HRESULT saveHistoryGuts(CFURLRef url, IWebError** error);
    145134    HRESULT postNotification(NotificationType notifyType, IPropertyBag* userInfo = 0);
    146135    HRESULT removeItem(IWebHistoryItem* entry);
     
    155144    BSTR getNotificationString(NotificationType notifyType);
    156145    HRESULT itemForURLString(CFStringRef urlString, IWebHistoryItem** item) const;
    157     RetainPtr<CFDataRef> data() const;
    158146
    159147    ULONG m_refCount;
Note: See TracChangeset for help on using the changeset viewer.