| 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 22 matching lines...) Expand all Loading... |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 AXObjectCache::AXObjectCacheCreateFunction AXObjectCache::m_createFunction = nul
lptr; | 35 AXObjectCache::AXObjectCacheCreateFunction AXObjectCache::m_createFunction = nul
lptr; |
| 36 | 36 |
| 37 void AXObjectCache::init(AXObjectCacheCreateFunction function) | 37 void AXObjectCache::init(AXObjectCacheCreateFunction function) |
| 38 { | 38 { |
| 39 ASSERT(!m_createFunction); | 39 ASSERT(!m_createFunction); |
| 40 m_createFunction = function; | 40 m_createFunction = function; |
| 41 } | 41 } |
| 42 | 42 |
| 43 PassOwnPtr<AXObjectCache> AXObjectCache::create(Document& document) | 43 PassOwnPtrWillBeRawPtr<AXObjectCache> AXObjectCache::create(Document& document) |
| 44 { | 44 { |
| 45 ASSERT(m_createFunction); | 45 ASSERT(m_createFunction); |
| 46 return (m_createFunction)(document); | 46 return (m_createFunction)(document); |
| 47 } | 47 } |
| 48 | 48 |
| 49 AXObjectCache::AXObjectCache() | 49 AXObjectCache::AXObjectCache() |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 AXObjectCache::~AXObjectCache() | 53 AXObjectCache::~AXObjectCache() |
| 54 { | 54 { |
| 55 } | 55 } |
| 56 | 56 |
| 57 PassOwnPtr<ScopedAXObjectCache> ScopedAXObjectCache::create(Document& document) | 57 PassOwnPtrWillBeRawPtr<ScopedAXObjectCache> ScopedAXObjectCache::create(Document
& document) |
| 58 { | 58 { |
| 59 return adoptPtr(new ScopedAXObjectCache(document)); | 59 return adoptPtrWillBeNoop(new ScopedAXObjectCache(document)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 ScopedAXObjectCache::ScopedAXObjectCache(Document& document) | 62 ScopedAXObjectCache::ScopedAXObjectCache(Document& document) |
| 63 : m_ownedCache(nullptr) | 63 : m_ownedCache(nullptr) |
| 64 , m_cache(nullptr) | 64 , m_cache(nullptr) |
| 65 #if ENABLE(ASSERT) |
| 66 , m_hasBeenDisposed(false) |
| 67 #endif |
| 65 { | 68 { |
| 66 if (AXObjectCache* existingCache = document.axObjectCache()) { | 69 if (AXObjectCache* existingCache = document.axObjectCache()) { |
| 67 m_cache = existingCache; | 70 m_cache = existingCache; |
| 68 } else { | 71 } else { |
| 69 m_ownedCache = AXObjectCache::create(document); | 72 m_ownedCache = AXObjectCache::create(document); |
| 70 m_cache = m_ownedCache.get(); | 73 m_cache = m_ownedCache.get(); |
| 71 } | 74 } |
| 72 } | 75 } |
| 73 | 76 |
| 77 ScopedAXObjectCache::~ScopedAXObjectCache() |
| 78 { |
| 79 ASSERT(m_hasBeenDisposed); |
| 80 } |
| 81 |
| 82 void ScopedAXObjectCache::dispose() |
| 83 { |
| 84 if (m_ownedCache) |
| 85 m_ownedCache->dispose(); |
| 86 #if ENABLE(ASSERT) |
| 87 m_hasBeenDisposed = true; |
| 88 #endif |
| 89 } |
| 90 |
| 74 AXObjectCache* ScopedAXObjectCache::get() | 91 AXObjectCache* ScopedAXObjectCache::get() |
| 75 { | 92 { |
| 76 ASSERT(m_cache); | 93 ASSERT(m_cache); |
| 77 return m_cache; | 94 return m_cache; |
| 78 } | 95 } |
| 79 | 96 |
| 97 DEFINE_TRACE(ScopedAXObjectCache) |
| 98 { |
| 99 visitor->trace(m_ownedCache); |
| 100 visitor->trace(m_cache); |
| 101 } |
| 102 |
| 80 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |