| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ASSERT(!m_stringCache.contains(stringImpl)); | 87 ASSERT(!m_stringCache.contains(stringImpl)); |
| 88 ASSERT(stringImpl->length()); | 88 ASSERT(stringImpl->length()); |
| 89 | 89 |
| 90 v8::Local<v8::String> newString = makeExternalString(String(stringImpl)); | 90 v8::Local<v8::String> newString = makeExternalString(String(stringImpl)); |
| 91 if (newString.IsEmpty()) | 91 if (newString.IsEmpty()) |
| 92 return newString; | 92 return newString; |
| 93 | 93 |
| 94 v8::Persistent<v8::String> wrapper(isolate, newString); | 94 v8::Persistent<v8::String> wrapper(isolate, newString); |
| 95 | 95 |
| 96 stringImpl->ref(); | 96 stringImpl->ref(); |
| 97 wrapper.MarkIndependent(isolate); | 97 wrapper.MarkIndependent(); |
| 98 wrapper.MakeWeak(stringImpl, &makeWeakCallback); | 98 wrapper.MakeWeak(stringImpl, &makeWeakCallback); |
| 99 m_lastV8String = UnsafePersistent<v8::String>(wrapper); | 99 m_lastV8String = UnsafePersistent<v8::String>(wrapper); |
| 100 m_lastStringImpl = stringImpl; | 100 m_lastStringImpl = stringImpl; |
| 101 m_stringCache.set(stringImpl, m_lastV8String); | 101 m_stringCache.set(stringImpl, m_lastV8String); |
| 102 | 102 |
| 103 return newString; | 103 return newString; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void StringCache::makeWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Stri
ng>* wrapper, StringImpl* stringImpl) | 106 void StringCache::makeWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Stri
ng>* wrapper, StringImpl* stringImpl) |
| 107 { | 107 { |
| 108 StringCache* stringCache = V8PerIsolateData::from(isolate)->stringCache(); | 108 StringCache* stringCache = V8PerIsolateData::from(isolate)->stringCache(); |
| 109 stringCache->m_lastStringImpl = 0; | 109 stringCache->m_lastStringImpl = 0; |
| 110 stringCache->m_lastV8String.clear(); | 110 stringCache->m_lastV8String.clear(); |
| 111 ASSERT(stringCache->m_stringCache.contains(stringImpl)); | 111 ASSERT(stringCache->m_stringCache.contains(stringImpl)); |
| 112 stringCache->m_stringCache.remove(stringImpl); | 112 stringCache->m_stringCache.remove(stringImpl); |
| 113 stringImpl->deref(); | 113 stringImpl->deref(); |
| 114 wrapper->Dispose(isolate); | 114 wrapper->Dispose(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace WebCore | 117 } // namespace WebCore |
| OLD | NEW |