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

Unified Diff: Source/core/dom/AXObjectCache.cpp

Issue 1167983002: Remove raw pointer member to AXObjectCache Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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/dom/AXObjectCache.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/AXObjectCache.cpp
diff --git a/Source/core/dom/AXObjectCache.cpp b/Source/core/dom/AXObjectCache.cpp
index 340616585a1efceb73bd691051ee2524ed4b56dc..5abb6fc9aeea0aa7a6389e530e77b575d3ba10d0 100644
--- a/Source/core/dom/AXObjectCache.cpp
+++ b/Source/core/dom/AXObjectCache.cpp
@@ -40,7 +40,7 @@ void AXObjectCache::init(AXObjectCacheCreateFunction function)
m_createFunction = function;
}
-AXObjectCache* AXObjectCache::create(Document& document)
+PassOwnPtr<AXObjectCache> AXObjectCache::create(Document& document)
{
ASSERT(m_createFunction);
return (m_createFunction)(document);
@@ -54,34 +54,25 @@ AXObjectCache::~AXObjectCache()
{
}
-ScopedAXObjectCache::ScopedAXObjectCache(Document& document)
- : m_document(document)
- , m_cache(0)
+PassOwnPtr<ScopedAXObjectCache> ScopedAXObjectCache::create(Document& document)
{
- if (AXObjectCache* existingCache = document.axObjectCache()) {
- m_cache = existingCache;
- m_isScoped = false;
- } else {
- m_isScoped = true;
- m_cache = AXObjectCache::create(m_document);
- }
+ return adoptPtr(new ScopedAXObjectCache(document));
}
-ScopedAXObjectCache::~ScopedAXObjectCache()
+ScopedAXObjectCache::ScopedAXObjectCache(Document& document)
+ : m_document(&document)
{
- if (m_isScoped)
- delete m_cache;
+ if (!m_document->axObjectCache())
+ m_cache = AXObjectCache::create(*m_document);
}
AXObjectCache* ScopedAXObjectCache::get()
{
- ASSERT(m_cache);
- return m_cache;
-}
-
-AXObjectCache* ScopedAXObjectCache::operator->()
-{
- return get();
+ if (m_cache)
+ return m_cache.get();
+ AXObjectCache* cache = m_document->axObjectCache();
+ ASSERT(cache);
+ return cache;
}
} // namespace blink
« no previous file with comments | « Source/core/dom/AXObjectCache.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698