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

Unified Diff: Source/core/inspector/PromiseTracker.cpp

Issue 571043002: Oilpan: handle delayed removal of PromiseTracker promises. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make promiseHash map lookup more reliable 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/PromiseTracker.cpp
diff --git a/Source/core/inspector/PromiseTracker.cpp b/Source/core/inspector/PromiseTracker.cpp
index b7d9a1f7feffcdd7a703a5ac282b90665f7a4160..3787eda37caf4bbee8031b1464569f33ae202134 100644
--- a/Source/core/inspector/PromiseTracker.cpp
+++ b/Source/core/inspector/PromiseTracker.cpp
@@ -27,7 +27,13 @@ public:
int promiseHash() const { return m_promiseHash; }
ScopedPersistent<v8::Object>& promise() { return m_promise; }
-#if !ENABLE(OILPAN)
+#if ENABLE(OILPAN)
+ void dispose()
+ {
+ m_promise.clear();
+ m_parentPromise.clear();
+ }
+#else
WeakPtr<PromiseData> createWeakPtr()
{
return m_weakPtrFactory.createWeakPtr();
@@ -103,9 +109,23 @@ public:
WeakPtrWillBeRawPtr<PromiseTracker::PromiseData> promiseData = wrapper->m_data;
if (!promiseData || !wrapper->m_tracker)
return;
+
+#if ENABLE(OILPAN)
+ // Oilpan: let go of ScopedPersistent<>s right here (and not wait until the
+ // PromiseDataWrapper is GCed later.) The v8 weak callback handling expects
+ // to see the callback data upon return.
+ promiseData->dispose();
+#endif
PromiseTracker::PromiseDataMap& map = wrapper->m_tracker->promiseDataMap();
int promiseHash = promiseData->promiseHash();
- PromiseTracker::PromiseDataVector* vector = &map.find(promiseHash)->value;
+
+ PromiseTracker::PromiseDataMap::iterator it = map.find(promiseHash);
+ // The PromiseTracker may have been disabled (and, possibly, re-enabled later),
+ // leaving the promiseHash as unmapped.
+ if (it == map.end())
+ return;
+
+ PromiseTracker::PromiseDataVector* vector = &it->value;
int index = indexOf(vector, promiseData->promise());
ASSERT(index >= 0);
vector->remove(index);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698