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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 static void DisposeWeak(const v8::WeakCallbackInfo<WeakCallbackDataType>&); | 60 static void DisposeWeak(const v8::WeakCallbackInfo<WeakCallbackDataType>&); |
61 }; | 61 }; |
62 | 62 |
63 | 63 |
64 class CORE_EXPORT StringCache { | 64 class CORE_EXPORT StringCache { |
65 WTF_MAKE_NONCOPYABLE(StringCache); | 65 WTF_MAKE_NONCOPYABLE(StringCache); |
66 public: | 66 public: |
67 StringCache(v8::Isolate* isolate) : m_stringCache(isolate) { } | 67 StringCache(v8::Isolate* isolate) : m_stringCache(isolate) { } |
68 ~StringCache(); | 68 ~StringCache(); |
69 | 69 |
70 v8::Local<v8::String> v8ExternalString(StringImpl* stringImpl, v8::Isolate*
isolate) | 70 v8::Local<v8::String> v8ExternalString(v8::Isolate* isolate, StringImpl* str
ingImpl) |
71 { | 71 { |
72 ASSERT(stringImpl); | 72 ASSERT(stringImpl); |
73 if (m_lastStringImpl.get() == stringImpl) | 73 if (m_lastStringImpl.get() == stringImpl) |
74 return m_lastV8String.NewLocal(isolate); | 74 return m_lastV8String.NewLocal(isolate); |
75 return v8ExternalStringSlow(isolate, stringImpl); | 75 return v8ExternalStringSlow(isolate, stringImpl); |
76 } | 76 } |
77 | 77 |
78 void setReturnValueFromString(v8::ReturnValue<v8::Value> returnValue, String
Impl* stringImpl) | 78 void setReturnValueFromString(v8::ReturnValue<v8::Value> returnValue, String
Impl* stringImpl) |
79 { | 79 { |
80 ASSERT(stringImpl); | 80 ASSERT(stringImpl); |
(...skipping 16 matching lines...) Expand all Loading... |
97 | 97 |
98 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity | 98 // Note: RefPtr is a must as we cache by StringImpl* equality, not identity |
99 // hence lastStringImpl might be not a key of the cache (in sense of identit
y) | 99 // hence lastStringImpl might be not a key of the cache (in sense of identit
y) |
100 // and hence it's not refed on addition. | 100 // and hence it's not refed on addition. |
101 RefPtr<StringImpl> m_lastStringImpl; | 101 RefPtr<StringImpl> m_lastStringImpl; |
102 }; | 102 }; |
103 | 103 |
104 } // namespace blink | 104 } // namespace blink |
105 | 105 |
106 #endif // V8ValueCache_h | 106 #endif // V8ValueCache_h |
OLD | NEW |