| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 template <class T> | 50 template <class T> |
| 51 void setReturnValueFromString(const T& info, StringImpl* stringImpl, v8::Iso
late* isolate) | 51 void setReturnValueFromString(const T& info, StringImpl* stringImpl, v8::Iso
late* isolate) |
| 52 { | 52 { |
| 53 if (m_lastStringImpl.get() == stringImpl && m_lastV8String.isWeak()) | 53 if (m_lastStringImpl.get() == stringImpl && m_lastV8String.isWeak()) |
| 54 info.GetReturnValue().Set(*m_lastV8String.persistent()); | 54 info.GetReturnValue().Set(*m_lastV8String.persistent()); |
| 55 else | 55 else |
| 56 setReturnValueFromStringSlow(info, stringImpl, isolate); | 56 setReturnValueFromStringSlow(info, stringImpl, isolate); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void clearOnGC() | 59 void clearOnGC() |
| 60 { | 60 { |
| 61 m_lastStringImpl = 0; | 61 m_lastStringImpl = 0; |
| 62 m_lastV8String.clear(); | 62 m_lastV8String.clear(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void remove(StringImpl*); | 65 void remove(StringImpl*); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 static v8::Local<v8::String> makeExternalString(const String&); | 68 static v8::Local<v8::String> makeExternalString(const String&); |
| 69 static void makeWeakCallback(v8::Isolate*, v8::Persistent<v8::String>*, Stri
ngImpl*); | 69 static void makeWeakCallback(v8::Isolate*, v8::Persistent<v8::String>*, Stri
ngImpl*); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 99 UnsafePersistent<v8::String> m_lastV8String; | 99 UnsafePersistent<v8::String> m_lastV8String; |
| 100 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity | 100 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity |
| 101 // hence lastStringImpl might be not a key of the cache (in sense of identit
y) | 101 // hence lastStringImpl might be not a key of the cache (in sense of identit
y) |
| 102 // and hence it's not refed on addition. | 102 // and hence it's not refed on addition. |
| 103 RefPtr<StringImpl> m_lastStringImpl; | 103 RefPtr<StringImpl> m_lastStringImpl; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace WebCore | 106 } // namespace WebCore |
| 107 | 107 |
| 108 #endif // V8ValueCache_h | 108 #endif // V8ValueCache_h |
| OLD | NEW |