Changeset 180585 in webkit
- Timestamp:
- Feb 24, 2015 2:40:30 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r180579 r180585 1 2015-02-24 Anders Carlsson <andersca@apple.com> 2 3 Pass _WKWebsiteDataRecord objects to the fetchData completion handler 4 https://bugs.webkit.org/show_bug.cgi?id=141984 5 6 Reviewed by Andreas Kling. 7 8 * Shared/Cocoa/APIObject.mm: 9 (API::Object::newObject): 10 Create _WKWebsiteDataRecord objects for WebsiteDataRecord API objects. 11 12 * UIProcess/API/APIWebsiteDataRecord.h: 13 Add WebsiteDataRecord getter. 14 15 * UIProcess/API/Cocoa/_WKWebsiteDataRecord.h: 16 Add displayName and dataTypes properties. 17 18 * UIProcess/API/Cocoa/_WKWebsiteDataRecord.mm: 19 (dataTypesToString): 20 Helper function to convert dataTypes bit-fields to strings. 21 22 (-[_WKWebsiteDataRecord description]): 23 Include the display name and data types in the description. 24 25 (-[_WKWebsiteDataRecord displayName]): 26 Return the display name. 27 28 (-[_WKWebsiteDataRecord dataTypes]): 29 Return the data types. 30 31 * UIProcess/API/Cocoa/_WKWebsiteDataRecordInternal.h: 32 (WebKit::toWebsiteDataTypes): 33 Move this here from _WKWebsiteDataStore.mm. 34 35 (WebKit::toWKWebsiteDataTypes): 36 Add new function to convert WebsiteDataTypes to WKWebsiteDataTypes. 37 38 * UIProcess/API/Cocoa/_WKWebsiteDataStore.mm: 39 (-[_WKWebsiteDataStore fetchDataRecordsOfTypes:completionHandler:]): 40 (-[_WKWebsiteDataStore removeDataOfTypes:modifiedSince:completionHandler:]): 41 Qualify toWebsiteDataTypes calls. 42 43 * UIProcess/WebsiteData/WebsiteDataRecord.cpp: Added. 44 (WebKit::WebsiteDataRecord::displayNameForOrigin): 45 New helper that returns a display name given an origin. 46 47 (WebKit::WebsiteDataRecord::add): 48 Add the origin as well as the type. 49 50 * UIProcess/WebsiteData/WebsiteDataRecord.h: 51 Add new members. 52 53 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 54 (WebKit::WebsiteDataStore::fetchData): 55 Loop through the entries and add them to the m_websiteDataRecords hash map, which 56 is keyed off of the display name. Pass the m_websiteDataRecords values to the completion handler. 57 58 * WebKit2.xcodeproj/project.pbxproj: 59 1 60 2015-02-24 Csaba Osztrogonác <ossy@webkit.org> 2 61 -
trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm
r180362 r180585 62 62 #import "_WKProcessPoolConfigurationInternal.h" 63 63 #import "_WKVisitedLinkProviderInternal.h" 64 #import "_WKWebsiteDataRecordInternal.h" 64 65 #import "_WKWebsiteDataStoreInternal.h" 65 66 #import <objc/objc-auto.h> … … 192 193 case Type::VisitedLinkProvider: 193 194 wrapper = [_WKVisitedLinkProvider alloc]; 195 break; 196 197 case Type::WebsiteDataRecord: 198 wrapper = [_WKWebsiteDataRecord alloc]; 194 199 break; 195 200 -
trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataRecord.h
r180519 r180585 37 37 virtual ~WebsiteDataRecord(); 38 38 39 const WebKit::WebsiteDataRecord& websiteDataRecord() const { return m_websiteDataRecord; } 40 39 41 private: 40 42 explicit WebsiteDataRecord(WebKit::WebsiteDataRecord&&); -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecord.h
r180513 r180585 41 41 WK_CLASS_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA) 42 42 @interface _WKWebsiteDataRecord : NSObject 43 44 @property (nonatomic, readonly, copy) NSString *displayName; 45 46 @property (nonatomic, readonly) WKWebsiteDataTypes dataTypes; 43 47 @end 44 48 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecord.mm
r180513 r180585 38 38 } 39 39 40 static NSString *dataTypesToString(WKWebsiteDataTypes dataTypes) 41 { 42 auto array = adoptNS([[NSMutableArray alloc] init]); 43 44 if (dataTypes & WKWebsiteDataTypeCookies) 45 [array addObject:@"Cookies"]; 46 if (dataTypes & WKWebsiteDataTypeDiskCache) 47 [array addObject:@"Disk Cache"]; 48 if (dataTypes & WKWebsiteDataTypeMemoryCache) 49 [array addObject:@"Memory Cache"]; 50 if (dataTypes & WKWebsiteDataTypeLocalStorage) 51 [array addObject:@"Local Storage"]; 52 53 return [array componentsJoinedByString:@", "]; 54 } 55 56 - (NSString *)description 57 { 58 return [NSString stringWithFormat:@"<%@: %p; displayName = %@; dataTypes = { %@ }>", NSStringFromClass(self.class), self, self.displayName, dataTypesToString(self.dataTypes)]; 59 } 60 61 - (NSString *)displayName 62 { 63 return _websiteDataRecord->websiteDataRecord().displayName; 64 } 65 66 - (WKWebsiteDataTypes)dataTypes 67 { 68 return WebKit::toWKWebsiteDataTypes(_websiteDataRecord->websiteDataRecord().types); 69 } 70 40 71 #pragma mark WKObject protocol implementation 41 72 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataRecordInternal.h
r180513 r180585 39 39 } 40 40 41 static inline WebKit::WebsiteDataTypes toWebsiteDataTypes(WKWebsiteDataTypes wkWebsiteDataTypes) 42 { 43 using WebsiteDataTypes = WebKit::WebsiteDataTypes; 44 45 int websiteDataTypes = 0; 46 47 if (wkWebsiteDataTypes & WKWebsiteDataTypeCookies) 48 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeCookies; 49 if (wkWebsiteDataTypes & WKWebsiteDataTypeDiskCache) 50 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeDiskCache; 51 if (wkWebsiteDataTypes & WKWebsiteDataTypeMemoryCache) 52 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeMemoryCache; 53 if (wkWebsiteDataTypes & WKWebsiteDataTypeLocalStorage) 54 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeLocalStorage; 55 56 return static_cast<WebsiteDataTypes>(websiteDataTypes); 57 } 58 59 static inline WKWebsiteDataTypes toWKWebsiteDataTypes(int websiteDataTypes) 60 { 61 using WebsiteDataTypes = WebKit::WebsiteDataTypes; 62 63 WKWebsiteDataTypes wkWebsiteDataTypes = 0; 64 65 if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeCookies) 66 wkWebsiteDataTypes |= WKWebsiteDataTypeCookies; 67 if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeDiskCache) 68 wkWebsiteDataTypes |= WKWebsiteDataTypeDiskCache; 69 if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeMemoryCache) 70 wkWebsiteDataTypes |= WKWebsiteDataTypeMemoryCache; 71 if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeLocalStorage) 72 wkWebsiteDataTypes |= WKWebsiteDataTypeLocalStorage; 73 74 return wkWebsiteDataTypes; 75 } 76 41 77 } 42 78 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStore.mm
r180519 r180585 30 30 31 31 #import "APIArray.h" 32 #import "APIWebsiteDataRecord.h"33 32 #import "WKNSArray.h" 33 #import "_WKWebsiteDataRecordInternal.h" 34 34 35 35 @implementation _WKWebsiteDataStore … … 57 57 } 58 58 59 static WebKit::WebsiteDataTypes toWebsiteDataTypes(WKWebsiteDataTypes wkWebsiteDataTypes)60 {61 using WebsiteDataTypes = WebKit::WebsiteDataTypes;62 63 int websiteDataTypes = 0;64 65 if (wkWebsiteDataTypes & WKWebsiteDataTypeCookies)66 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeCookies;67 if (wkWebsiteDataTypes & WKWebsiteDataTypeDiskCache)68 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeDiskCache;69 if (wkWebsiteDataTypes & WKWebsiteDataTypeMemoryCache)70 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeMemoryCache;71 if (wkWebsiteDataTypes & WKWebsiteDataTypeLocalStorage)72 websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeLocalStorage;73 74 return static_cast<WebsiteDataTypes>(websiteDataTypes);75 }76 77 59 static std::chrono::system_clock::time_point toSystemClockTime(NSDate *date) 78 60 { … … 87 69 auto completionHandlerCopy = Block_copy(completionHandler); 88 70 89 _websiteDataStore->websiteDataStore().fetchData( toWebsiteDataTypes(websiteDataTypes), [completionHandlerCopy](Vector<WebKit::WebsiteDataRecord> websiteDataRecords) {71 _websiteDataStore->websiteDataStore().fetchData(WebKit::toWebsiteDataTypes(websiteDataTypes), [completionHandlerCopy](Vector<WebKit::WebsiteDataRecord> websiteDataRecords) { 90 72 Vector<RefPtr<API::Object>> elements; 91 73 elements.reserveInitialCapacity(websiteDataRecords.size()); … … 103 85 { 104 86 auto completionHandlerCopy = Block_copy(completionHandler); 105 _websiteDataStore->websiteDataStore().removeData( toWebsiteDataTypes(websiteDataTypes), toSystemClockTime(date ? date : [NSDate distantPast]), [completionHandlerCopy] {87 _websiteDataStore->websiteDataStore().removeData(WebKit::toWebsiteDataTypes(websiteDataTypes), toSystemClockTime(date ? date : [NSDate distantPast]), [completionHandlerCopy] { 106 88 completionHandlerCopy(); 107 89 Block_release(completionHandlerCopy); -
trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp
r180579 r180585 24 24 */ 25 25 26 #ifndef APIWebsiteDataRecord_h 27 #define APIWebsiteDataRecord_h 28 29 #include "APIObject.h" 26 #include "config.h" 30 27 #include "WebsiteDataRecord.h" 31 28 32 namespace API { 29 #include <WebCore/PublicSuffix.h> 30 #include <WebCore/SecurityOrigin.h> 33 31 34 class WebsiteDataRecord final : public ObjectImpl<Object::Type::WebsiteDataRecord> { 35 public: 36 static Ref<WebsiteDataRecord> create(WebKit::WebsiteDataRecord&&); 37 virtual ~WebsiteDataRecord(); 32 namespace WebKit { 38 33 39 private: 40 explicit WebsiteDataRecord(WebKit::WebsiteDataRecord&&); 34 String WebsiteDataRecord::displayNameForOrigin(const WebCore::SecurityOrigin& securityOrigin) 35 { 36 const auto& protocol = securityOrigin.protocol(); 41 37 42 const WebKit::WebsiteDataRecord m_websiteDataRecord; 43 }; 38 if (protocol == "file") { 39 // FIXME: Handle this. Return a localized display name. 40 ASSERT_NOT_REACHED(); 41 } 42 43 if (protocol == "http" || protocol == "https") 44 return WebCore::topPrivatelyControlledDomain(securityOrigin.host()); 45 46 return String(); 47 } 48 49 void WebsiteDataRecord::add(WebsiteDataTypes type, RefPtr<WebCore::SecurityOrigin>&& origin) 50 { 51 types |= type; 52 53 origins.add(WTF::move(origin)); 54 } 44 55 45 56 } 46 47 #endif // APIWebsiteDataRecord_h -
trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.h
r180519 r180585 27 27 #define WebsiteDataRecord_h 28 28 29 #include "WebsiteDataTypes.h" 30 #include <WebCore/SecurityOriginHash.h> 31 #include <wtf/HashSet.h> 32 #include <wtf/text/WTFString.h> 33 34 namespace WebCore { 35 class SecurityOrigin; 36 } 37 29 38 namespace WebKit { 30 39 31 40 struct WebsiteDataRecord { 32 // FIXME: Fill this in. 41 static String displayNameForOrigin(const WebCore::SecurityOrigin&); 42 43 void add(WebsiteDataTypes, RefPtr<WebCore::SecurityOrigin>&&); 44 45 String displayName; 46 unsigned types; 47 HashSet<RefPtr<WebCore::SecurityOrigin>> origins; 33 48 }; 34 49 -
trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp
r180575 r180585 134 134 --pendingCallbacks; 135 135 136 // FIXME: Do something with the website data. 136 for (auto& entry : websiteData.entries) { 137 auto displayName = WebsiteDataRecord::displayNameForOrigin(*entry.origin); 138 if (!displayName) 139 continue; 140 141 auto& record = m_websiteDataRecords.add(displayName, WebsiteDataRecord { }).iterator->value; 142 if (!record.displayName) 143 record.displayName = WTF::move(displayName); 144 145 record.add(entry.type, WTF::move(entry.origin)); 146 } 147 137 148 callIfNeeded(); 138 149 } … … 145 156 RefPtr<CallbackAggregator> callbackAggregator(this); 146 157 RunLoop::main().dispatch([callbackAggregator] { 147 // FIXME: Pass data records to the completion handler. 148 callbackAggregator->completionHandler({ }); 158 159 WTF::Vector<WebsiteDataRecord> records; 160 records.reserveInitialCapacity(callbackAggregator->m_websiteDataRecords.size()); 161 162 for (auto& record : callbackAggregator->m_websiteDataRecords.values()) 163 records.uncheckedAppend(WTF::move(record)); 164 165 callbackAggregator->completionHandler(WTF::move(records)); 149 166 }); 150 167 } … … 152 169 unsigned pendingCallbacks = 0; 153 170 std::function<void (Vector<WebsiteDataRecord>)> completionHandler; 171 172 HashMap<String, WebsiteDataRecord> m_websiteDataRecords; 154 173 }; 155 174 -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r180575 r180585 257 257 1A4832D61A9CDF96008B4DFE /* WebsiteData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4832D41A9CDF96008B4DFE /* WebsiteData.cpp */; }; 258 258 1A4832D71A9CDF96008B4DFE /* WebsiteData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4832D51A9CDF96008B4DFE /* WebsiteData.h */; }; 259 1A4832D91A9D1FD2008B4DFE /* WebsiteDataRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4832D81A9D1FD2008B4DFE /* WebsiteDataRecord.cpp */; }; 259 260 1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A9C5312B816CF008FE984 /* NetscapePluginModule.cpp */; }; 260 261 1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4A9C5412B816CF008FE984 /* NetscapePluginModule.h */; }; … … 2337 2338 1A4832D41A9CDF96008B4DFE /* WebsiteData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebsiteData.cpp; sourceTree = "<group>"; }; 2338 2339 1A4832D51A9CDF96008B4DFE /* WebsiteData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteData.h; sourceTree = "<group>"; }; 2340 1A4832D81A9D1FD2008B4DFE /* WebsiteDataRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebsiteDataRecord.cpp; sourceTree = "<group>"; }; 2339 2341 1A4A9C5312B816CF008FE984 /* NetscapePluginModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginModule.cpp; sourceTree = "<group>"; }; 2340 2342 1A4A9C5412B816CF008FE984 /* NetscapePluginModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePluginModule.h; sourceTree = "<group>"; }; … … 4482 4484 children = ( 4483 4485 1A4832C01A965A33008B4DFE /* Cocoa */, 4486 1A4832D81A9D1FD2008B4DFE /* WebsiteDataRecord.cpp */, 4484 4487 1A4832CF1A9BD821008B4DFE /* WebsiteDataRecord.h */, 4485 4488 1A53C2A41A32569F004E8C70 /* WebsiteDataStore.cpp */, … … 9859 9862 BC20528211C94284008F3375 /* WKBundlePage.cpp in Sources */, 9860 9863 7CF47FF617275B71008ACB91 /* WKBundlePageBanner.cpp in Sources */, 9864 1A4832D91A9D1FD2008B4DFE /* WebsiteDataRecord.cpp in Sources */, 9861 9865 7CF47FFE17276AE3008ACB91 /* WKBundlePageBannerMac.mm in Sources */, 9862 9866 BC7B633E12A45D1200D174A4 /* WKBundlePageGroup.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.