Changeset 148215 in webkit
- Timestamp:
- Apr 11, 2013 10:44:17 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r148214 r148215 1 2013-04-11 Anders Carlsson <andersca@apple.com> 2 3 Implement more logic in StorageAreaMap 4 https://bugs.webkit.org/show_bug.cgi?id=114451 5 6 Reviewed by Alexey Proskuryakov. 7 8 * Platform/CoreIPC/HandleMessage.h: 9 (CoreIPC::callMemberFunction): 10 Add new overload. 11 12 * UIProcess/Storage/StorageManager.cpp: 13 (WebKit::StorageManager::StorageArea::addListener): 14 (WebKit::StorageManager::StorageArea::removeListener): 15 These take storage map IDs. 16 17 (WebKit::StorageManager::StorageArea::setItem): 18 Rename storageAreaID to sourceStorageAreaID. 19 20 (WebKit::StorageManager::StorageArea::dispatchEvents): 21 Remove the code that would not dispatch to the source connection, there may still be storage areas interested in those events. 22 23 (WebKit::StorageManager::setItem): 24 This now takes the source storage area ID. 25 26 (WebKit::StorageManager::findStorageArea): 27 This takes a storage map ID. 28 29 * UIProcess/Storage/StorageManager.messages.in: 30 SetItem now takes the source storage area ID as well. 31 32 * WebProcess/Storage/StorageAreaImpl.cpp: 33 (WebKit::StorageAreaImpl::setItem): 34 Pass the source frame to StorageAreaMap::setItem. 35 36 * WebProcess/Storage/StorageAreaMap.cpp: 37 (WebKit::StorageAreaMap::StorageAreaMap): 38 Send CreateStorageMap and add the object as a message receiver. 39 40 (WebKit::StorageAreaMap::~StorageAreaMap): 41 Send DestroyStorageMap and remove the object as a message receiver. 42 43 (WebKit::StorageAreaMap::length): 44 (WebKit::StorageAreaMap::key): 45 (WebKit::StorageAreaMap::item): 46 (WebKit::StorageAreaMap::contains): 47 Load values and forward calls to the storage map. 48 49 (WebKit::StorageAreaMap::setItem): 50 This now takes the source frame as well. Update the local storage map and send a SetItem message. 51 52 (WebKit::StorageAreaMap::loadValuesIfNeeded): 53 Get the values from the storage manager. 54 55 (WebKit::StorageAreaMap::dispatchStorageEvent): 56 This now takes the source storage area ID. 57 58 * WebProcess/Storage/StorageAreaMap.messages.in: 59 DispatchStorageEvent now takes the source storage area ID. 60 1 61 2013-04-10 Brady Eidson <beidson@apple.com> 2 62 -
trunk/Source/WebKit2/Platform/CoreIPC/HandleMessage.h
r145164 r148215 254 254 } 255 255 256 template<typename C, typename MF, typename P1, typename P2, typename P3, typename P4, typename P5> 257 void callMemberFunction(Connection* connection, const Arguments5<P1, P2, P3, P4, P5>& args, C* object, MF function) 258 { 259 (object->*function)(connection, args.argument1, args.argument2, args.argument3, args.argument4, args.argument5); 260 } 261 256 262 template<typename C, typename MF, typename P1, typename R1> 257 263 void callMemberFunction(Connection* connection, const Arguments1<P1>& args, Arguments1<R1>& replyArgs, C* object, MF function) -
trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp
r148160 r148215 44 44 ~StorageArea(); 45 45 46 void addListener(CoreIPC::Connection*, uint64_t storage AreaID);47 void removeListener(CoreIPC::Connection*, uint64_t storage AreaID);48 49 void setItem(CoreIPC::Connection*, uint64_t s torageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException);46 void addListener(CoreIPC::Connection*, uint64_t storageMapID); 47 void removeListener(CoreIPC::Connection*, uint64_t storageMapID); 48 49 void setItem(CoreIPC::Connection*, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException); 50 50 51 51 private: 52 52 explicit StorageArea(unsigned quotaInBytes); 53 53 54 void dispatchEvents(CoreIPC::Connection* , uint64_t storageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;54 void dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const; 55 55 56 56 RefPtr<StorageMap> m_storageMap; … … 73 73 } 74 74 75 void StorageManager::StorageArea::addListener(CoreIPC::Connection* connection, uint64_t storage AreaID)76 { 77 ASSERT(!m_eventListeners.contains(std::make_pair(connection, storage AreaID)));78 m_eventListeners.add(std::make_pair(connection, storage AreaID));79 } 80 81 void StorageManager::StorageArea::removeListener(CoreIPC::Connection* connection, uint64_t storage AreaID)82 { 83 ASSERT(m_eventListeners.contains(std::make_pair(connection, storage AreaID)));84 m_eventListeners.remove(std::make_pair(connection, storage AreaID));85 } 86 87 void StorageManager::StorageArea::setItem(CoreIPC::Connection* connection, uint64_t s torageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException)75 void StorageManager::StorageArea::addListener(CoreIPC::Connection* connection, uint64_t storageMapID) 76 { 77 ASSERT(!m_eventListeners.contains(std::make_pair(connection, storageMapID))); 78 m_eventListeners.add(std::make_pair(connection, storageMapID)); 79 } 80 81 void StorageManager::StorageArea::removeListener(CoreIPC::Connection* connection, uint64_t storageMapID) 82 { 83 ASSERT(m_eventListeners.contains(std::make_pair(connection, storageMapID))); 84 m_eventListeners.remove(std::make_pair(connection, storageMapID)); 85 } 86 87 void StorageManager::StorageArea::setItem(CoreIPC::Connection* connection, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException) 88 88 { 89 89 ASSERT(m_storageMap->hasOneRef()); … … 93 93 94 94 if (!quotaException) 95 dispatchEvents(connection, s torageAreaID, key, oldValue, value, urlString);96 } 97 98 void StorageManager::StorageArea::dispatchEvents(CoreIPC::Connection* connection, uint64_t storageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const95 dispatchEvents(connection, sourceStorageAreaID, key, oldValue, value, urlString); 96 } 97 98 void StorageManager::StorageArea::dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const 99 99 { 100 100 for (HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> >::const_iterator it = m_eventListeners.begin(), end = m_eventListeners.end(); it != end; ++it) { 101 if (it->first == connection && it->second == storageAreaID) { 102 // We don't want to dispatch events to the storage area that originated the event. 103 continue; 104 } 105 106 it->first->send(Messages::StorageAreaMap::DispatchStorageEvent(key, oldValue, newValue, urlString), it->second); 101 // FIXME: If this is sent to another process, the source storage area ID will be bogus, since storage are IDs are per process. 102 it->first->send(Messages::StorageAreaMap::DispatchStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString), it->second); 107 103 } 108 104 } … … 265 261 } 266 262 267 void StorageManager::setItem(CoreIPC::Connection* connection, uint64_t storageMapID, const String& key, const String& value, const String& urlString)263 void StorageManager::setItem(CoreIPC::Connection* connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString) 268 264 { 269 265 StorageArea* storageArea = findStorageArea(connection, storageMapID); … … 273 269 274 270 bool quotaError; 275 storageArea->setItem(connection, s torageMapID, key, value, urlString, quotaError);271 storageArea->setItem(connection, sourceStorageAreaID, key, value, urlString, quotaError); 276 272 connection->send(Messages::StorageAreaMap::DidSetItem(key, quotaError), storageMapID); 277 273 } … … 309 305 } 310 306 311 StorageManager::StorageArea* StorageManager::findStorageArea(CoreIPC::Connection* connection, uint64_t storage AreaID) const312 { 313 std::pair<CoreIPC::Connection*, uint64_t> connectionAndStorage AreaIDPair(connection, storageAreaID);314 if (!HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorage AreaIDPair))307 StorageManager::StorageArea* StorageManager::findStorageArea(CoreIPC::Connection* connection, uint64_t storageMapID) const 308 { 309 std::pair<CoreIPC::Connection*, uint64_t> connectionAndStorageMapIDPair(connection, storageMapID); 310 if (!HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorageMapIDPair)) 315 311 return 0; 316 312 317 return m_storageAreas.get(connectionAndStorage AreaIDPair).get();313 return m_storageAreas.get(connectionAndStorageMapIDPair).get(); 318 314 } 319 315 -
trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h
r148160 r148215 63 63 void destroyStorageMap(CoreIPC::Connection*, uint64_t storageMapID); 64 64 void getValues(CoreIPC::Connection*, uint64_t storageMapID, HashMap<String, String>& values); 65 void setItem(CoreIPC::Connection*, uint64_t storageAreaID, const String& key, const String& value, const String& urlString);65 void setItem(CoreIPC::Connection*, uint64_t storageAreaID, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString); 66 66 67 67 void createSessionStorageNamespaceInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection, unsigned quotaInBytes); -
trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in
r148160 r148215 27 27 GetValues(uint64_t storageMapID) -> (WTF::HashMap<WTF::String, WTF::String> values) WantsConnection 28 28 29 SetItem(uint64_t storageMapID, WTF::String key, WTF::String value, WTF::String urlString) WantsConnection29 SetItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String key, WTF::String value, WTF::String urlString) WantsConnection 30 30 } -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaImpl.cpp
r148161 r148215 122 122 123 123 bool quotaException; 124 m_storageAreaMap->setItem( this, key, value, quotaException);124 m_storageAreaMap->setItem(sourceFrame, this, key, value, quotaException); 125 125 126 126 if (quotaException) -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp
r148161 r148215 27 27 #include "StorageAreaMap.h" 28 28 29 #include "SecurityOriginData.h" 30 #include "StorageAreaImpl.h" 31 #include "StorageAreaMapMessages.h" 32 #include "StorageManagerMessages.h" 29 33 #include "StorageNamespaceImpl.h" 34 #include "WebProcess.h" 35 #include <WebCore/Frame.h> 30 36 #include <WebCore/StorageMap.h> 31 37 … … 51 57 , m_securityOrigin(securityOrigin) 52 58 { 59 WebProcess::shared().connection()->send(Messages::StorageManager::CreateStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin.get())), 0); 60 WebProcess::shared().addMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID, this); 53 61 } 54 62 55 63 StorageAreaMap::~StorageAreaMap() 56 64 { 65 WebProcess::shared().connection()->send(Messages::StorageManager::DestroyStorageMap(m_storageMapID), 0); 66 WebProcess::shared().removeMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID); 57 67 } 58 68 … … 68 78 unsigned StorageAreaMap::length() 69 79 { 70 // FIXME: Implement. 71 return 0; 80 loadValuesIfNeeded(); 81 82 return m_storageMap->length(); 72 83 } 73 84 74 85 String StorageAreaMap::key(unsigned index) 75 86 { 76 // FIXME: Implement. 77 return String(); 87 loadValuesIfNeeded(); 88 89 return m_storageMap->key(index); 78 90 } 79 91 80 92 String StorageAreaMap::item(const String& key) 81 93 { 82 // FIXME: Implement. 83 return String(); 94 loadValuesIfNeeded(); 95 96 return m_storageMap->getItem(key); 84 97 } 85 98 86 void StorageAreaMap::setItem( StorageAreaImpl* sourceArea, const String& key, const String& value, bool& quotaException)99 void StorageAreaMap::setItem(Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key, const String& value, bool& quotaException) 87 100 { 88 // FIXME: Implement. 101 loadValuesIfNeeded(); 102 103 ASSERT(m_storageMap->hasOneRef()); 104 105 String oldValue; 106 quotaException = false; 107 m_storageMap->setItem(key, value, oldValue, quotaException); 108 if (quotaException) 109 return; 110 111 if (oldValue == value) 112 return; 113 114 m_pendingValueChanges.add(key); 115 116 WebProcess::shared().connection()->send(Messages::StorageManager::SetItem(m_storageMapID, sourceArea->storageAreaID(), key, value, sourceFrame->document()->url()), 0); 89 117 } 90 118 91 119 bool StorageAreaMap::contains(const String& key) 92 120 { 93 // FIXME: Implement. 94 return false; 121 loadValuesIfNeeded(); 122 123 return m_storageMap->contains(key); 124 } 125 126 void StorageAreaMap::loadValuesIfNeeded() 127 { 128 if (m_storageMap) 129 return; 130 131 HashMap<String, String> values; 132 // FIXME: This should use a special sendSync flag to indicate that we don't want to process incoming messages while waiting for a reply. 133 // (This flag does not yet exist). Since loadValuesIfNeeded() ends up being called from within JavaScript code, processing incoming synchronous messages 134 // could lead to weird reentrency bugs otherwise. 135 WebProcess::shared().connection()->sendSync(Messages::StorageManager::GetValues(m_storageMapID), Messages::StorageManager::GetValues::Reply(values), 0); 136 137 m_storageMap = StorageMap::create(m_quotaInBytes); 138 m_storageMap->importItems(values); 95 139 } 96 140 … … 100 144 } 101 145 102 void StorageAreaMap::dispatchStorageEvent( const String& key, const String& oldValue, const String& newValue, const String& urlString)146 void StorageAreaMap::dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) 103 147 { 104 148 // FIXME: Implement. -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h
r148161 r148215 31 31 #include <WebCore/StorageArea.h> 32 32 #include <wtf/Forward.h> 33 #include <wtf/HashCountedSet.h> 33 34 #include <wtf/PassRefPtr.h> 34 35 #include <wtf/RefCounted.h> … … 54 55 String key(unsigned index); 55 56 String item(const String& key); 56 void setItem( StorageAreaImpl* sourceArea, const String& key, const String& value, bool& quotaException);57 void setItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key, const String& value, bool& quotaException); 57 58 bool contains(const String& key); 58 59 … … 64 65 65 66 void didSetItem(const String& key, bool quotaError); 66 void dispatchStorageEvent( const String& key, const String& oldValue, const String& newValue, const String& urlString);67 void dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString); 67 68 68 69 void loadValuesIfNeeded(); … … 73 74 RefPtr<WebCore::SecurityOrigin> m_securityOrigin; 74 75 75 76 76 RefPtr<WebCore::StorageMap> m_storageMap; 77 HashCountedSet<String> m_pendingValueChanges; 77 78 }; 78 79 -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in
r148154 r148215 24 24 DidSetItem(WTF::String key, bool quotaException) 25 25 26 DispatchStorageEvent( WTF::String key, WTF::String oldValue, WTF::String newValue, WTF::String urlString)26 DispatchStorageEvent(uint64_t sourceStorageAreaID, WTF::String key, WTF::String oldValue, WTF::String newValue, WTF::String urlString) 27 27 }
Note: See TracChangeset
for help on using the changeset viewer.