| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 | 128 |
| 129 return_value.Set( | 129 return_value.Set( |
| 130 CreateStringAndInsertIntoCache(return_value.GetIsolate(), string_impl)); | 130 CreateStringAndInsertIntoCache(return_value.GetIsolate(), string_impl)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 v8::Local<v8::String> StringCache::CreateStringAndInsertIntoCache( | 133 v8::Local<v8::String> StringCache::CreateStringAndInsertIntoCache( |
| 134 v8::Isolate* isolate, | 134 v8::Isolate* isolate, |
| 135 StringImpl* string_impl) { | 135 StringImpl* string_impl) { |
| 136 ASSERT(!string_cache_.Contains(string_impl)); | 136 DCHECK(!string_cache_.Contains(string_impl)); |
| 137 ASSERT(string_impl->length()); | 137 DCHECK(string_impl->length()); |
| 138 | 138 |
| 139 v8::Local<v8::String> new_string = | 139 v8::Local<v8::String> new_string = |
| 140 MakeExternalString(isolate, String(string_impl)); | 140 MakeExternalString(isolate, String(string_impl)); |
| 141 ASSERT(!new_string.IsEmpty()); | 141 DCHECK(!new_string.IsEmpty()); |
| 142 ASSERT(new_string->Length()); | 142 DCHECK(new_string->Length()); |
| 143 | 143 |
| 144 v8::UniquePersistent<v8::String> wrapper(isolate, new_string); | 144 v8::UniquePersistent<v8::String> wrapper(isolate, new_string); |
| 145 | 145 |
| 146 string_impl->Ref(); | 146 string_impl->Ref(); |
| 147 wrapper.MarkIndependent(); | 147 wrapper.MarkIndependent(); |
| 148 string_cache_.Set(string_impl, std::move(wrapper), &last_v8_string_); | 148 string_cache_.Set(string_impl, std::move(wrapper), &last_v8_string_); |
| 149 last_string_impl_ = string_impl; | 149 last_string_impl_ = string_impl; |
| 150 | 150 |
| 151 return new_string; | 151 return new_string; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void StringCache::InvalidateLastString() { | 154 void StringCache::InvalidateLastString() { |
| 155 last_string_impl_ = nullptr; | 155 last_string_impl_ = nullptr; |
| 156 last_v8_string_.Reset(); | 156 last_v8_string_.Reset(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |