Changeset 215315 in webkit
- Timestamp:
- Apr 12, 2017 11:38:19 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 2 deleted
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r215312 r215315 1 2017-04-12 Brady Eidson <beidson@apple.com> 2 3 QuotaExceededError when saving to localStorage in private mode. 4 https://bugs.webkit.org/show_bug.cgi?id=157010 5 6 Reviewed by Alex Christensen. 7 8 * platform/mac-wk2/TestExpectations: 9 * storage/domstorage/localstorage/private-browsing-affects-storage-expected.txt: 10 * storage/domstorage/localstorage/private-browsing-affects-storage.html: 11 * storage/domstorage/localstorage/resources/private-browsing-1.html: Added. 12 * storage/domstorage/localstorage/resources/private-browsing-2.html: Added. 13 * storage/domstorage/localstorage/resources/private-browsing-3.html: Added. 14 * storage/domstorage/localstorage/resources/private-browsing-storage-2.html: Added. 15 * storage/domstorage/sessionstorage/private-browsing-affects-storage-expected.txt: Removed. 16 * storage/domstorage/sessionstorage/private-browsing-affects-storage.html: Removed. 17 1 18 2017-04-12 Joseph Pecoraro <pecoraro@apple.com> 2 19 -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r215263 r215315 425 425 plugins/private-browsing-mode-2.html [ Skip ] 426 426 plugins/private-browsing-mode.html [ Skip ] 427 storage/domstorage/localstorage/private-browsing-affects-storage.html [ Skip ]428 storage/domstorage/sessionstorage/private-browsing-affects-storage.html [ Skip ]429 427 storage/websql/private-browsing-noread-nowrite.html [ Skip ] 430 428 -
trunk/LayoutTests/storage/domstorage/localstorage/private-browsing-affects-storage-expected.txt
r203333 r215315 1 This is a test to make sure that when private browsing is on any attempt to change the localStorage area fail. 2 Initial value of testItem is: null 3 Caught exception trying to change item: QuotaExceededError (DOM Exception 22): The quota has been exceeded. 4 After change attempt, testItem is: null 5 After remove attempt, testItem is: null 6 After clear attempt, testItem is: null 1 ALERT: Persistent localStorage testItem is: Persistent item! 2 ALERT: Start of private browsing test, testItem is: null 3 ALERT: localStorage's length is: 0 4 ALERT: After set attempt, testItem is: FirstValue 5 ALERT: After second set attempt, testItem is: ChangedValue 6 ALERT: Opening window... 7 ALERT: localStorage's length is: 1 8 ALERT: The item in new window starts out as: ChangedValue 9 ALERT: The item in new window is now: NewWindowValue 10 ALERT: Back in parent window, localStorage's length is: 1 11 ALERT: Back in parent window, testItem is: ChangedValue 12 ALERT: Final window, localStorage's length is: 1 13 ALERT: Final window, item is: Persistent item! 7 14 -
trunk/LayoutTests/storage/domstorage/localstorage/private-browsing-affects-storage.html
r120516 r215315 3 3 <script> 4 4 5 if (window.testRunner) 5 if (window.testRunner) { 6 6 testRunner.dumpAsText(); 7 testRunner.waitUntilDone(); 8 } 7 9 8 10 function log(a) 9 11 { 10 document.getElementById("logger").innerHTML += a + "<br>";12 alert(a + ""); 11 13 } 12 14 13 15 function runTest() 14 16 { 15 if (!window. localStorage) {16 log(" window.localStorage DOES NOT exist");17 if (!window.testRunner) { 18 log("Test only designed to be run under DumpRenderTree or WebKitTestRunner"); 17 19 return; 18 20 } 19 if (!window.testRunner) { 20 log("Test only designed to be run under DumpRenderTree"); 21 return; 22 } 23 localStorage.clear(); 21 22 localStorage.setItem("testItem", "Persistent item!"); 23 log("Persistent localStorage testItem is: " + localStorage.getItem("testItem")); 24 24 25 localStorage.setItem("testItem", "InitialValue");26 25 testRunner.setPrivateBrowsingEnabled(true); 27 log("Initial value of testItem is: " + localStorage.getItem("testItem")); 28 29 try { 30 localStorage.setItem("testItem", "ChangedValue"); 31 } catch(e) { 32 log("Caught exception trying to change item: " + e); 33 } 34 35 log("After change attempt, testItem is: " + localStorage.getItem("testItem")); 26 testRunner.setCanOpenWindows(); 36 27 37 localStorage.removeItem("testItem"); 38 log("After remove attempt, testItem is: " + localStorage.getItem("testItem")); 39 40 localStorage.clear(); 41 log("After clear attempt, testItem is: " + localStorage.getItem("testItem")); 28 window.location.href = "resources/private-browsing-1.html" 42 29 } 43 30 … … 45 32 </head> 46 33 <body onload="runTest();"> 47 This is a test to make sure that when private browsing is on any attempt to change the localStorage area fail.34 This is a test to make sure that when private browsing is on changes to local storage are not persistent. 48 35 <div id="logger"></div> 49 36 </body> -
trunk/Source/WebCore/ChangeLog
r215314 r215315 1 2017-04-12 Brady Eidson <beidson@apple.com> 2 3 QuotaExceededError when saving to localStorage in private mode. 4 https://bugs.webkit.org/show_bug.cgi?id=157010 5 6 Reviewed by Alex Christensen. 7 8 No new tests (Covered by changes to existing test). 9 10 LocalStorage in private browsing is now effectively SessionStorage. 11 It's ephemeral, per-tab, and copied over to tabs window.open()'ed from the current. 12 13 * loader/EmptyClients.cpp: 14 (WebCore::EmptyStorageNamespaceProvider::createEphemeralLocalStorageNamespace): 15 16 * page/Chrome.cpp: 17 (WebCore::Chrome::createWindow): 18 19 * page/Page.cpp: 20 (WebCore::Page::ephemeralLocalStorage): 21 (WebCore::Page::setEphemeralLocalStorage): 22 * page/Page.h: 23 24 * page/SecurityOriginData.h: 25 26 * storage/Storage.cpp: 27 (WebCore::Storage::length): 28 (WebCore::Storage::key): 29 (WebCore::Storage::getItem): 30 (WebCore::Storage::setItem): 31 (WebCore::Storage::removeItem): 32 (WebCore::Storage::clear): 33 (WebCore::Storage::contains): 34 (WebCore::Storage::isDisabledByPrivateBrowsing): Deleted. 35 36 * storage/StorageMap.h: 37 38 * storage/StorageNamespaceProvider.cpp: 39 (WebCore::StorageNamespaceProvider::localStorageArea): 40 * storage/StorageNamespaceProvider.h: 41 42 * storage/StorageType.h: 43 (WebCore::isLocalStorage): 44 (WebCore::isPersistentLocalStorage): 45 1 46 2017-04-12 Myles C. Maxfield <mmaxfield@apple.com> 2 47 -
trunk/Source/WebCore/loader/EmptyClients.cpp
r214680 r215315 563 563 RefPtr<StorageNamespace> createSessionStorageNamespace(Page&, unsigned) final; 564 564 RefPtr<StorageNamespace> createLocalStorageNamespace(unsigned) final; 565 RefPtr<StorageNamespace> createEphemeralLocalStorageNamespace(Page&, unsigned) final; 565 566 RefPtr<StorageNamespace> createTransientLocalStorageNamespace(SecurityOrigin&, unsigned) final; 566 567 }; … … 673 674 674 675 RefPtr<StorageNamespace> EmptyStorageNamespaceProvider::createLocalStorageNamespace(unsigned) 676 { 677 return adoptRef(*new EmptyStorageNamespace); 678 } 679 680 RefPtr<StorageNamespace> EmptyStorageNamespaceProvider::createEphemeralLocalStorageNamespace(Page&, unsigned) 675 681 { 676 682 return adoptRef(*new EmptyStorageNamespace); -
trunk/Source/WebCore/page/Chrome.cpp
r211033 r215315 193 193 if (!newPage) 194 194 return nullptr; 195 195 196 if (auto* oldSessionStorage = m_page.sessionStorage(false)) 196 197 newPage->setSessionStorage(oldSessionStorage->copy(newPage)); 198 if (auto* oldEphemeralLocalStorage = m_page.ephemeralLocalStorage(false)) 199 newPage->setEphemeralLocalStorage(oldEphemeralLocalStorage->copy(newPage)); 200 197 201 return newPage; 198 202 } -
trunk/Source/WebCore/page/Page.cpp
r214893 r215315 1312 1312 } 1313 1313 1314 StorageNamespace* Page::ephemeralLocalStorage(bool optionalCreate) 1315 { 1316 if (!m_ephemeralLocalStorage && optionalCreate) 1317 m_ephemeralLocalStorage = m_storageNamespaceProvider->createEphemeralLocalStorageNamespace(*this, m_settings->sessionStorageQuota()); 1318 1319 return m_ephemeralLocalStorage.get(); 1320 } 1321 1322 void Page::setEphemeralLocalStorage(RefPtr<StorageNamespace>&& newStorage) 1323 { 1324 m_ephemeralLocalStorage = WTFMove(newStorage); 1325 } 1326 1314 1327 bool Page::hasCustomHTMLTokenizerTimeDelay() const 1315 1328 { -
trunk/Source/WebCore/page/Page.h
r214893 r215315 415 415 void setSessionStorage(RefPtr<StorageNamespace>&&); 416 416 417 StorageNamespace* ephemeralLocalStorage(bool optionalCreate = true); 418 void setEphemeralLocalStorage(RefPtr<StorageNamespace>&&); 419 417 420 bool hasCustomHTMLTokenizerTimeDelay() const; 418 421 double customHTMLTokenizerTimeDelay() const; … … 717 720 718 721 RefPtr<StorageNamespace> m_sessionStorage; 722 RefPtr<StorageNamespace> m_ephemeralLocalStorage; 719 723 720 724 #if ENABLE(VIEW_MODE_CSS_MEDIA) -
trunk/Source/WebCore/page/SecurityOriginData.h
r208985 r215315 79 79 80 80 #if !LOG_DISABLED 81 String debugString() const;81 WEBCORE_EXPORT String debugString() const; 82 82 #endif 83 83 }; -
trunk/Source/WebCore/storage/Storage.cpp
r214680 r215315 64 64 return Exception { SECURITY_ERR }; 65 65 66 if (isDisabledByPrivateBrowsing())67 return 0;68 69 66 return m_storageArea->length(); 70 67 } … … 74 71 if (!m_storageArea->canAccessStorage(m_frame)) 75 72 return Exception { SECURITY_ERR }; 76 77 if (isDisabledByPrivateBrowsing())78 return String();79 73 80 74 return m_storageArea->key(index); … … 86 80 return Exception { SECURITY_ERR }; 87 81 88 if (isDisabledByPrivateBrowsing())89 return String();90 91 82 return m_storageArea->item(key); 92 83 } … … 96 87 if (!m_storageArea->canAccessStorage(m_frame)) 97 88 return Exception { SECURITY_ERR }; 98 99 if (isDisabledByPrivateBrowsing())100 return Exception { QUOTA_EXCEEDED_ERR };101 89 102 90 bool quotaException = false; … … 112 100 return Exception { SECURITY_ERR }; 113 101 114 if (isDisabledByPrivateBrowsing())115 return { };116 117 102 m_storageArea->removeItem(m_frame, key); 118 103 return { }; … … 123 108 if (!m_storageArea->canAccessStorage(m_frame)) 124 109 return Exception { SECURITY_ERR }; 125 126 if (isDisabledByPrivateBrowsing())127 return { };128 110 129 111 m_storageArea->clear(m_frame); … … 136 118 return Exception { SECURITY_ERR }; 137 119 138 if (isDisabledByPrivateBrowsing())139 return false;140 141 120 return m_storageArea->contains(key); 142 121 } 143 122 144 bool Storage::isDisabledByPrivateBrowsing() const145 {146 if (!m_frame->page()->usesEphemeralSession())147 return false;148 149 if (isLocalStorage(m_storageArea->storageType())) {150 if (SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing(m_frame->document()->securityOrigin().protocol()))151 return false;152 }153 154 return true;155 }156 157 123 } // namespace WebCore -
trunk/Source/WebCore/storage/StorageMap.h
r208844 r215315 52 52 unsigned quota() const { return m_quotaSize; } 53 53 54 WEBCORE_EXPORT Ref<StorageMap> copy(); 55 54 56 static const constexpr unsigned noQuota = UINT_MAX; 55 57 56 58 private: 57 59 explicit StorageMap(unsigned quota); 58 Ref<StorageMap> copy();59 60 void invalidateIterator(); 60 61 void setIteratorToIndex(unsigned); -
trunk/Source/WebCore/storage/StorageNamespaceProvider.cpp
r210923 r215315 28 28 29 29 #include "Document.h" 30 #include "Page.h" 30 31 #include "SecurityOriginData.h" 31 32 #include "StorageArea.h" … … 62 63 RefPtr<StorageArea> StorageNamespaceProvider::localStorageArea(Document& document) 63 64 { 64 auto& storageNamespace = document.securityOrigin().canAccessLocalStorage(&document.topOrigin()) ? localStorageNamespace() : transientLocalStorageNamespace(document.topOrigin()); 65 // This StorageNamespaceProvider was retrieved from the Document's Page, 66 // so the Document had better still actually have a Page. 67 ASSERT(document.page()); 65 68 66 return storageNamespace.storageArea(SecurityOriginData::fromSecurityOrigin(document.securityOrigin())); 69 bool ephemeral = document.page()->usesEphemeralSession(); 70 bool transient = !document.securityOrigin().canAccessLocalStorage(&document.topOrigin()); 71 72 RefPtr<StorageNamespace> storageNamespace; 73 74 if (transient) 75 storageNamespace = &transientLocalStorageNamespace(document.topOrigin()); 76 else if (ephemeral) 77 storageNamespace = document.page()->ephemeralLocalStorage(); 78 else 79 storageNamespace = &localStorageNamespace(); 80 81 return storageNamespace->storageArea(SecurityOriginData::fromSecurityOrigin(document.securityOrigin())); 67 82 } 68 83 -
trunk/Source/WebCore/storage/StorageNamespaceProvider.h
r208646 r215315 46 46 47 47 virtual RefPtr<StorageNamespace> createSessionStorageNamespace(Page&, unsigned quota) = 0; 48 virtual RefPtr<StorageNamespace> createEphemeralLocalStorageNamespace(Page&, unsigned quota) = 0; 49 48 50 RefPtr<StorageArea> localStorageArea(Document&); 49 51 -
trunk/Source/WebCore/storage/StorageType.h
r214680 r215315 31 31 Session, 32 32 Local, 33 EphemeralLocal, 33 34 TransientLocal, 34 35 }; … … 36 37 inline bool isLocalStorage(StorageType storageType) 37 38 { 39 return storageType == StorageType::Local || storageType == StorageType::TransientLocal || storageType == StorageType::EphemeralLocal; 40 } 41 42 inline bool isPersistentLocalStorage(StorageType storageType) 43 { 38 44 return storageType == StorageType::Local || storageType == StorageType::TransientLocal; 39 45 } -
trunk/Source/WebKit/ChangeLog
r215265 r215315 1 2017-04-12 Brady Eidson <beidson@apple.com> 2 3 QuotaExceededError when saving to localStorage in private mode. 4 https://bugs.webkit.org/show_bug.cgi?id=157010 5 6 Reviewed by Alex Christensen. 7 8 * Storage/StorageNamespaceImpl.cpp: 9 (WebKit::StorageNamespaceImpl::createEphemeralLocalStorageNamespace): 10 (WebKit::StorageNamespaceImpl::StorageNamespaceImpl): 11 (WebKit::StorageNamespaceImpl::~StorageNamespaceImpl): 12 (WebKit::StorageNamespaceImpl::copy): 13 (WebKit::StorageNamespaceImpl::close): 14 * Storage/StorageNamespaceImpl.h: 15 16 * Storage/WebStorageNamespaceProvider.cpp: 17 (WebKit::WebStorageNamespaceProvider::createEphemeralLocalStorageNamespace): 18 * Storage/WebStorageNamespaceProvider.h: 19 1 20 2017-04-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 21 -
trunk/Source/WebKit/Storage/StorageNamespaceImpl.cpp
r214680 r215315 51 51 } 52 52 53 Ref<StorageNamespaceImpl> StorageNamespaceImpl::createEphemeralLocalStorageNamespace(unsigned quota) 54 { 55 return adoptRef(*new StorageNamespaceImpl(StorageType::EphemeralLocal, String(), quota)); 56 } 57 53 58 Ref<StorageNamespaceImpl> StorageNamespaceImpl::getOrCreateLocalStorageNamespace(const String& databasePath, unsigned quota) 54 59 { … … 72 77 , m_isShutdown(false) 73 78 { 74 if (is LocalStorage(m_storageType) && !m_path.isEmpty())79 if (isPersistentLocalStorage(m_storageType) && !m_path.isEmpty()) 75 80 m_syncManager = StorageSyncManager::create(m_path); 76 81 } … … 80 85 ASSERT(isMainThread()); 81 86 82 if (is LocalStorage(m_storageType)) {87 if (isPersistentLocalStorage(m_storageType)) { 83 88 ASSERT(localStorageNamespaceMap().get(m_path) == this); 84 89 localStorageNamespaceMap().remove(m_path); … … 93 98 ASSERT(isMainThread()); 94 99 ASSERT(!m_isShutdown); 95 ASSERT(m_storageType == StorageType::Session );100 ASSERT(m_storageType == StorageType::Session || m_storageType == StorageType::EphemeralLocal); 96 101 97 102 RefPtr<StorageNamespaceImpl> newNamespace = adoptRef(new StorageNamespaceImpl(m_storageType, m_path, m_quota)); 103 for (auto& iter : m_storageAreaMap) 104 newNamespace->m_storageAreaMap.set(iter.key, iter.value->copy()); 98 105 99 StorageAreaMap::iterator end = m_storageAreaMap.end();100 for (StorageAreaMap::iterator i = m_storageAreaMap.begin(); i != end; ++i)101 newNamespace->m_storageAreaMap.set(i->key, i->value->copy());102 106 return newNamespace; 103 107 } … … 124 128 return; 125 129 126 // If we're sessionstorage, we shouldn't need to do any work here.127 if (m_storageType == StorageType::Session ) {130 // If we're not a persistent storage, we shouldn't need to do any work here. 131 if (m_storageType == StorageType::Session || m_storageType == StorageType::EphemeralLocal) { 128 132 ASSERT(!m_syncManager); 129 133 return; -
trunk/Source/WebKit/Storage/StorageNamespaceImpl.h
r208727 r215315 40 40 public: 41 41 static Ref<StorageNamespaceImpl> createSessionStorageNamespace(unsigned quota); 42 static Ref<StorageNamespaceImpl> createEphemeralLocalStorageNamespace(unsigned quota); 42 43 static Ref<StorageNamespaceImpl> getOrCreateLocalStorageNamespace(const String& databasePath, unsigned quota); 43 44 virtual ~StorageNamespaceImpl(); -
trunk/Source/WebKit/Storage/WebStorageNamespaceProvider.cpp
r208727 r215315 102 102 } 103 103 104 RefPtr<StorageNamespace> WebStorageNamespaceProvider::createEphemeralLocalStorageNamespace(Page&, unsigned quota) 105 { 106 return StorageNamespaceImpl::createEphemeralLocalStorageNamespace(quota); 107 } 108 104 109 RefPtr<StorageNamespace> WebStorageNamespaceProvider::createLocalStorageNamespace(unsigned quota) 105 110 { -
trunk/Source/WebKit/Storage/WebStorageNamespaceProvider.h
r208727 r215315 51 51 52 52 RefPtr<WebCore::StorageNamespace> createSessionStorageNamespace(WebCore::Page&, unsigned quota) override; 53 RefPtr<WebCore::StorageNamespace> createEphemeralLocalStorageNamespace(WebCore::Page&, unsigned quota) override; 53 54 RefPtr<WebCore::StorageNamespace> createLocalStorageNamespace(unsigned quota) override; 54 55 RefPtr<WebCore::StorageNamespace> createTransientLocalStorageNamespace(WebCore::SecurityOrigin&, unsigned quota) override; -
trunk/Source/WebKit2/ChangeLog
r215313 r215315 1 2017-04-12 Brady Eidson <beidson@apple.com> 2 3 QuotaExceededError when saving to localStorage in private mode. 4 https://bugs.webkit.org/show_bug.cgi?id=157010 5 6 Reviewed by Alex Christensen. 7 8 * WebProcess/Storage/StorageAreaMap.cpp: 9 (WebKit::StorageAreaMap::StorageAreaMap): 10 (WebKit::StorageAreaMap::~StorageAreaMap): 11 12 * WebProcess/Storage/StorageNamespaceImpl.cpp: 13 (WebKit::StorageNamespaceImpl::createEphemeralLocalStorageNamespace): 14 (WebKit::StorageNamespaceImpl::storageArea): 15 (WebKit::StorageNamespaceImpl::ephemeralLocalStorageArea): 16 (WebKit::StorageNamespaceImpl::copy): 17 * WebProcess/Storage/StorageNamespaceImpl.h: 18 19 * WebProcess/Storage/WebStorageNamespaceProvider.cpp: 20 (WebKit::WebStorageNamespaceProvider::createEphemeralLocalStorageNamespace): 21 * WebProcess/Storage/WebStorageNamespaceProvider.h: 22 1 23 2017-04-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 24 -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp
r214680 r215315 84 84 WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateSessionStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0); 85 85 break; 86 87 case StorageType::EphemeralLocal: 88 // The UI process is not involved for EphemeralLocal storages. 89 return; 86 90 } 87 91 … … 91 95 StorageAreaMap::~StorageAreaMap() 92 96 { 93 WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::DestroyStorageMap(m_storageMapID), 0); 94 WebProcess::singleton().removeMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID); 97 if (m_storageType != StorageType::EphemeralLocal) { 98 WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::DestroyStorageMap(m_storageMapID), 0); 99 WebProcess::singleton().removeMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID); 100 } 95 101 96 102 m_storageNamespace->didDestroyStorageAreaMap(*this); -
trunk/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp
r214680 r215315 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #include "WebPageGroupProxy.h" 33 33 #include "WebProcess.h" 34 #include <WebCore/Frame.h> 34 35 #include <WebCore/PageGroup.h> 35 36 #include <WebCore/SecurityOrigin.h> … … 44 45 { 45 46 return adoptRef(new StorageNamespaceImpl(StorageType::Session, identifier, nullptr, quotaInBytes)); 47 } 48 49 RefPtr<StorageNamespaceImpl> StorageNamespaceImpl::createEphemeralLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes) 50 { 51 return adoptRef(new StorageNamespaceImpl(StorageType::EphemeralLocal, identifier, nullptr, quotaInBytes)); 46 52 } 47 53 … … 75 81 RefPtr<StorageArea> StorageNamespaceImpl::storageArea(const SecurityOriginData& securityOrigin) 76 82 { 83 if (m_storageType == StorageType::EphemeralLocal) 84 return ephemeralLocalStorageArea(securityOrigin); 85 77 86 RefPtr<StorageAreaMap> map; 78 87 … … 87 96 } 88 97 98 class StorageNamespaceImpl::EphemeralStorageArea final : public StorageArea { 99 public: 100 static Ref<EphemeralStorageArea> create(const SecurityOriginData& origin, unsigned quotaInBytes) 101 { 102 return adoptRef(*new EphemeralStorageArea(origin, quotaInBytes)); 103 } 104 105 Ref<EphemeralStorageArea> copy() 106 { 107 return adoptRef(*new EphemeralStorageArea(*this)); 108 } 109 110 private: 111 EphemeralStorageArea(const SecurityOriginData& origin, unsigned quotaInBytes) 112 : m_securityOriginData(origin) 113 , m_storageMap(StorageMap::create(quotaInBytes)) 114 { 115 } 116 117 EphemeralStorageArea(EphemeralStorageArea& other) 118 : m_securityOriginData(other.m_securityOriginData) 119 , m_storageMap(other.m_storageMap) 120 { 121 } 122 123 // WebCore::StorageArea. 124 unsigned length() 125 { 126 return m_storageMap->length(); 127 } 128 129 String key(unsigned index) 130 { 131 return m_storageMap->key(index); 132 } 133 134 String item(const String& key) 135 { 136 return m_storageMap->getItem(key); 137 } 138 139 void setItem(Frame*, const String& key, const String& value, bool& quotaException) 140 { 141 String oldValue; 142 if (auto newMap = m_storageMap->setItem(key, value, oldValue, quotaException)) 143 m_storageMap = WTFMove(newMap); 144 } 145 146 void removeItem(Frame*, const String& key) 147 { 148 String oldValue; 149 if (auto newMap = m_storageMap->removeItem(key, oldValue)) 150 m_storageMap = WTFMove(newMap); 151 } 152 153 void clear(Frame*) 154 { 155 if (!m_storageMap->length()) 156 return; 157 158 m_storageMap = StorageMap::create(m_storageMap->quota()); 159 } 160 161 bool contains(const String& key) 162 { 163 return m_storageMap->contains(key); 164 } 165 166 bool canAccessStorage(Frame* frame) 167 { 168 return frame && frame->page(); 169 } 170 171 StorageType storageType() const 172 { 173 return StorageType::EphemeralLocal; 174 } 175 176 size_t memoryBytesUsedByCache() 177 { 178 return 0; 179 } 180 181 void incrementAccessCount() { } 182 void decrementAccessCount() { } 183 void closeDatabaseIfIdle() { } 184 185 SecurityOriginData securityOrigin() const 186 { 187 return m_securityOriginData; 188 } 189 190 SecurityOriginData m_securityOriginData; 191 RefPtr<StorageMap> m_storageMap; 192 }; 193 194 RefPtr<StorageArea> StorageNamespaceImpl::ephemeralLocalStorageArea(const SecurityOriginData& securityOrigin) 195 { 196 auto& slot = m_ephemeralLocalStorageAreas.add(securityOrigin, nullptr).iterator->value; 197 if (!slot) 198 slot = StorageNamespaceImpl::EphemeralStorageArea::create(securityOrigin, m_quotaInBytes); 199 200 return slot.get(); 201 } 202 89 203 RefPtr<StorageNamespace> StorageNamespaceImpl::copy(Page* newPage) 90 204 { 91 205 ASSERT(m_storageNamespaceID); 92 206 93 return createSessionStorageNamespace(WebPage::fromCorePage(newPage)->pageID(), m_quotaInBytes); 207 if (m_storageType == StorageType::Session) 208 return createSessionStorageNamespace(WebPage::fromCorePage(newPage)->pageID(), m_quotaInBytes); 209 210 ASSERT(m_storageType == StorageType::EphemeralLocal); 211 RefPtr<StorageNamespaceImpl> newNamespace = adoptRef(new StorageNamespaceImpl(m_storageType, m_storageNamespaceID, m_topLevelOrigin.get(), m_quotaInBytes)); 212 213 for (auto& iter : m_ephemeralLocalStorageAreas) 214 newNamespace->m_ephemeralLocalStorageAreas.set(iter.key, iter.value->copy()); 215 216 return newNamespace; 94 217 } 95 218 -
trunk/Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.h
r208727 r215315 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #include <WebCore/SecurityOriginHash.h> 30 30 #include <WebCore/StorageArea.h> 31 #include <WebCore/StorageMap.h> 31 32 #include <WebCore/StorageNamespace.h> 32 33 #include <wtf/HashMap.h> … … 40 41 public: 41 42 static RefPtr<StorageNamespaceImpl> createSessionStorageNamespace(uint64_t identifier, unsigned quotaInBytes); 43 static RefPtr<StorageNamespaceImpl> createEphemeralLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes); 42 44 static RefPtr<StorageNamespaceImpl> createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes); 43 45 static RefPtr<StorageNamespaceImpl> createTransientLocalStorageNamespace(uint64_t identifier, WebCore::SecurityOrigin& topLevelOrigin, uint64_t quotaInBytes); … … 58 60 RefPtr<WebCore::StorageNamespace> copy(WebCore::Page*) override; 59 61 62 RefPtr<WebCore::StorageArea> ephemeralLocalStorageArea(const WebCore::SecurityOriginData&); 63 60 64 const WebCore::StorageType m_storageType; 61 65 const uint64_t m_storageNamespaceID; … … 67 71 68 72 HashMap<WebCore::SecurityOriginData, StorageAreaMap*> m_storageAreaMaps; 73 74 class EphemeralStorageArea; 75 HashMap<WebCore::SecurityOriginData, RefPtr<EphemeralStorageArea>> m_ephemeralLocalStorageAreas; 69 76 }; 70 77 -
trunk/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.cpp
r177810 r215315 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 72 72 } 73 73 74 RefPtr<WebCore::StorageNamespace> WebStorageNamespaceProvider::createEphemeralLocalStorageNamespace(Page& page, unsigned quota) 75 { 76 return StorageNamespaceImpl::createEphemeralLocalStorageNamespace(WebPage::fromCorePage(&page)->pageID(), quota); 77 } 78 74 79 RefPtr<WebCore::StorageNamespace> WebStorageNamespaceProvider::createLocalStorageNamespace(unsigned quota) 75 80 { -
trunk/Source/WebKit2/WebProcess/Storage/WebStorageNamespaceProvider.h
r197563 r215315 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 41 41 RefPtr<WebCore::StorageNamespace> createSessionStorageNamespace(WebCore::Page&, unsigned quota) override; 42 RefPtr<WebCore::StorageNamespace> createEphemeralLocalStorageNamespace(WebCore::Page&, unsigned quota) override; 42 43 RefPtr<WebCore::StorageNamespace> createLocalStorageNamespace(unsigned quota) override; 43 44 RefPtr<WebCore::StorageNamespace> createTransientLocalStorageNamespace(WebCore::SecurityOrigin&, unsigned quota) override;
Note: See TracChangeset
for help on using the changeset viewer.