OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 23 matching lines...) Expand all Loading... |
34 public: | 34 public: |
35 ~CachedResourceHandleBase() { if (m_resource) m_resource->unregisterHand
le(this); } | 35 ~CachedResourceHandleBase() { if (m_resource) m_resource->unregisterHand
le(this); } |
36 CachedResource* get() const { return m_resource; } | 36 CachedResource* get() const { return m_resource; } |
37 | 37 |
38 bool operator!() const { return !m_resource; } | 38 bool operator!() const { return !m_resource; } |
39 | 39 |
40 // This conversion operator allows implicit conversion to bool but not t
o other integer types. | 40 // This conversion operator allows implicit conversion to bool but not t
o other integer types. |
41 typedef CachedResource* CachedResourceHandleBase::*UnspecifiedBoolType; | 41 typedef CachedResource* CachedResourceHandleBase::*UnspecifiedBoolType; |
42 operator UnspecifiedBoolType() const { return m_resource ? &CachedResour
ceHandleBase::m_resource : 0; } | 42 operator UnspecifiedBoolType() const { return m_resource ? &CachedResour
ceHandleBase::m_resource : 0; } |
43 | 43 |
44 void reportMemoryUsage(MemoryObjectInfo*) const; | |
45 | |
46 protected: | 44 protected: |
47 CachedResourceHandleBase() : m_resource(0) {} | 45 CachedResourceHandleBase() : m_resource(0) {} |
48 CachedResourceHandleBase(CachedResource* res) { m_resource = res; if (m_
resource) m_resource->registerHandle(this); } | 46 CachedResourceHandleBase(CachedResource* res) { m_resource = res; if (m_
resource) m_resource->registerHandle(this); } |
49 CachedResourceHandleBase(const CachedResourceHandleBase& o) : m_resource
(o.m_resource) { if (m_resource) m_resource->registerHandle(this); } | 47 CachedResourceHandleBase(const CachedResourceHandleBase& o) : m_resource
(o.m_resource) { if (m_resource) m_resource->registerHandle(this); } |
50 | 48 |
51 void setResource(CachedResource*); | 49 void setResource(CachedResource*); |
52 | 50 |
53 private: | 51 private: |
54 CachedResourceHandleBase& operator=(const CachedResourceHandleBase&) { r
eturn *this; } | 52 CachedResourceHandleBase& operator=(const CachedResourceHandleBase&) { r
eturn *this; } |
55 | 53 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 { | 86 { |
89 return h.get() != res; | 87 return h.get() != res; |
90 } | 88 } |
91 template <class R, class RR> bool operator!=(const RR* res, const CachedReso
urceHandle<R>& h) | 89 template <class R, class RR> bool operator!=(const RR* res, const CachedReso
urceHandle<R>& h) |
92 { | 90 { |
93 return h.get() != res; | 91 return h.get() != res; |
94 } | 92 } |
95 } | 93 } |
96 | 94 |
97 #endif | 95 #endif |
OLD | NEW |