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

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

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Work for all comments Created 3 years, 6 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 V8PerContextData* V8PerContextData::From(v8::Local<v8::Context> context) { 84 V8PerContextData* V8PerContextData::From(v8::Local<v8::Context> context) {
85 return ScriptState::From(context)->PerContextData(); 85 return ScriptState::From(context)->PerContextData();
86 } 86 }
87 87
88 v8::Local<v8::Object> V8PerContextData::CreateWrapperFromCacheSlowCase( 88 v8::Local<v8::Object> V8PerContextData::CreateWrapperFromCacheSlowCase(
89 const WrapperTypeInfo* type) { 89 const WrapperTypeInfo* type) {
90 DCHECK(!error_prototype_.IsEmpty()); 90 DCHECK(!error_prototype_.IsEmpty());
91 91
92 v8::Context::Scope scope(GetContext()); 92 v8::Local<v8::Context> context = GetContext();
Yuki 2017/06/20 14:20:11 |context| seems never used again?
peria 2017/06/21 07:19:16 Done.
93 v8::Context::Scope scope(context);
93 v8::Local<v8::Function> interface_object = ConstructorForType(type); 94 v8::Local<v8::Function> interface_object = ConstructorForType(type);
95
94 CHECK(!interface_object.IsEmpty()); 96 CHECK(!interface_object.IsEmpty());
95 v8::Local<v8::Object> instance_template = 97 v8::Local<v8::Object> instance_template =
96 V8ObjectConstructor::NewInstance(isolate_, interface_object) 98 V8ObjectConstructor::NewInstance(isolate_, interface_object)
97 .ToLocalChecked(); 99 .ToLocalChecked();
98 wrapper_boilerplates_.Set(type, instance_template); 100 wrapper_boilerplates_.Set(type, instance_template);
99 return instance_template->Clone(); 101 return instance_template->Clone();
100 } 102 }
101 103
102 v8::Local<v8::Function> V8PerContextData::ConstructorForTypeSlowCase( 104 v8::Local<v8::Function> V8PerContextData::ConstructorForTypeSlowCase(
103 const WrapperTypeInfo* type) { 105 const WrapperTypeInfo* type) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (!V8CallBoolean(prototype_object->SetPrototype( 154 if (!V8CallBoolean(prototype_object->SetPrototype(
153 current_context, error_prototype_.NewLocal(isolate_)))) { 155 current_context, error_prototype_.NewLocal(isolate_)))) {
154 return v8::Local<v8::Function>(); 156 return v8::Local<v8::Function>();
155 } 157 }
156 } 158 }
157 } 159 }
158 160
159 // Origin Trials 161 // Origin Trials
160 InstallConditionalFeatures(type, ScriptState::From(current_context), 162 InstallConditionalFeatures(type, ScriptState::From(current_context),
161 prototype_object, interface_object); 163 prototype_object, interface_object);
162
163 constructor_map_.Set(type, interface_object); 164 constructor_map_.Set(type, interface_object);
164 165
165 return interface_object; 166 return interface_object;
166 } 167 }
167 168
168 v8::Local<v8::Object> V8PerContextData::PrototypeForType( 169 v8::Local<v8::Object> V8PerContextData::PrototypeForType(
169 const WrapperTypeInfo* type) { 170 const WrapperTypeInfo* type) {
170 v8::Local<v8::Object> constructor = ConstructorForType(type); 171 v8::Local<v8::Object> constructor = ConstructorForType(type);
171 if (constructor.IsEmpty()) 172 if (constructor.IsEmpty())
172 return v8::Local<v8::Object>(); 173 return v8::Local<v8::Object>();
(...skipping 30 matching lines...) Expand all
203 204
204 void V8PerContextData::ClearData(const char* key) { 205 void V8PerContextData::ClearData(const char* key) {
205 data_map_.erase(key); 206 data_map_.erase(key);
206 } 207 }
207 208
208 V8PerContextData::Data* V8PerContextData::GetData(const char* key) { 209 V8PerContextData::Data* V8PerContextData::GetData(const char* key) {
209 return data_map_.at(key); 210 return data_map_.at(key);
210 } 211 }
211 212
212 } // namespace blink 213 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698