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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InspectorWrapper.h

Issue 1804043002: Revert of Remove V8RecrusionScope, cleanup call sites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef InspectorWrapper_h 5 #ifndef InspectorWrapper_h
6 #define InspectorWrapper_h 6 #define InspectorWrapper_h
7 7
8 #include "platform/inspector_protocol/Collections.h" 8 #include "platform/inspector_protocol/Collections.h"
9 #include "wtf/PassOwnPtr.h" 9 #include "wtf/PassOwnPtr.h"
10 #include <v8.h> 10 #include <v8.h>
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class V8DebuggerClient;
15
14 class InspectorWrapperBase { 16 class InspectorWrapperBase {
15 public: 17 public:
16 struct V8MethodConfiguration { 18 struct V8MethodConfiguration {
17 const char* name; 19 const char* name;
18 v8::FunctionCallback callback; 20 v8::FunctionCallback callback;
19 }; 21 };
20 22
21 struct V8AttributeConfiguration { 23 struct V8AttributeConfiguration {
22 const char* name; 24 const char* name;
23 v8::AccessorNameGetterCallback callback; 25 v8::AccessorNameGetterCallback callback;
24 }; 26 };
25 27
26 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*, c onst char* className, const protocol::Vector<V8MethodConfiguration>& methods, co nst protocol::Vector<V8AttributeConfiguration>& attributes); 28 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*, c onst char* className, const protocol::Vector<V8MethodConfiguration>& methods, co nst protocol::Vector<V8AttributeConfiguration>& attributes);
27 29
28 protected: 30 protected:
29 static v8::Local<v8::Object> createWrapper(v8::Local<v8::FunctionTemplate>, v8::Local<v8::Context>); 31 static v8::Local<v8::Object> createWrapper(V8DebuggerClient*, v8::Local<v8:: FunctionTemplate>, v8::Local<v8::Context>);
30 static void* unwrap(v8::Local<v8::Context>, v8::Local<v8::Object>, const cha r* name); 32 static void* unwrap(v8::Local<v8::Context>, v8::Local<v8::Object>, const cha r* name);
31 33
32 static v8::Local<v8::String> v8InternalizedString(v8::Isolate*, const char* name); 34 static v8::Local<v8::String> v8InternalizedString(v8::Isolate*, const char* name);
33 }; 35 };
34 36
35 template<class T, char* const hiddenPropertyName, char* const className> 37 template<class T, char* const hiddenPropertyName, char* const className>
36 class InspectorWrapper final : public InspectorWrapperBase { 38 class InspectorWrapper final : public InspectorWrapperBase {
37 public: 39 public:
38 class WeakCallbackData final { 40 class WeakCallbackData final {
39 public: 41 public:
(...skipping 22 matching lines...) Expand all
62 } 64 }
63 65
64 v8::Global<v8::Object> m_persistent; 66 v8::Global<v8::Object> m_persistent;
65 }; 67 };
66 68
67 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate* is olate, const protocol::Vector<V8MethodConfiguration>& methods, const protocol::V ector<V8AttributeConfiguration>& attributes) 69 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate* is olate, const protocol::Vector<V8MethodConfiguration>& methods, const protocol::V ector<V8AttributeConfiguration>& attributes)
68 { 70 {
69 return InspectorWrapperBase::createWrapperTemplate(isolate, className, m ethods, attributes); 71 return InspectorWrapperBase::createWrapperTemplate(isolate, className, m ethods, attributes);
70 } 72 }
71 73
72 static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructo rTemplate, v8::Local<v8::Context> context, T* object) 74 static v8::Local<v8::Object> wrap(V8DebuggerClient* client, v8::Local<v8::Fu nctionTemplate> constructorTemplate, v8::Local<v8::Context> context, T* object)
73 { 75 {
74 v8::Context::Scope contextScope(context); 76 v8::Context::Scope contextScope(context);
75 v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(const ructorTemplate, context); 77 v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(clien t, constructorTemplate, context);
76 if (result.IsEmpty()) 78 if (result.IsEmpty())
77 return v8::Local<v8::Object>(); 79 return v8::Local<v8::Object>();
78 v8::Isolate* isolate = context->GetIsolate(); 80 v8::Isolate* isolate = context->GetIsolate();
79 v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, object, result)); 81 v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, object, result));
80 82
81 v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::Str ing::NewFromUtf8(isolate, hiddenPropertyName, v8::NewStringType::kInternalized). ToLocalChecked()); 83 v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::Str ing::NewFromUtf8(isolate, hiddenPropertyName, v8::NewStringType::kInternalized). ToLocalChecked());
82 result->SetPrivate(context, privateKey, objectReference); 84 result->SetPrivate(context, privateKey, objectReference);
83 return result; 85 return result;
84 } 86 }
85 87
86 static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructo rTemplate, v8::Local<v8::Context> context, PassOwnPtr<T> object) 88 static v8::Local<v8::Object> wrap(V8DebuggerClient* client, v8::Local<v8::Fu nctionTemplate> constructorTemplate, v8::Local<v8::Context> context, PassOwnPtr< T> object)
87 { 89 {
88 v8::Context::Scope contextScope(context); 90 v8::Context::Scope contextScope(context);
89 v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(const ructorTemplate, context); 91 v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(clien t, constructorTemplate, context);
90 if (result.IsEmpty()) 92 if (result.IsEmpty())
91 return v8::Local<v8::Object>(); 93 return v8::Local<v8::Object>();
92 v8::Isolate* isolate = context->GetIsolate(); 94 v8::Isolate* isolate = context->GetIsolate();
93 v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, object, result)); 95 v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, object, result));
94 96
95 v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::Str ing::NewFromUtf8(isolate, hiddenPropertyName, v8::NewStringType::kInternalized). ToLocalChecked()); 97 v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::Str ing::NewFromUtf8(isolate, hiddenPropertyName, v8::NewStringType::kInternalized). ToLocalChecked());
96 result->SetPrivate(context, privateKey, objectReference); 98 result->SetPrivate(context, privateKey, objectReference);
97 return result; 99 return result;
98 } 100 }
99 101
100 static T* unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> objec t) 102 static T* unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> objec t)
101 { 103 {
102 void* data = InspectorWrapperBase::unwrap(context, object, hiddenPropert yName); 104 void* data = InspectorWrapperBase::unwrap(context, object, hiddenPropert yName);
103 if (!data) 105 if (!data)
104 return nullptr; 106 return nullptr;
105 return reinterpret_cast<WeakCallbackData*>(data)->m_impl; 107 return reinterpret_cast<WeakCallbackData*>(data)->m_impl;
106 } 108 }
107 }; 109 };
108 110
109 } // namespace blink 111 } // namespace blink
110 112
111 #endif // InspectorWrapper_h 113 #endif // InspectorWrapper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698