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

Side by Side Diff: Source/core/dom/AXObjectCache.cpp

Issue 1072273006: Oilpan: Prepare moving AXObject to heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
OLDNEW
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
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 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 ScopedAXObjectCache::ScopedAXObjectCache(Document& document) 57 ScopedAXObjectCache::ScopedAXObjectCache(Document& document)
58 : m_document(document) 58 #if ENABLE(OILPAN)
59 , m_cache(0) 59 : m_isOwned(false)
60 #else
61 : m_ownedCache(nullptr)
62 #endif
63 , m_cache(nullptr)
60 { 64 {
61 if (AXObjectCache* existingCache = document.axObjectCache()) { 65 if (AXObjectCache* existingCache = document.axObjectCache()) {
62 m_cache = existingCache; 66 m_cache = existingCache;
63 m_isScoped = false;
64 } else { 67 } else {
65 m_isScoped = true; 68 #if ENABLE(OILPAN)
66 m_cache = AXObjectCache::create(m_document); 69 m_isOwned = true;
70 m_cache = AXObjectCache::create(document);
71 #else
72 m_ownedCache = AXObjectCache::create(document);
73 m_cache = m_ownedCache.get();
74 #endif
67 } 75 }
68 } 76 }
69 77
70 ScopedAXObjectCache::~ScopedAXObjectCache() 78 ScopedAXObjectCache::~ScopedAXObjectCache()
71 { 79 {
72 if (m_isScoped) 80 #if ENABLE(OILPAN)
73 delete m_cache; 81 if (m_isOwned) {
82 #else
83 if (m_ownedCache) {
84 #endif
85 m_cache->dispose();
86 }
74 } 87 }
75 88
76 AXObjectCache* ScopedAXObjectCache::get() 89 AXObjectCache* ScopedAXObjectCache::get()
77 { 90 {
78 ASSERT(m_cache); 91 ASSERT(m_cache);
79 return m_cache; 92 return m_cache;
80 } 93 }
81 94
82 AXObjectCache* ScopedAXObjectCache::operator->() 95 AXObjectCache* ScopedAXObjectCache::operator->()
83 { 96 {
84 return get(); 97 return get();
85 } 98 }
86 99
87 } // namespace blink 100 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698