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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 // This is incredibly unsafe: the handle is valid only when this | 83 // This is incredibly unsafe: the handle is valid only when this |
84 // UnsafePersistent is alive and valid (see class level comment). | 84 // UnsafePersistent is alive and valid (see class level comment). |
85 v8::Persistent<T>* persistent() | 85 v8::Persistent<T>* persistent() |
86 { | 86 { |
87 v8::Persistent<T>* handle = reinterpret_cast<v8::Persistent<T>*>(&m_valu
e); | 87 v8::Persistent<T>* handle = reinterpret_cast<v8::Persistent<T>*>(&m_valu
e); |
88 return handle; | 88 return handle; |
89 } | 89 } |
90 | 90 |
| 91 void setReferenceFrom(const v8::Persistent<v8::Object>& parent, v8::Isolate*
isolate) |
| 92 { |
| 93 // FIXME: remove As() after v8 roll. |
| 94 isolate->SetReference(parent, persistent()->template As<v8::Value>()); |
| 95 } |
| 96 |
91 void dispose() | 97 void dispose() |
92 { | 98 { |
93 persistent()->Dispose(); | 99 persistent()->Dispose(); |
94 m_value = 0; | 100 m_value = 0; |
95 } | 101 } |
96 | 102 |
97 void clear() | 103 void clear() |
98 { | 104 { |
99 m_value = 0; | 105 m_value = 0; |
100 } | 106 } |
(...skipping 14 matching lines...) Expand all Loading... |
115 v8::Handle<T>* handle = reinterpret_cast<v8::Handle<T>*>(&m_value); | 121 v8::Handle<T>* handle = reinterpret_cast<v8::Handle<T>*>(&m_value); |
116 return *handle; | 122 return *handle; |
117 } | 123 } |
118 | 124 |
119 T* m_value; | 125 T* m_value; |
120 }; | 126 }; |
121 | 127 |
122 } // namespace WebCore | 128 } // namespace WebCore |
123 | 129 |
124 #endif // UnsafePersistent_h | 130 #endif // UnsafePersistent_h |
OLD | NEW |