Changeset 150660 in webkit
- Timestamp:
- May 24, 2013 3:05:57 PM (11 years ago)
- Location:
- trunk/Source/WebKit/win
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/win/ChangeLog
r150499 r150660 1 2013-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 1 24 2013-05-21 Mark Salisbury <mark.salisbury@hp.com> 2 25 -
trunk/Source/WebKit/win/Interfaces/IWebHistory.idl
r30180 r150660 81 81 HRESULT setOptionalSharedHistory([in] IWebHistory* history); 82 82 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(); 102 85 103 86 /*! -
trunk/Source/WebKit/win/Interfaces/IWebHistoryPrivate.idl
r49564 r150660 36 36 { 37 37 HRESULT allItems([in, out] int* count, [out, retval] IWebHistoryItem** items); 38 HRESULT data([out, retval] IStream**);38 HRESULT unused1(); 39 39 HRESULT setVisitedLinkTrackingEnabled([in] BOOL visitedLinkTrackingEnable); 40 40 HRESULT removeAllVisitedLinks(); -
trunk/Source/WebKit/win/WebHistory.cpp
r149716 r150660 39 39 #include <WebCore/BString.h> 40 40 #include <WebCore/HistoryItem.h> 41 #include <WebCore/HistoryPropertyList.h>42 41 #include <WebCore/KURL.h> 43 42 #include <WebCore/PageGroup.h> … … 49 48 using namespace WebCore; 50 49 using namespace std; 51 52 CFStringRef DatesArrayKey = CFSTR("WebHistoryDates");53 CFStringRef FileVersionKey = CFSTR("WebHistoryFileVersion");54 55 #define currentFileVersion 156 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 date79 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 }91 50 92 51 static bool areEqualOrClose(double d1, double d2) … … 235 194 } 236 195 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; 196 HRESULT STDMETHODCALLTYPE WebHistory::unused1() 197 { 198 ASSERT_NOT_REACHED(); 199 return E_FAIL; 200 } 201 202 HRESULT STDMETHODCALLTYPE WebHistory::unused2() 203 { 204 ASSERT_NOT_REACHED(); 205 return E_FAIL; 410 206 } 411 207 … … 553 349 554 350 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);570 351 } 571 352 … … 1004 785 CFDictionaryApplyFunction(m_entriesByURL.get(), addVisitedLinkToPageGroup, &group); 1005 786 } 1006 1007 RetainPtr<CFDataRef> WebHistory::data() const1008 {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 63 63 /* [in] */ IWebHistory* history); 64 64 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; 74 67 75 68 virtual HRESULT STDMETHODCALLTYPE addItems( … … 114 107 /* [retval][out] */ IWebHistoryItem** items); 115 108 116 virtual HRESULT STDMETHODCALLTYPE data(IStream**);117 118 109 virtual HRESULT STDMETHODCALLTYPE setVisitedLinkTrackingEnabled(BOOL visitedLinkTrackingEnable); 119 110 virtual HRESULT STDMETHODCALLTYPE removeAllVisitedLinks(); … … 141 132 }; 142 133 143 HRESULT loadHistoryGutsFromURL(CFURLRef url, CFMutableArrayRef discardedItems, IWebError** error);144 HRESULT saveHistoryGuts(CFURLRef url, IWebError** error);145 134 HRESULT postNotification(NotificationType notifyType, IPropertyBag* userInfo = 0); 146 135 HRESULT removeItem(IWebHistoryItem* entry); … … 155 144 BSTR getNotificationString(NotificationType notifyType); 156 145 HRESULT itemForURLString(CFStringRef urlString, IWebHistoryItem** item) const; 157 RetainPtr<CFDataRef> data() const;158 146 159 147 ULONG m_refCount;
Note: See TracChangeset
for help on using the changeset viewer.