Changeset 181837 in webkit
- Timestamp:
- Mar 22, 2015, 3:50:23 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webdatabase/DatabaseTracker.h (modified) (3 diffs)
-
Source/WebCore/Modules/webdatabase/OriginLock.h (modified) (1 diff)
-
Source/WebKit2/ChangeLog (modified) (1 diff)
-
Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecord.h (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecord.mm (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecordInternal.h (modified) (2 diffs)
-
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (modified) (7 diffs)
-
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/MiniBrowser/mac/WK2BrowserWindowController.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r181832 r181837 1 2015-03-22 Anders Carlsson <andersca@apple.com> 2 3 _WKWebsiteDataStore should clear WebSQL databases 4 https://bugs.webkit.org/show_bug.cgi?id=142947 5 6 Reviewed by Sam Weinig. 7 8 * Modules/webdatabase/DatabaseTracker.cpp: 9 (WebCore::DatabaseTracker::trackerWithDatabasePath): 10 Add a hack so we can get at a tracker from the UI process. 11 12 (WebCore::DatabaseTracker::deleteDatabasesModifiedSince): 13 New function that deletes all databases modified after a given time. 14 15 * Modules/webdatabase/DatabaseTracker.h: 16 Add new members and export the ones we want to call from WebKit2. 17 18 * Modules/webdatabase/OriginLock.h: 19 Export the destructor. 20 1 21 2015-03-21 Dean Jackson <dino@apple.com> 2 22 -
trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
r178575 r181837 57 57 namespace WebCore { 58 58 59 std::unique_ptr<DatabaseTracker> DatabaseTracker::trackerWithDatabasePath(const String& databasePath) 60 { 61 return std::unique_ptr<DatabaseTracker>(new DatabaseTracker(databasePath)); 62 } 63 59 64 static DatabaseTracker* staticTracker = 0; 60 65 … … 824 829 for (unsigned i = 0; i < originsCopy.size(); ++i) 825 830 deleteOrigin(originsCopy[i].get()); 831 } 832 833 void DatabaseTracker::deleteDatabasesModifiedSince(std::chrono::system_clock::time_point time) 834 { 835 Vector<RefPtr<SecurityOrigin>> originsCopy; 836 origins(originsCopy); 837 838 for (auto& origin : originsCopy) { 839 Vector<String> databaseNames; 840 if (!databaseNamesForOrigin(origin.get(), databaseNames)) 841 continue; 842 843 for (auto& databaseName : databaseNames) { 844 auto fullPath = fullPathForDatabase(origin.get(), databaseName, false); 845 846 time_t modificationTime; 847 if (!getFileModificationTime(fullPath, modificationTime)) 848 continue; 849 850 if (modificationTime < std::chrono::system_clock::to_time_t(time)) 851 continue; 852 853 deleteDatabase(origin.get(), databaseName); 854 } 855 } 826 856 } 827 857 -
trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h
r178575 r181837 50 50 WTF_MAKE_NONCOPYABLE(DatabaseTracker); WTF_MAKE_FAST_ALLOCATED; 51 51 public: 52 // FIXME: This is a hack so we can easily delete databases from the UI process in WebKit2. 53 WEBCORE_EXPORT static std::unique_ptr<DatabaseTracker> trackerWithDatabasePath(const String& databasePath); 54 52 55 static void initializeTracker(const String& databasePath); 53 56 … … 83 86 String databaseDirectoryPath() const; 84 87 85 void origins(Vector<RefPtr<SecurityOrigin>>& result);88 WEBCORE_EXPORT void origins(Vector<RefPtr<SecurityOrigin>>& result); 86 89 bool databaseNamesForOrigin(SecurityOrigin*, Vector<String>& result); 87 90 … … 94 97 95 98 void deleteAllDatabases(); 96 bool deleteOrigin(SecurityOrigin*); 99 WEBCORE_EXPORT void deleteDatabasesModifiedSince(std::chrono::system_clock::time_point); 100 WEBCORE_EXPORT bool deleteOrigin(SecurityOrigin*); 97 101 bool deleteDatabase(SecurityOrigin*, const String& name); 98 102 -
trunk/Source/WebCore/Modules/webdatabase/OriginLock.h
r178575 r181837 38 38 public: 39 39 OriginLock(String originPath); 40 ~OriginLock();40 WEBCORE_EXPORT ~OriginLock(); 41 41 42 42 void lock(); -
trunk/Source/WebKit2/ChangeLog
r181836 r181837 1 2015-03-22 Anders Carlsson <andersca@apple.com> 2 3 _WKWebsiteDataStore should clear WebSQL databases 4 https://bugs.webkit.org/show_bug.cgi?id=142947 5 rdar://problem/20242174 6 7 Reviewed by Sam Weinig. 8 9 * Shared/WebsiteData/WebsiteDataTypes.h: 10 Add WebsiteDataTypeWebSQLDatabases. 11 12 * UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm: 13 (API::WebsiteDataStore::defaultDataStoreConfiguration): 14 Initialize configuration.webSQLDatabaseDirectory. 15 16 * UIProcess/API/Cocoa/_WKWebsiteDataRecord.h: 17 Add WKWebsiteDataTypeWebSQLDatabases. 18 19 * UIProcess/API/Cocoa/_WKWebsiteDataRecord.mm: 20 (dataTypesToString): 21 Handle WKWebsiteDataTypeWebSQLDatabases. 22 23 * UIProcess/API/Cocoa/_WKWebsiteDataRecordInternal.h: 24 (WebKit::toWebsiteDataTypes): 25 (WebKit::toWKWebsiteDataTypes): 26 Handle WKWebsiteDataTypeWebSQLDatabases and WebsiteDataTypes::WebsiteDataTypeWebSQLDatabases. 27 28 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 29 (WebKit::WebsiteDataStore::WebsiteDataStore): 30 Initialize m_webSQLDatabaseDirectory and add a queue member variable. 31 32 (WebKit::WebsiteDataStore::fetchData): 33 Fetch database origins. 34 35 (WebKit::WebsiteDataStore::removeData): 36 Remove databases. 37 38 * UIProcess/WebsiteData/WebsiteDataStore.h: 39 Add new members. 40 1 41 2015-03-22 Dan Bernstein <mitz@apple.com> 2 42 -
trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h
r180265 r181837 34 34 WebsiteDataTypeMemoryCache = 1 << 2, 35 35 WebsiteDataTypeLocalStorage = 1 << 3, 36 WebsiteDataTypeWebSQLDatabases = 1 << 4, 36 37 }; 37 38 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm
r178685 r181837 66 66 67 67 configuration.localStorageDirectory = websiteDataDirectoryFileSystemRepresentation("LocalStorage"); 68 configuration.webSQLDatabaseDirectory = websiteDataDirectoryFileSystemRepresentation("WebSQL"); 68 69 69 70 return configuration; -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecord.h
r180585 r181837 36 36 37 37 WKWebsiteDataTypeLocalStorage = 1 << 3, 38 WKWebsiteDataTypeWebSQLDatabases = 1 << 4, 39 38 40 WKWebsiteDataTypeAll = NSUIntegerMax, 39 41 } WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA); -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecord.mm
r180585 r181837 50 50 if (dataTypes & WKWebsiteDataTypeLocalStorage) 51 51 [array addObject:@"Local Storage"]; 52 if (dataTypes & WKWebsiteDataTypeWebSQLDatabases) 53 [array addObject:@"Web SQL"]; 52 54 53 55 return [array componentsJoinedByString:@", "]; -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecordInternal.h
r180585 r181837 53 53 if (wkWebsiteDataTypes & WKWebsiteDataTypeLocalStorage) 54 54 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeLocalStorage; 55 if (wkWebsiteDataTypes & WKWebsiteDataTypeWebSQLDatabases) 56 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeWebSQLDatabases; 55 57 56 58 return static_cast<WebsiteDataTypes>(websiteDataTypes); … … 71 73 if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeLocalStorage) 72 74 wkWebsiteDataTypes |= WKWebsiteDataTypeLocalStorage; 75 if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeWebSQLDatabases) 76 wkWebsiteDataTypes |= WKWebsiteDataTypeWebSQLDatabases; 73 77 74 78 return wkWebsiteDataTypes; -
trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp
r180892 r181837 31 31 #include "WebProcessPool.h" 32 32 #include "WebsiteData.h" 33 #include <WebCore/DatabaseTracker.h> 34 #include <WebCore/OriginLock.h> 33 35 #include <wtf/RunLoop.h> 34 36 … … 63 65 : m_identifier(generateIdentifier()) 64 66 , m_sessionID(WebCore::SessionID::defaultSessionID()) 67 , m_webSQLDatabaseDirectory(WTF::move(configuration.webSQLDatabaseDirectory)) 65 68 , m_storageManager(StorageManager::create(WTF::move(configuration.localStorageDirectory))) 69 , m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore")) 66 70 { 67 71 platformInitialize(); … … 71 75 : m_identifier(generateIdentifier()) 72 76 , m_sessionID(sessionID) 77 , m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore")) 73 78 { 74 79 platformInitialize(); … … 271 276 } 272 277 278 if (dataTypes & WebsiteDataTypeWebSQLDatabases && !isNonPersistent()) { 279 StringCapture webSQLDatabaseDirectory { m_webSQLDatabaseDirectory }; 280 281 callbackAggregator->addPendingCallback(); 282 283 m_queue->dispatch([webSQLDatabaseDirectory, callbackAggregator] { 284 Vector<RefPtr<WebCore::SecurityOrigin>> origins; 285 WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory.string())->origins(origins); 286 287 RunLoop::main().dispatch([webSQLDatabaseDirectory, callbackAggregator, origins]() mutable { 288 WebsiteData websiteData; 289 for (auto& origin : origins) 290 websiteData.entries.append(WebsiteData::Entry { WTF::move(origin), WebsiteDataTypeWebSQLDatabases }); 291 292 callbackAggregator->removePendingCallback(WTF::move(websiteData)); 293 }); 294 }); 295 } 296 273 297 callbackAggregator->callIfNeeded(); 274 298 } … … 397 421 } 398 422 423 if (dataTypes & WebsiteDataTypeWebSQLDatabases && !isNonPersistent()) { 424 StringCapture webSQLDatabaseDirectory { m_webSQLDatabaseDirectory }; 425 426 callbackAggregator->addPendingCallback(); 427 428 m_queue->dispatch([webSQLDatabaseDirectory, callbackAggregator, modifiedSince] { 429 WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory.string())->deleteDatabasesModifiedSince(modifiedSince); 430 431 RunLoop::main().dispatch([callbackAggregator] { 432 callbackAggregator->removePendingCallback(); 433 }); 434 }); 435 } 436 399 437 // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away. 400 438 callbackAggregator->callIfNeeded(); … … 410 448 } 411 449 412 struct CallbackAggregator : public RefCounted<CallbackAggregator> {450 struct CallbackAggregator : public ThreadSafeRefCounted<CallbackAggregator> { 413 451 explicit CallbackAggregator (std::function<void ()> completionHandler) 414 452 : completionHandler(WTF::move(completionHandler)) … … 509 547 } 510 548 549 if (dataTypes & WebsiteDataTypeWebSQLDatabases && !isNonPersistent()) { 550 StringCapture webSQLDatabaseDirectory { m_webSQLDatabaseDirectory }; 551 552 HashSet<RefPtr<WebCore::SecurityOrigin>> origins; 553 for (const auto& dataRecord : dataRecords) { 554 for (const auto& origin : dataRecord.origins) 555 origins.add(origin); 556 } 557 558 callbackAggregator->addPendingCallback(); 559 m_queue->dispatch([origins, callbackAggregator, webSQLDatabaseDirectory] { 560 auto databaseTracker = WebCore::DatabaseTracker::trackerWithDatabasePath(webSQLDatabaseDirectory.string()); 561 562 for (const auto& origin : origins) 563 databaseTracker->deleteOrigin(origin.get()); 564 565 RunLoop::main().dispatch([callbackAggregator] { 566 callbackAggregator->removePendingCallback(); 567 }); 568 }); 569 } 570 511 571 // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away. 512 572 callbackAggregator->callIfNeeded(); -
trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h
r180706 r181837 34 34 #include <wtf/RefCounted.h> 35 35 #include <wtf/RefPtr.h> 36 #include <wtf/WorkQueue.h> 36 37 #include <wtf/text/WTFString.h> 37 38 … … 45 46 public: 46 47 struct Configuration { 48 String webSQLDatabaseDirectory; 47 49 String localStorageDirectory; 48 50 }; … … 82 84 const WebCore::SessionID m_sessionID; 83 85 86 const String m_webSQLDatabaseDirectory; 84 87 const RefPtr<StorageManager> m_storageManager; 88 89 Ref<WorkQueue> m_queue; 85 90 }; 86 91 -
trunk/Tools/ChangeLog
r181821 r181837 1 2015-03-22 Anders Carlsson <andersca@apple.com> 2 3 _WKWebsiteDataStore should clear WebSQL databases 4 https://bugs.webkit.org/show_bug.cgi?id=142947 5 6 Reviewed by Sam Weinig. 7 8 Add a variable that keeps track of the types of data we want to operate on, for easier debugging. 9 10 * MiniBrowser/mac/WK2BrowserWindowController.m: 11 (-[WK2BrowserWindowController fetchWebsiteData:]): 12 (-[WK2BrowserWindowController fetchAndClearWebsiteData:]): 13 (-[WK2BrowserWindowController clearWebsiteData:]): 14 1 15 2015-03-20 Mark Hahnenberg <mhahnenb@gmail.com> 2 16 -
trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m
r180773 r181837 408 408 } 409 409 410 static const WKWebsiteDataTypes dataTypes = WKWebsiteDataTypeAll; 411 410 412 - (IBAction)fetchWebsiteData:(id)sender 411 413 { 412 [_configuration._websiteDataStore fetchDataRecordsOfTypes: WKWebsiteDataTypeAllcompletionHandler:^(NSArray *websiteDataRecords) {414 [_configuration._websiteDataStore fetchDataRecordsOfTypes:dataTypes completionHandler:^(NSArray *websiteDataRecords) { 413 415 NSLog(@"did fetch website data %@.", websiteDataRecords); 414 416 }]; … … 417 419 - (IBAction)fetchAndClearWebsiteData:(id)sender 418 420 { 419 [_configuration._websiteDataStore fetchDataRecordsOfTypes: WKWebsiteDataTypeAllcompletionHandler:^(NSArray *websiteDataRecords) {420 [_configuration._websiteDataStore removeDataOfTypes: WKWebsiteDataTypeAllforDataRecords:websiteDataRecords completionHandler:^{421 [_configuration._websiteDataStore fetchDataRecordsOfTypes: WKWebsiteDataTypeAllcompletionHandler:^(NSArray *websiteDataRecords) {421 [_configuration._websiteDataStore fetchDataRecordsOfTypes:dataTypes completionHandler:^(NSArray *websiteDataRecords) { 422 [_configuration._websiteDataStore removeDataOfTypes:dataTypes forDataRecords:websiteDataRecords completionHandler:^{ 423 [_configuration._websiteDataStore fetchDataRecordsOfTypes:dataTypes completionHandler:^(NSArray *websiteDataRecords) { 422 424 NSLog(@"did clear website data, after clearing data is %@.", websiteDataRecords); 423 425 }]; … … 428 430 - (IBAction)clearWebsiteData:(id)sender 429 431 { 430 [_configuration._websiteDataStore removeDataOfTypes: WKWebsiteDataTypeAllmodifiedSince:[NSDate distantPast] completionHandler:^{432 [_configuration._websiteDataStore removeDataOfTypes:dataTypes modifiedSince:[NSDate distantPast] completionHandler:^{ 431 433 NSLog(@"Did clear website data."); 432 434 }];
Note:
See TracChangeset
for help on using the changeset viewer.