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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8PerContextData.h

Issue 2828643002: Make customElements.define faster
Patch Set: Try to make Android builder happy. Created 3 years, 8 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 // Garbage collected classes that use V8PerContextData to hold an instance 106 // Garbage collected classes that use V8PerContextData to hold an instance
107 // should subclass Data, and use addData / clearData / getData to manage the 107 // should subclass Data, and use addData / clearData / getData to manage the
108 // instance. 108 // instance.
109 class CORE_EXPORT Data : public GarbageCollectedMixin {}; 109 class CORE_EXPORT Data : public GarbageCollectedMixin {};
110 110
111 void AddData(const char* key, Data*); 111 void AddData(const char* key, Data*);
112 void ClearData(const char* key); 112 void ClearData(const char* key);
113 Data* GetData(const char* key); 113 Data* GetData(const char* key);
114 114
115 // Gets a Private to store custom element definition IDs on a
116 // function in use as a custom element constructor in this context.
117 v8::Local<v8::Private> GetPrivateCustomElementDefinitionId() {
118 if (UNLIKELY(private_custom_element_definition_id_.IsEmpty())) {
119 private_custom_element_definition_id_.Set(isolate_,
120 v8::Private::New(isolate_));
121 }
122 return private_custom_element_definition_id_.NewLocal(isolate_);
123 }
124
115 private: 125 private:
116 V8PerContextData(v8::Local<v8::Context>); 126 V8PerContextData(v8::Local<v8::Context>);
117 127
118 v8::Local<v8::Object> CreateWrapperFromCacheSlowCase(const WrapperTypeInfo*); 128 v8::Local<v8::Object> CreateWrapperFromCacheSlowCase(const WrapperTypeInfo*);
119 v8::Local<v8::Function> ConstructorForTypeSlowCase(const WrapperTypeInfo*); 129 v8::Local<v8::Function> ConstructorForTypeSlowCase(const WrapperTypeInfo*);
120 130
121 v8::Isolate* isolate_; 131 v8::Isolate* isolate_;
122 132
123 // For each possible type of wrapper, we keep a boilerplate object. 133 // For each possible type of wrapper, we keep a boilerplate object.
124 // The boilerplate is used to create additional wrappers of the same type. 134 // The boilerplate is used to create additional wrappers of the same type.
125 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Object, v8::kNotWeak> 135 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Object, v8::kNotWeak>
126 WrapperBoilerplateMap; 136 WrapperBoilerplateMap;
127 WrapperBoilerplateMap wrapper_boilerplates_; 137 WrapperBoilerplateMap wrapper_boilerplates_;
128 138
129 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak> 139 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak>
130 ConstructorMap; 140 ConstructorMap;
131 ConstructorMap constructor_map_; 141 ConstructorMap constructor_map_;
132 142
133 std::unique_ptr<gin::ContextHolder> context_holder_; 143 std::unique_ptr<gin::ContextHolder> context_holder_;
134 144
135 ScopedPersistent<v8::Context> context_; 145 ScopedPersistent<v8::Context> context_;
136 ScopedPersistent<v8::Value> error_prototype_; 146 ScopedPersistent<v8::Value> error_prototype_;
137 147
148 // One function may be defined as a custom element constructor
149 // across multiple contexts simultaneously. Each context tags the
150 // constructor with a different Private to map the constructor back
151 // to its definition.
152 ScopedPersistent<v8::Private> private_custom_element_definition_id_;
153
138 typedef Vector<std::unique_ptr<V0CustomElementBinding>> 154 typedef Vector<std::unique_ptr<V0CustomElementBinding>>
139 V0CustomElementBindingList; 155 V0CustomElementBindingList;
140 V0CustomElementBindingList custom_element_bindings_; 156 V0CustomElementBindingList custom_element_bindings_;
141 157
142 // This is owned by a static hash map in V8DOMActivityLogger. 158 // This is owned by a static hash map in V8DOMActivityLogger.
143 V8DOMActivityLogger* activity_logger_; 159 V8DOMActivityLogger* activity_logger_;
144 160
145 using DataMap = PersistentHeapHashMap<const char*, Member<Data>>; 161 using DataMap = PersistentHeapHashMap<const char*, Member<Data>>;
146 DataMap data_map_; 162 DataMap data_map_;
147 }; 163 };
148 164
149 } // namespace blink 165 } // namespace blink
150 166
151 #endif // V8PerContextData_h 167 #endif // V8PerContextData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698