Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: Source/bindings/core/v8/V8ValueCache.cpp

Issue 684803002: Move the v8::Isolate* parameter to the first parameter of various binding methods in third_party/We… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/core/v8/V8ValueCache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return newString; 64 return newString;
65 } 65 }
66 66
67 WebCoreStringResource16* stringResource = new WebCoreStringResource16(string ); 67 WebCoreStringResource16* stringResource = new WebCoreStringResource16(string );
68 v8::Local<v8::String> newString = v8::String::NewExternal(isolate, stringRes ource); 68 v8::Local<v8::String> newString = v8::String::NewExternal(isolate, stringRes ource);
69 if (newString.IsEmpty()) 69 if (newString.IsEmpty())
70 delete stringResource; 70 delete stringResource;
71 return newString; 71 return newString;
72 } 72 }
73 73
74 v8::Handle<v8::String> StringCache::v8ExternalStringSlow(StringImpl* stringImpl, v8::Isolate* isolate) 74 v8::Handle<v8::String> StringCache::v8ExternalStringSlow(v8::Isolate* isolate, S tringImpl* stringImpl)
75 { 75 {
76 if (!stringImpl->length()) 76 if (!stringImpl->length())
77 return v8::String::Empty(isolate); 77 return v8::String::Empty(isolate);
78 78
79 StringCacheMapTraits::MapType::PersistentValueReference cachedV8String = m_s tringCache.GetReference(stringImpl); 79 StringCacheMapTraits::MapType::PersistentValueReference cachedV8String = m_s tringCache.GetReference(stringImpl);
80 if (!cachedV8String.IsEmpty()) { 80 if (!cachedV8String.IsEmpty()) {
81 m_lastStringImpl = stringImpl; 81 m_lastStringImpl = stringImpl;
82 m_lastV8String = cachedV8String; 82 m_lastV8String = cachedV8String;
83 return m_lastV8String.NewLocal(isolate); 83 return m_lastV8String.NewLocal(isolate);
84 } 84 }
85 85
86 return createStringAndInsertIntoCache(stringImpl, isolate); 86 return createStringAndInsertIntoCache(isolate, stringImpl);
87 } 87 }
88 88
89 void StringCache::setReturnValueFromStringSlow(v8::ReturnValue<v8::Value> return Value, StringImpl* stringImpl) 89 void StringCache::setReturnValueFromStringSlow(v8::ReturnValue<v8::Value> return Value, StringImpl* stringImpl)
90 { 90 {
91 if (!stringImpl->length()) { 91 if (!stringImpl->length()) {
92 returnValue.SetEmptyString(); 92 returnValue.SetEmptyString();
93 return; 93 return;
94 } 94 }
95 95
96 StringCacheMapTraits::MapType::PersistentValueReference cachedV8String = m_s tringCache.GetReference(stringImpl); 96 StringCacheMapTraits::MapType::PersistentValueReference cachedV8String = m_s tringCache.GetReference(stringImpl);
97 if (!cachedV8String.IsEmpty()) { 97 if (!cachedV8String.IsEmpty()) {
98 m_lastStringImpl = stringImpl; 98 m_lastStringImpl = stringImpl;
99 m_lastV8String = cachedV8String; 99 m_lastV8String = cachedV8String;
100 m_lastV8String.SetReturnValue(returnValue); 100 m_lastV8String.SetReturnValue(returnValue);
101 return; 101 return;
102 } 102 }
103 103
104 returnValue.Set(createStringAndInsertIntoCache(stringImpl, returnValue.GetIs olate())); 104 returnValue.Set(createStringAndInsertIntoCache(returnValue.GetIsolate(), str ingImpl));
105 } 105 }
106 106
107 v8::Local<v8::String> StringCache::createStringAndInsertIntoCache(StringImpl* st ringImpl, v8::Isolate* isolate) 107 v8::Local<v8::String> StringCache::createStringAndInsertIntoCache(v8::Isolate* i solate, StringImpl* stringImpl)
108 { 108 {
109 ASSERT(!m_stringCache.Contains(stringImpl)); 109 ASSERT(!m_stringCache.Contains(stringImpl));
110 ASSERT(stringImpl->length()); 110 ASSERT(stringImpl->length());
111 111
112 v8::Local<v8::String> newString = makeExternalString(String(stringImpl), iso late); 112 v8::Local<v8::String> newString = makeExternalString(String(stringImpl), iso late);
113 if (newString.IsEmpty()) 113 if (newString.IsEmpty())
114 return newString; 114 return newString;
115 115
116 v8::UniquePersistent<v8::String> wrapper(isolate, newString); 116 v8::UniquePersistent<v8::String> wrapper(isolate, newString);
117 117
118 stringImpl->ref(); 118 stringImpl->ref();
119 wrapper.MarkIndependent(); 119 wrapper.MarkIndependent();
120 m_stringCache.Set(stringImpl, wrapper.Pass(), &m_lastV8String); 120 m_stringCache.Set(stringImpl, wrapper.Pass(), &m_lastV8String);
121 m_lastStringImpl = stringImpl; 121 m_lastStringImpl = stringImpl;
122 122
123 return newString; 123 return newString;
124 } 124 }
125 125
126 void StringCache::InvalidateLastString() 126 void StringCache::InvalidateLastString()
127 { 127 {
128 m_lastStringImpl = nullptr; 128 m_lastStringImpl = nullptr;
129 m_lastV8String.Reset(); 129 m_lastV8String.Reset();
130 } 130 }
131 131
132 } // namespace blink 132 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8ValueCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698