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

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

Issue 2828643002: Make customElements.define faster
Patch Set: Remove some unneeded casts. Created 3 years, 7 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // Gets the constructor and prototype for a type, if they have already been 91 // Gets the constructor and prototype for a type, if they have already been
92 // created. Returns true if they exist, and sets the existing values in 92 // created. Returns true if they exist, and sets the existing values in
93 // |prototypeObject| and |interfaceObject|. Otherwise, returns false, and the 93 // |prototypeObject| and |interfaceObject|. Otherwise, returns false, and the
94 // values are set to empty objects (non-null). 94 // values are set to empty objects (non-null).
95 bool GetExistingConstructorAndPrototypeForType( 95 bool GetExistingConstructorAndPrototypeForType(
96 const WrapperTypeInfo*, 96 const WrapperTypeInfo*,
97 v8::Local<v8::Object>* prototype_object, 97 v8::Local<v8::Object>* prototype_object,
98 v8::Local<v8::Function>* interface_object); 98 v8::Local<v8::Function>* interface_object);
99 99
100 // Gets a Private to store custom element definition IDs on a
101 // function in use as a custom element constructor in this context.
102 v8::Local<v8::Private> GetPrivateCustomElementDefinitionId() {
103 if (UNLIKELY(private_custom_element_definition_id_.IsEmpty())) {
104 private_custom_element_definition_id_.Set(isolate_,
105 v8::Private::New(isolate_));
106 }
107 return private_custom_element_definition_id_.NewLocal(isolate_);
108 }
109
100 void AddCustomElementBinding(std::unique_ptr<V0CustomElementBinding>); 110 void AddCustomElementBinding(std::unique_ptr<V0CustomElementBinding>);
101 111
102 V8DOMActivityLogger* ActivityLogger() const { return activity_logger_; } 112 V8DOMActivityLogger* ActivityLogger() const { return activity_logger_; }
103 void SetActivityLogger(V8DOMActivityLogger* activity_logger) { 113 void SetActivityLogger(V8DOMActivityLogger* activity_logger) {
104 activity_logger_ = activity_logger; 114 activity_logger_ = activity_logger;
105 } 115 }
106 116
107 // Garbage collected classes that use V8PerContextData to hold an instance 117 // Garbage collected classes that use V8PerContextData to hold an instance
108 // should subclass Data, and use addData / clearData / getData to manage the 118 // should subclass Data, and use addData / clearData / getData to manage the
109 // instance. 119 // instance.
(...skipping 19 matching lines...) Expand all
129 139
130 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak> 140 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak>
131 ConstructorMap; 141 ConstructorMap;
132 ConstructorMap constructor_map_; 142 ConstructorMap constructor_map_;
133 143
134 std::unique_ptr<gin::ContextHolder> context_holder_; 144 std::unique_ptr<gin::ContextHolder> context_holder_;
135 145
136 ScopedPersistent<v8::Context> context_; 146 ScopedPersistent<v8::Context> context_;
137 ScopedPersistent<v8::Value> error_prototype_; 147 ScopedPersistent<v8::Value> error_prototype_;
138 148
149 // One function may be defined as a custom element constructor
150 // across multiple contexts simultaneously. Each context tags the
151 // constructor with a different Private to map the constructor back
152 // to its definition.
haraken 2017/04/28 08:49:30 Can we use V8PrivateProperty instead?
153 ScopedPersistent<v8::Private> private_custom_element_definition_id_;
154
139 typedef Vector<std::unique_ptr<V0CustomElementBinding>> 155 typedef Vector<std::unique_ptr<V0CustomElementBinding>>
140 V0CustomElementBindingList; 156 V0CustomElementBindingList;
141 V0CustomElementBindingList custom_element_bindings_; 157 V0CustomElementBindingList custom_element_bindings_;
142 158
143 // This is owned by a static hash map in V8DOMActivityLogger. 159 // This is owned by a static hash map in V8DOMActivityLogger.
144 V8DOMActivityLogger* activity_logger_; 160 V8DOMActivityLogger* activity_logger_;
145 161
146 using DataMap = PersistentHeapHashMap<const char*, Member<Data>>; 162 using DataMap = PersistentHeapHashMap<const char*, Member<Data>>;
147 DataMap data_map_; 163 DataMap data_map_;
148 }; 164 };
149 165
150 } // namespace blink 166 } // namespace blink
151 167
152 #endif // V8PerContextData_h 168 #endif // V8PerContextData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698