| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void StringCache::Dispose() { | 63 void StringCache::Dispose() { |
| 64 // The MapType::Dispose callback calls StringCache::InvalidateLastString, | 64 // The MapType::Dispose callback calls StringCache::InvalidateLastString, |
| 65 // which will only work while the destructor has not yet finished. Thus, | 65 // which will only work while the destructor has not yet finished. Thus, |
| 66 // we need to clear the map before the destructor has completed. | 66 // we need to clear the map before the destructor has completed. |
| 67 string_cache_.Clear(); | 67 string_cache_.Clear(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 static v8::Local<v8::String> MakeExternalString(v8::Isolate* isolate, | 70 static v8::Local<v8::String> MakeExternalString(v8::Isolate* isolate, |
| 71 const String& string) { | 71 const String& string) { |
| 72 if (string.Is8Bit()) { | 72 if (string.Is8Bit()) { |
| 73 WebCoreStringResource8* string_resource = | 73 StringResource8* string_resource = new StringResource8(string); |
| 74 new WebCoreStringResource8(string); | |
| 75 v8::Local<v8::String> new_string; | 74 v8::Local<v8::String> new_string; |
| 76 if (!v8::String::NewExternalOneByte(isolate, string_resource) | 75 if (!v8::String::NewExternalOneByte(isolate, string_resource) |
| 77 .ToLocal(&new_string)) { | 76 .ToLocal(&new_string)) { |
| 78 delete string_resource; | 77 delete string_resource; |
| 79 return v8::String::Empty(isolate); | 78 return v8::String::Empty(isolate); |
| 80 } | 79 } |
| 81 return new_string; | 80 return new_string; |
| 82 } | 81 } |
| 83 | 82 |
| 84 WebCoreStringResource16* string_resource = | 83 StringResource16* string_resource = new StringResource16(string); |
| 85 new WebCoreStringResource16(string); | |
| 86 v8::Local<v8::String> new_string; | 84 v8::Local<v8::String> new_string; |
| 87 if (!v8::String::NewExternalTwoByte(isolate, string_resource) | 85 if (!v8::String::NewExternalTwoByte(isolate, string_resource) |
| 88 .ToLocal(&new_string)) { | 86 .ToLocal(&new_string)) { |
| 89 delete string_resource; | 87 delete string_resource; |
| 90 return v8::String::Empty(isolate); | 88 return v8::String::Empty(isolate); |
| 91 } | 89 } |
| 92 return new_string; | 90 return new_string; |
| 93 } | 91 } |
| 94 | 92 |
| 95 v8::Local<v8::String> StringCache::V8ExternalStringSlow( | 93 v8::Local<v8::String> StringCache::V8ExternalStringSlow( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 148 |
| 151 return new_string; | 149 return new_string; |
| 152 } | 150 } |
| 153 | 151 |
| 154 void StringCache::InvalidateLastString() { | 152 void StringCache::InvalidateLastString() { |
| 155 last_string_impl_ = nullptr; | 153 last_string_impl_ = nullptr; |
| 156 last_v8_string_.Reset(); | 154 last_v8_string_.Reset(); |
| 157 } | 155 } |
| 158 | 156 |
| 159 } // namespace blink | 157 } // namespace blink |
| OLD | NEW |