| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2014 Google Inc. All rights reserved. | 2  * Copyright (C) 2014 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 891         if (m_object) | 891         if (m_object) | 
| 892             m_object->dispose(); | 892             m_object->dispose(); | 
| 893     } | 893     } | 
| 894 | 894 | 
| 895     void clear() { m_object.clear(); } | 895     void clear() { m_object.clear(); } | 
| 896 | 896 | 
| 897 private: | 897 private: | 
| 898     Member<T> m_object; | 898     Member<T> m_object; | 
| 899 }; | 899 }; | 
| 900 | 900 | 
|  | 901 // SelfKeepAlive<Object> is the idiom to use for objects that have to keep | 
|  | 902 // themselves temporarily alive and cannot rely on there being some | 
|  | 903 // external reference in that interval: | 
|  | 904 // | 
|  | 905 //  class Opener { | 
|  | 906 //  public: | 
|  | 907 //     ... | 
|  | 908 //     void open() | 
|  | 909 //     { | 
|  | 910 //         // Retain a self-reference while in an open()ed state: | 
|  | 911 //         m_keepAlive = this; | 
|  | 912 //         .... | 
|  | 913 //     } | 
|  | 914 // | 
|  | 915 //     void close() | 
|  | 916 //     { | 
|  | 917 //         // Clear self-reference that ensured we were kept alive while opened. | 
|  | 918 //         m_keepAlive.clear(); | 
|  | 919 //         .... | 
|  | 920 //     } | 
|  | 921 // | 
|  | 922 //  private: | 
|  | 923 //     ... | 
|  | 924 //     SelfKeepAlive m_keepAlive; | 
|  | 925 //  }; | 
|  | 926 // | 
|  | 927 // The responsibility to call clear() in a timely fashion resides with the imple
      mentation | 
|  | 928 // of the object. | 
|  | 929 // | 
|  | 930 // | 
|  | 931 template<typename Self> | 
|  | 932 class SelfKeepAlive { | 
|  | 933 public: | 
|  | 934     SelfKeepAlive& operator=(Self* self) | 
|  | 935     { | 
|  | 936         ASSERT(!m_keepAlive || m_keepAlive.get() == self); | 
|  | 937         m_keepAlive = self; | 
|  | 938         return *this; | 
|  | 939     } | 
|  | 940 | 
|  | 941     void clear() | 
|  | 942     { | 
|  | 943         m_keepAlive = nullptr; | 
|  | 944     } | 
|  | 945 | 
|  | 946     typedef Persistent<Self> (SelfKeepAlive::*UnspecifiedBoolType); | 
|  | 947     operator UnspecifiedBoolType() const { return m_keepAlive ? &SelfKeepAlive::
      m_keepAlive : 0; } | 
|  | 948 | 
|  | 949 private: | 
|  | 950     GC_PLUGIN_IGNORE("420515") | 
|  | 951     Persistent<Self> m_keepAlive; | 
|  | 952 }; | 
|  | 953 | 
| 901 } // namespace blink | 954 } // namespace blink | 
| 902 | 955 | 
| 903 namespace WTF { | 956 namespace WTF { | 
| 904 | 957 | 
| 905 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b
      link::Member<T>> { | 958 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b
      link::Member<T>> { | 
| 906     static const bool needsDestruction = false; | 959     static const bool needsDestruction = false; | 
| 907     static const bool canInitializeWithMemset = true; | 960     static const bool canInitializeWithMemset = true; | 
| 908     static const bool canClearUnusedSlotsWithMemset = true; | 961     static const bool canClearUnusedSlotsWithMemset = true; | 
| 909     static const bool canMoveWithMemcpy = true; | 962     static const bool canMoveWithMemcpy = true; | 
| 910 }; | 963 }; | 
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1087 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin
      k::IsGarbageCollectedType<T>::value> { | 1140 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin
      k::IsGarbageCollectedType<T>::value> { | 
| 1088     static_assert(sizeof(T), "T must be fully defined"); | 1141     static_assert(sizeof(T), "T must be fully defined"); | 
| 1089 }; | 1142 }; | 
| 1090 | 1143 | 
| 1091 template<typename T> | 1144 template<typename T> | 
| 1092 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1145 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 
| 1093 | 1146 | 
| 1094 } // namespace WTF | 1147 } // namespace WTF | 
| 1095 | 1148 | 
| 1096 #endif | 1149 #endif | 
| OLD | NEW | 
|---|