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

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

Issue 2817533003: Replace ASSERT, RELEASE_ASSERT, and ASSERT_NOT_REACHED in bindings (Closed)
Patch Set: 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) 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 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // value may not be a Blink's wrapper object. In order to make sure of it, 74 // value may not be a Blink's wrapper object. In order to make sure of it,
75 // Use isWrapper function instead. 75 // Use isWrapper function instead.
76 CORE_EXPORT static bool HasInternalFieldsSet(v8::Local<v8::Value>); 76 CORE_EXPORT static bool HasInternalFieldsSet(v8::Local<v8::Value>);
77 }; 77 };
78 78
79 inline void V8DOMWrapper::SetNativeInfo( 79 inline void V8DOMWrapper::SetNativeInfo(
80 v8::Isolate* isolate, 80 v8::Isolate* isolate,
81 v8::Local<v8::Object> wrapper, 81 v8::Local<v8::Object> wrapper,
82 const WrapperTypeInfo* wrapper_type_info, 82 const WrapperTypeInfo* wrapper_type_info,
83 ScriptWrappable* script_wrappable) { 83 ScriptWrappable* script_wrappable) {
84 ASSERT(wrapper->InternalFieldCount() >= 2); 84 DCHECK_GE(wrapper->InternalFieldCount(), 2);
85 ASSERT(script_wrappable); 85 DCHECK(script_wrappable);
86 ASSERT(wrapper_type_info); 86 DCHECK(wrapper_type_info);
87 int indices[] = {kV8DOMWrapperObjectIndex, kV8DOMWrapperTypeIndex}; 87 int indices[] = {kV8DOMWrapperObjectIndex, kV8DOMWrapperTypeIndex};
88 void* values[] = {script_wrappable, 88 void* values[] = {script_wrappable,
89 const_cast<WrapperTypeInfo*>(wrapper_type_info)}; 89 const_cast<WrapperTypeInfo*>(wrapper_type_info)};
90 wrapper->SetAlignedPointerInInternalFields(WTF_ARRAY_LENGTH(indices), indices, 90 wrapper->SetAlignedPointerInInternalFields(WTF_ARRAY_LENGTH(indices), indices,
91 values); 91 values);
92 auto per_isolate_data = V8PerIsolateData::From(isolate); 92 auto per_isolate_data = V8PerIsolateData::From(isolate);
93 // We notify ScriptWrappableVisitor about the new wrapper association, 93 // We notify ScriptWrappableVisitor about the new wrapper association,
94 // so the visitor can make sure to trace the association (in case it is 94 // so the visitor can make sure to trace the association (in case it is
95 // currently tracing). Because of some optimizations, V8 will not 95 // currently tracing). Because of some optimizations, V8 will not
96 // necessarily detect wrappers created during its incremental marking. 96 // necessarily detect wrappers created during its incremental marking.
(...skipping 11 matching lines...) Expand all
108 } 108 }
109 109
110 inline v8::Local<v8::Object> V8DOMWrapper::AssociateObjectWithWrapper( 110 inline v8::Local<v8::Object> V8DOMWrapper::AssociateObjectWithWrapper(
111 v8::Isolate* isolate, 111 v8::Isolate* isolate,
112 ScriptWrappable* impl, 112 ScriptWrappable* impl,
113 const WrapperTypeInfo* wrapper_type_info, 113 const WrapperTypeInfo* wrapper_type_info,
114 v8::Local<v8::Object> wrapper) { 114 v8::Local<v8::Object> wrapper) {
115 if (DOMDataStore::SetWrapper(isolate, impl, wrapper_type_info, wrapper)) { 115 if (DOMDataStore::SetWrapper(isolate, impl, wrapper_type_info, wrapper)) {
116 wrapper_type_info->WrapperCreated(); 116 wrapper_type_info->WrapperCreated();
117 SetNativeInfo(isolate, wrapper, wrapper_type_info, impl); 117 SetNativeInfo(isolate, wrapper, wrapper_type_info, impl);
118 ASSERT(HasInternalFieldsSet(wrapper)); 118 DCHECK(HasInternalFieldsSet(wrapper));
119 } 119 }
120 SECURITY_CHECK(ToScriptWrappable(wrapper) == impl); 120 SECURITY_CHECK(ToScriptWrappable(wrapper) == impl);
121 return wrapper; 121 return wrapper;
122 } 122 }
123 123
124 class V8WrapperInstantiationScope { 124 class V8WrapperInstantiationScope {
125 STACK_ALLOCATED(); 125 STACK_ALLOCATED();
126 126
127 public: 127 public:
128 V8WrapperInstantiationScope(v8::Local<v8::Object> creation_context, 128 V8WrapperInstantiationScope(v8::Local<v8::Object> creation_context,
129 v8::Isolate* isolate, 129 v8::Isolate* isolate,
130 bool with_security_check) 130 bool with_security_check)
131 : did_enter_context_(false), 131 : did_enter_context_(false),
132 context_(isolate->GetCurrentContext()), 132 context_(isolate->GetCurrentContext()),
133 try_catch_(isolate), 133 try_catch_(isolate),
134 convert_exceptions_(false) { 134 convert_exceptions_(false) {
135 // creationContext should not be empty. Because if we have an 135 // creationContext should not be empty. Because if we have an
136 // empty creationContext, we will end up creating 136 // empty creationContext, we will end up creating
137 // a new object in the context currently entered. This is wrong. 137 // a new object in the context currently entered. This is wrong.
138 RELEASE_ASSERT(!creation_context.IsEmpty()); 138 CHECK(!creation_context.IsEmpty());
139 v8::Local<v8::Context> context_for_wrapper = 139 v8::Local<v8::Context> context_for_wrapper =
140 creation_context->CreationContext(); 140 creation_context->CreationContext();
141 141
142 // For performance, we enter the context only if the currently running 142 // For performance, we enter the context only if the currently running
143 // context is different from the context that we are about to enter. 143 // context is different from the context that we are about to enter.
144 if (context_for_wrapper == context_) 144 if (context_for_wrapper == context_)
145 return; 145 return;
146 if (with_security_check) { 146 if (with_security_check) {
147 SecurityCheck(isolate, context_for_wrapper); 147 SecurityCheck(isolate, context_for_wrapper);
148 } else { 148 } else {
(...skipping 28 matching lines...) Expand all
177 177
178 bool did_enter_context_; 178 bool did_enter_context_;
179 v8::Local<v8::Context> context_; 179 v8::Local<v8::Context> context_;
180 v8::TryCatch try_catch_; 180 v8::TryCatch try_catch_;
181 bool convert_exceptions_; 181 bool convert_exceptions_;
182 }; 182 };
183 183
184 } // namespace blink 184 } // namespace blink
185 185
186 #endif // V8DOMWrapper_h 186 #endif // V8DOMWrapper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698