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

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

Issue 2817533003: Replace ASSERT, RELEASE_ASSERT, and ASSERT_NOT_REACHED in bindings (Closed)
Patch Set: fixed dcheck build error 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 V8PerContextData::V8PerContextData(v8::Local<v8::Context> context) 45 V8PerContextData::V8PerContextData(v8::Local<v8::Context> context)
46 : isolate_(context->GetIsolate()), 46 : isolate_(context->GetIsolate()),
47 wrapper_boilerplates_(isolate_), 47 wrapper_boilerplates_(isolate_),
48 constructor_map_(isolate_), 48 constructor_map_(isolate_),
49 context_holder_(WTF::MakeUnique<gin::ContextHolder>(isolate_)), 49 context_holder_(WTF::MakeUnique<gin::ContextHolder>(isolate_)),
50 context_(isolate_, context), 50 context_(isolate_, context),
51 activity_logger_(nullptr) { 51 activity_logger_(nullptr) {
52 context_holder_->SetContext(context); 52 context_holder_->SetContext(context);
53 53
54 v8::Context::Scope context_scope(context); 54 v8::Context::Scope context_scope(context);
55 ASSERT(error_prototype_.IsEmpty()); 55 DCHECK(error_prototype_.IsEmpty());
56 v8::Local<v8::Value> object_value = 56 v8::Local<v8::Value> object_value =
57 context->Global() 57 context->Global()
58 ->Get(context, V8AtomicString(isolate_, "Error")) 58 ->Get(context, V8AtomicString(isolate_, "Error"))
59 .ToLocalChecked(); 59 .ToLocalChecked();
60 v8::Local<v8::Value> prototype_value = 60 v8::Local<v8::Value> prototype_value =
61 object_value.As<v8::Object>() 61 object_value.As<v8::Object>()
62 ->Get(context, V8AtomicString(isolate_, "prototype")) 62 ->Get(context, V8AtomicString(isolate_, "prototype"))
63 .ToLocalChecked(); 63 .ToLocalChecked();
64 error_prototype_.Set(isolate_, prototype_value); 64 error_prototype_.Set(isolate_, prototype_value);
65 65
(...skipping 12 matching lines...) Expand all
78 v8::Local<v8::Context> context) { 78 v8::Local<v8::Context> context) {
79 return WTF::WrapUnique(new V8PerContextData(context)); 79 return WTF::WrapUnique(new V8PerContextData(context));
80 } 80 }
81 81
82 V8PerContextData* V8PerContextData::From(v8::Local<v8::Context> context) { 82 V8PerContextData* V8PerContextData::From(v8::Local<v8::Context> context) {
83 return ScriptState::From(context)->PerContextData(); 83 return ScriptState::From(context)->PerContextData();
84 } 84 }
85 85
86 v8::Local<v8::Object> V8PerContextData::CreateWrapperFromCacheSlowCase( 86 v8::Local<v8::Object> V8PerContextData::CreateWrapperFromCacheSlowCase(
87 const WrapperTypeInfo* type) { 87 const WrapperTypeInfo* type) {
88 ASSERT(!error_prototype_.IsEmpty()); 88 DCHECK(!error_prototype_.IsEmpty());
89 89
90 v8::Context::Scope scope(GetContext()); 90 v8::Context::Scope scope(GetContext());
91 v8::Local<v8::Function> interface_object = ConstructorForType(type); 91 v8::Local<v8::Function> interface_object = ConstructorForType(type);
92 if (interface_object.IsEmpty()) 92 if (interface_object.IsEmpty())
93 return v8::Local<v8::Object>(); 93 return v8::Local<v8::Object>();
94 v8::Local<v8::Object> instance_template; 94 v8::Local<v8::Object> instance_template;
95 if (!V8ObjectConstructor::NewInstance(isolate_, interface_object) 95 if (!V8ObjectConstructor::NewInstance(isolate_, interface_object)
96 .ToLocal(&instance_template)) 96 .ToLocal(&instance_template))
97 return v8::Local<v8::Object>(); 97 return v8::Local<v8::Object>();
98 wrapper_boilerplates_.Set(type, instance_template); 98 wrapper_boilerplates_.Set(type, instance_template);
99 return instance_template->Clone(); 99 return instance_template->Clone();
100 } 100 }
101 101
102 v8::Local<v8::Function> V8PerContextData::ConstructorForTypeSlowCase( 102 v8::Local<v8::Function> V8PerContextData::ConstructorForTypeSlowCase(
103 const WrapperTypeInfo* type) { 103 const WrapperTypeInfo* type) {
104 ASSERT(!error_prototype_.IsEmpty()); 104 DCHECK(!error_prototype_.IsEmpty());
105 105
106 v8::Local<v8::Context> current_context = GetContext(); 106 v8::Local<v8::Context> current_context = GetContext();
107 v8::Context::Scope scope(current_context); 107 v8::Context::Scope scope(current_context);
108 const DOMWrapperWorld& world = DOMWrapperWorld::World(current_context); 108 const DOMWrapperWorld& world = DOMWrapperWorld::World(current_context);
109 // We shouldn't reach this point for the types that are implemented in v8 such 109 // We shouldn't reach this point for the types that are implemented in v8 such
110 // as typed arrays and hence don't have domTemplateFunction. 110 // as typed arrays and hence don't have domTemplateFunction.
111 ASSERT(type->dom_template_function); 111 DCHECK(type->dom_template_function);
112 v8::Local<v8::FunctionTemplate> interface_template = 112 v8::Local<v8::FunctionTemplate> interface_template =
113 type->domTemplate(isolate_, world); 113 type->domTemplate(isolate_, world);
114 // Getting the function might fail if we're running out of stack or memory. 114 // Getting the function might fail if we're running out of stack or memory.
115 v8::Local<v8::Function> interface_object; 115 v8::Local<v8::Function> interface_object;
116 if (!interface_template->GetFunction(current_context) 116 if (!interface_template->GetFunction(current_context)
117 .ToLocal(&interface_object)) 117 .ToLocal(&interface_object))
118 return v8::Local<v8::Function>(); 118 return v8::Local<v8::Function>();
119 119
120 if (type->parent_class) { 120 if (type->parent_class) {
121 v8::Local<v8::Object> prototype_template = 121 v8::Local<v8::Object> prototype_template =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 void V8PerContextData::ClearData(const char* key) { 198 void V8PerContextData::ClearData(const char* key) {
199 data_map_.erase(key); 199 data_map_.erase(key);
200 } 200 }
201 201
202 V8PerContextData::Data* V8PerContextData::GetData(const char* key) { 202 V8PerContextData::Data* V8PerContextData::GetData(const char* key) {
203 return data_map_.at(key); 203 return data_map_.at(key);
204 } 204 }
205 205
206 } // namespace blink 206 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698