| 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 15 matching lines...) Expand all Loading... |
| 26 #ifndef ResourcePtr_h | 26 #ifndef ResourcePtr_h |
| 27 #define ResourcePtr_h | 27 #define ResourcePtr_h |
| 28 | 28 |
| 29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/fetch/Resource.h" | 30 #include "core/fetch/Resource.h" |
| 31 #include "wtf/Allocator.h" | 31 #include "wtf/Allocator.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class CORE_EXPORT ResourcePtrBase { | 35 class CORE_EXPORT ResourcePtrBase { |
| 36 ALLOW_ONLY_INLINE_ALLOCATION(); | 36 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 37 public: | 37 public: |
| 38 Resource* get() const { return m_resource; } | 38 Resource* get() const { return m_resource; } |
| 39 bool operator!() const { return !m_resource; } | 39 bool operator!() const { return !m_resource; } |
| 40 void clear() { setResource(nullptr); } | 40 void clear() { setResource(nullptr); } |
| 41 | 41 |
| 42 // This conversion operator allows implicit conversion to bool but not to ot
her integer types. | 42 // This conversion operator allows implicit conversion to bool but not to ot
her integer types. |
| 43 typedef Resource* ResourcePtrBase::*UnspecifiedBoolType; | 43 typedef Resource* ResourcePtrBase::*UnspecifiedBoolType; |
| 44 operator UnspecifiedBoolType() const { return m_resource ? &ResourcePtrBase:
:m_resource : nullptr; } | 44 operator UnspecifiedBoolType() const { return m_resource ? &ResourcePtrBase:
:m_resource : nullptr; } |
| 45 | 45 |
| 46 protected: | 46 protected: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 { | 113 { |
| 114 return h.get() != res; | 114 return h.get() != res; |
| 115 } | 115 } |
| 116 template <class R, class RR> bool operator!=(const RR* res, const ResourcePtr<R>
& h) | 116 template <class R, class RR> bool operator!=(const RR* res, const ResourcePtr<R>
& h) |
| 117 { | 117 { |
| 118 return h.get() != res; | 118 return h.get() != res; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 #endif | 122 #endif |
| OLD | NEW |