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

Unified Diff: Source/platform/heap/Handle.h

Issue 1263313003: Oilpan: lazily create SelfKeepAlive<>'s persistent reference. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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/platform/heap/Handle.h
diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h
index 13d407d00b1ca7bff6933d27f2c49a69647b39b6..d3a1cc23de41db114edbae4e6c19e368a1bde476 100644
--- a/Source/platform/heap/Handle.h
+++ b/Source/platform/heap/Handle.h
@@ -931,24 +931,40 @@ private:
template<typename Self>
class SelfKeepAlive {
public:
+ SelfKeepAlive()
+ {
+ }
+
+ explicit SelfKeepAlive(Self* self)
+ {
+ assign(self);
+ }
+
SelfKeepAlive& operator=(Self* self)
{
- ASSERT(!m_keepAlive || m_keepAlive.get() == self);
- m_keepAlive = self;
+ assign(self);
return *this;
}
void clear()
{
- m_keepAlive = nullptr;
+ m_keepAlive.clear();
}
- typedef Persistent<Self> (SelfKeepAlive::*UnspecifiedBoolType);
+ typedef OwnPtr<Persistent<Self>> (SelfKeepAlive::*UnspecifiedBoolType);
operator UnspecifiedBoolType() const { return m_keepAlive ? &SelfKeepAlive::m_keepAlive : 0; }
private:
+ void assign(Self* self)
+ {
+ ASSERT(!m_keepAlive || m_keepAlive->get() == self);
+ if (!m_keepAlive)
+ m_keepAlive = adoptPtr(new Persistent<Self>);
+ *m_keepAlive = self;
+ }
+
GC_PLUGIN_IGNORE("420515")
- Persistent<Self> m_keepAlive;
+ OwnPtr<Persistent<Self>> m_keepAlive;
};
} // namespace blink
« 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