| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "core/dom/AXObjectCache.h" | 29 #include "core/dom/AXObjectCache.h" |
| 30 | 30 |
| 31 #include "wtf/PtrUtil.h" |
| 32 #include <memory> |
| 33 |
| 31 namespace blink { | 34 namespace blink { |
| 32 | 35 |
| 33 AXObjectCache::AXObjectCacheCreateFunction AXObjectCache::m_createFunction = nul
lptr; | 36 AXObjectCache::AXObjectCacheCreateFunction AXObjectCache::m_createFunction = nul
lptr; |
| 34 | 37 |
| 35 void AXObjectCache::init(AXObjectCacheCreateFunction function) | 38 void AXObjectCache::init(AXObjectCacheCreateFunction function) |
| 36 { | 39 { |
| 37 DCHECK(!m_createFunction); | 40 DCHECK(!m_createFunction); |
| 38 m_createFunction = function; | 41 m_createFunction = function; |
| 39 } | 42 } |
| 40 | 43 |
| 41 AXObjectCache* AXObjectCache::create(Document& document) | 44 AXObjectCache* AXObjectCache::create(Document& document) |
| 42 { | 45 { |
| 43 DCHECK(m_createFunction); | 46 DCHECK(m_createFunction); |
| 44 return m_createFunction(document); | 47 return m_createFunction(document); |
| 45 } | 48 } |
| 46 | 49 |
| 47 AXObjectCache::AXObjectCache() | 50 AXObjectCache::AXObjectCache() |
| 48 { | 51 { |
| 49 } | 52 } |
| 50 | 53 |
| 51 AXObjectCache::~AXObjectCache() | 54 AXObjectCache::~AXObjectCache() |
| 52 { | 55 { |
| 53 } | 56 } |
| 54 | 57 |
| 55 PassOwnPtr<ScopedAXObjectCache> ScopedAXObjectCache::create(Document& document) | 58 std::unique_ptr<ScopedAXObjectCache> ScopedAXObjectCache::create(Document& docum
ent) |
| 56 { | 59 { |
| 57 return adoptPtr(new ScopedAXObjectCache(document)); | 60 return wrapUnique(new ScopedAXObjectCache(document)); |
| 58 } | 61 } |
| 59 | 62 |
| 60 ScopedAXObjectCache::ScopedAXObjectCache(Document& document) | 63 ScopedAXObjectCache::ScopedAXObjectCache(Document& document) |
| 61 : m_document(&document) | 64 : m_document(&document) |
| 62 { | 65 { |
| 63 if (!m_document->axObjectCache()) | 66 if (!m_document->axObjectCache()) |
| 64 m_cache = AXObjectCache::create(*m_document); | 67 m_cache = AXObjectCache::create(*m_document); |
| 65 } | 68 } |
| 66 | 69 |
| 67 ScopedAXObjectCache::~ScopedAXObjectCache() | 70 ScopedAXObjectCache::~ScopedAXObjectCache() |
| 68 { | 71 { |
| 69 if (m_cache) | 72 if (m_cache) |
| 70 m_cache->dispose(); | 73 m_cache->dispose(); |
| 71 } | 74 } |
| 72 | 75 |
| 73 AXObjectCache* ScopedAXObjectCache::get() | 76 AXObjectCache* ScopedAXObjectCache::get() |
| 74 { | 77 { |
| 75 if (m_cache) | 78 if (m_cache) |
| 76 return m_cache.get(); | 79 return m_cache.get(); |
| 77 AXObjectCache* cache = m_document->axObjectCache(); | 80 AXObjectCache* cache = m_document->axObjectCache(); |
| 78 DCHECK(cache); | 81 DCHECK(cache); |
| 79 return cache; | 82 return cache; |
| 80 } | 83 } |
| 81 | 84 |
| 82 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |