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 return newString; | 49 return newString; |
50 } | 50 } |
51 | 51 |
52 void StringCache::makeWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Stri
ng>* wrapper, StringImpl* stringImpl) | 52 void StringCache::makeWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Stri
ng>* wrapper, StringImpl* stringImpl) |
53 { | 53 { |
54 V8PerIsolateData::current()->stringCache()->remove(stringImpl); | 54 V8PerIsolateData::current()->stringCache()->remove(stringImpl); |
55 wrapper->Dispose(isolate); | 55 wrapper->Dispose(isolate); |
56 stringImpl->deref(); | 56 stringImpl->deref(); |
57 } | 57 } |
58 | 58 |
59 void StringCache::remove(StringImpl* stringImpl) | 59 void StringCache::remove(StringImpl* stringImpl) |
60 { | 60 { |
61 ASSERT(m_stringCache.contains(stringImpl)); | 61 ASSERT(m_stringCache.contains(stringImpl)); |
62 m_stringCache.remove(stringImpl); | 62 m_stringCache.remove(stringImpl); |
63 // Make sure that already disposed m_lastV8String is not used in | 63 // Make sure that already disposed m_lastV8String is not used in |
64 // StringCache::v8ExternalString(). | 64 // StringCache::v8ExternalString(). |
65 clearOnGC(); | 65 clearOnGC(); |
66 } | 66 } |
67 | 67 |
68 v8::Handle<v8::String> StringCache::v8ExternalStringSlow(StringImpl* stringImpl,
v8::Isolate* isolate) | 68 v8::Handle<v8::String> StringCache::v8ExternalStringSlow(StringImpl* stringImpl,
v8::Isolate* isolate) |
69 { | 69 { |
(...skipping 23 matching lines...) Expand all Loading... |
93 wrapper.MarkIndependent(isolate); | 93 wrapper.MarkIndependent(isolate); |
94 wrapper.MakeWeak(stringImpl, &makeWeakCallback); | 94 wrapper.MakeWeak(stringImpl, &makeWeakCallback); |
95 m_lastV8String = UnsafePersistent<v8::String>(wrapper); | 95 m_lastV8String = UnsafePersistent<v8::String>(wrapper); |
96 m_stringCache.set(stringImpl, m_lastV8String); | 96 m_stringCache.set(stringImpl, m_lastV8String); |
97 | 97 |
98 m_lastStringImpl = stringImpl; | 98 m_lastStringImpl = stringImpl; |
99 return newString; | 99 return newString; |
100 } | 100 } |
101 | 101 |
102 } // namespace WebCore | 102 } // namespace WebCore |
OLD | NEW |