OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 visitor->trace(m_resource); | 69 visitor->trace(m_resource); |
70 ResourceOwnerBase<C, std::is_base_of<GarbageCollectedMixin, C>::value>::
trace(visitor); | 70 ResourceOwnerBase<C, std::is_base_of<GarbageCollectedMixin, C>::value>::
trace(visitor); |
71 } | 71 } |
72 | 72 |
73 protected: | 73 protected: |
74 ResourceOwner() | 74 ResourceOwner() |
75 { | 75 { |
76 ThreadState::current()->registerPreFinalizer(this); | 76 ThreadState::current()->registerPreFinalizer(this); |
77 } | 77 } |
78 | 78 |
79 void setResource(ResourceType*); | 79 void setResource(ResourceType*, Resource::PreloadReferencePolicy = Resource:
:MarkAsReferenced); |
80 void clearResource() { setResource(nullptr); } | 80 void clearResource() { setResource(nullptr); } |
81 | 81 |
82 private: | 82 private: |
83 Member<ResourceType> m_resource; | 83 Member<ResourceType> m_resource; |
84 }; | 84 }; |
85 | 85 |
86 template<class R, class C> | 86 template<class R, class C> |
87 inline void ResourceOwner<R, C>::setResource(R* newResource) | 87 inline void ResourceOwner<R, C>::setResource(R* newResource, Resource::PreloadRe
ferencePolicy preloadReferencePolicy) |
88 { | 88 { |
89 if (newResource == m_resource) | 89 if (newResource == m_resource) |
90 return; | 90 return; |
91 | 91 |
92 // Some ResourceClient implementations reenter this so | 92 // Some ResourceClient implementations reenter this so |
93 // we need to prevent double removal. | 93 // we need to prevent double removal. |
94 if (ResourceType* oldResource = m_resource.release()) | 94 if (ResourceType* oldResource = m_resource.release()) |
95 oldResource->removeClient(this); | 95 oldResource->removeClient(this); |
96 | 96 |
97 if (newResource) { | 97 if (newResource) { |
98 m_resource = newResource; | 98 m_resource = newResource; |
99 m_resource->addClient(this); | 99 m_resource->addClient(this, preloadReferencePolicy); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 } // namespace blink | 103 } // namespace blink |
104 | 104 |
105 #endif | 105 #endif |
OLD | NEW |