Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Unified Diff: Source/core/storage/StorageArea.cpp

Issue 594083002: Make StorageArea cleanly observe its cached frame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make FrameDestructionObserver::observeFrame() protected again Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/storage/StorageArea.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/storage/StorageArea.cpp
diff --git a/Source/core/storage/StorageArea.cpp b/Source/core/storage/StorageArea.cpp
index ee5dfc3aa9e6ea77a8ddc814d5a34d6364a08c4a..6e8aab6103baef118e957ee6deb1f4748f67155f 100644
--- a/Source/core/storage/StorageArea.cpp
+++ b/Source/core/storage/StorageArea.cpp
@@ -51,9 +51,9 @@ PassOwnPtrWillBeRawPtr<StorageArea> StorageArea::create(PassOwnPtr<WebStorageAre
}
StorageArea::StorageArea(PassOwnPtr<WebStorageArea> storageArea, StorageType storageType)
- : m_storageArea(storageArea)
+ : FrameDestructionObserver(nullptr)
+ , m_storageArea(storageArea)
, m_storageType(storageType)
- , m_canAccessStorageCachedFrame(nullptr)
, m_canAccessStorageCachedResult(false)
{
}
@@ -64,7 +64,7 @@ StorageArea::~StorageArea()
void StorageArea::trace(Visitor* visitor)
{
- visitor->trace(m_canAccessStorageCachedFrame);
+ FrameDestructionObserver::trace(visitor);
}
unsigned StorageArea::length(ExceptionState& exceptionState, LocalFrame* frame)
@@ -137,10 +137,15 @@ bool StorageArea::canAccessStorage(LocalFrame* frame)
{
if (!frame || !frame->page())
return false;
- if (m_canAccessStorageCachedFrame == frame)
+
+ // FrameDestructionObserver is used to safely keep the cached
+ // reference to the LocalFrame. Should the LocalFrame die before
+ // this StorageArea does, that cached reference will be cleared.
+ if (m_frame == frame)
return m_canAccessStorageCachedResult;
bool result = frame->page()->storageClient().canAccessStorage(frame, m_storageType);
- m_canAccessStorageCachedFrame = frame;
+ // Move attention to the new LocalFrame.
+ observeFrame(frame);
m_canAccessStorageCachedResult = result;
return result;
}
« no previous file with comments | « Source/core/storage/StorageArea.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698