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

Side by Side Diff: src/inspector/V8InjectedScriptHost.cpp

Issue 2292053003: [inspector] Build inspector under v8_enable_inspector build flag. (Closed)
Patch Set: owners Created 4 years, 3 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 V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project 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 #include "src/inspector/V8InjectedScriptHost.h" 5 #include "src/inspector/V8InjectedScriptHost.h"
6 6
7 #include "src/base/macros.h"
7 #include "src/inspector/InjectedScriptNative.h" 8 #include "src/inspector/InjectedScriptNative.h"
8 #include "src/inspector/StringUtil.h" 9 #include "src/inspector/StringUtil.h"
9 #include "src/inspector/V8Compat.h"
10 #include "src/inspector/V8Debugger.h" 10 #include "src/inspector/V8Debugger.h"
11 #include "src/inspector/V8InspectorImpl.h" 11 #include "src/inspector/V8InspectorImpl.h"
12 #include "src/inspector/V8InternalValueType.h" 12 #include "src/inspector/V8InternalValueType.h"
13 #include "src/inspector/V8ValueCopier.h" 13 #include "src/inspector/V8ValueCopier.h"
14 #include "src/inspector/public/V8InspectorClient.h" 14
15 #include "include/v8-inspector.h"
15 16
16 namespace v8_inspector { 17 namespace v8_inspector {
17 18
18 namespace { 19 namespace {
19 20
20 void setFunctionProperty(v8::Local<v8::Context> context, 21 void setFunctionProperty(v8::Local<v8::Context> context,
21 v8::Local<v8::Object> obj, const char* name, 22 v8::Local<v8::Object> obj, const char* name,
22 v8::FunctionCallback callback, 23 v8::FunctionCallback callback,
23 v8::Local<v8::External> external) { 24 v8::Local<v8::External> external) {
24 v8::Local<v8::String> funcName = 25 v8::Local<v8::String> funcName =
25 toV8StringInternalized(context->GetIsolate(), name); 26 toV8StringInternalized(context->GetIsolate(), name);
26 v8::Local<v8::Function> func; 27 v8::Local<v8::Function> func;
27 if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, external, 0) 28 if (!v8::Function::New(context, callback, external, 0,
29 v8::ConstructorBehavior::kThrow)
28 .ToLocal(&func)) 30 .ToLocal(&func))
29 return; 31 return;
30 func->SetName(funcName); 32 func->SetName(funcName);
31 createDataProperty(context, obj, funcName, func); 33 createDataProperty(context, obj, funcName, func);
32 } 34 }
33 35
34 V8InspectorImpl* unwrapInspector( 36 V8InspectorImpl* unwrapInspector(
35 const v8::FunctionCallbackInfo<v8::Value>& info) { 37 const v8::FunctionCallbackInfo<v8::Value>& info) {
36 DCHECK(!info.Data().IsEmpty()); 38 DCHECK(!info.Data().IsEmpty());
37 DCHECK(info.Data()->IsExternal()); 39 DCHECK(info.Data()->IsExternal());
38 V8InspectorImpl* inspector = 40 V8InspectorImpl* inspector =
39 static_cast<V8InspectorImpl*>(info.Data().As<v8::External>()->Value()); 41 static_cast<V8InspectorImpl*>(info.Data().As<v8::External>()->Value());
40 DCHECK(inspector); 42 DCHECK(inspector);
41 return inspector; 43 return inspector;
42 } 44 }
43 45
44 } // namespace 46 } // namespace
45 47
46 v8::Local<v8::Object> V8InjectedScriptHost::create( 48 v8::Local<v8::Object> V8InjectedScriptHost::create(
47 v8::Local<v8::Context> context, V8InspectorImpl* inspector) { 49 v8::Local<v8::Context> context, V8InspectorImpl* inspector) {
48 v8::Isolate* isolate = inspector->isolate(); 50 v8::Isolate* isolate = inspector->isolate();
49 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); 51 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate);
50 bool success = injectedScriptHost->SetPrototype(context, v8::Null(isolate)) 52 bool success = injectedScriptHost->SetPrototype(context, v8::Null(isolate))
51 .FromMaybe(false); 53 .FromMaybe(false);
52 DCHECK(success); 54 DCHECK(success);
55 USE(success);
53 v8::Local<v8::External> debuggerExternal = 56 v8::Local<v8::External> debuggerExternal =
54 v8::External::New(isolate, inspector); 57 v8::External::New(isolate, inspector);
55 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", 58 setFunctionProperty(context, injectedScriptHost, "internalConstructorName",
56 V8InjectedScriptHost::internalConstructorNameCallback, 59 V8InjectedScriptHost::internalConstructorNameCallback,
57 debuggerExternal); 60 debuggerExternal);
58 setFunctionProperty( 61 setFunctionProperty(
59 context, injectedScriptHost, "formatAccessorsAsProperties", 62 context, injectedScriptHost, "formatAccessorsAsProperties",
60 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); 63 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal);
61 setFunctionProperty(context, injectedScriptHost, "subtype", 64 setFunctionProperty(context, injectedScriptHost, "subtype",
62 V8InjectedScriptHost::subtypeCallback, debuggerExternal); 65 V8InjectedScriptHost::subtypeCallback, debuggerExternal);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 194
192 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); 195 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate());
193 String16 groupName = toProtocolStringWithTypeCheck(v8groupName); 196 String16 groupName = toProtocolStringWithTypeCheck(v8groupName);
194 int id = injectedScriptNative->bind(info[0], groupName); 197 int id = injectedScriptNative->bind(info[0], groupName);
195 info.GetReturnValue().Set(id); 198 info.GetReturnValue().Set(id);
196 } 199 }
197 200
198 void V8InjectedScriptHost::proxyTargetValueCallback( 201 void V8InjectedScriptHost::proxyTargetValueCallback(
199 const v8::FunctionCallbackInfo<v8::Value>& info) { 202 const v8::FunctionCallbackInfo<v8::Value>& info) {
200 if (info.Length() != 1 || !info[0]->IsProxy()) { 203 if (info.Length() != 1 || !info[0]->IsProxy()) {
201 NOTREACHED(); 204 UNREACHABLE();
202 return; 205 return;
203 } 206 }
204 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); 207 v8::Local<v8::Object> target = info[0].As<v8::Proxy>();
205 while (target->IsProxy()) 208 while (target->IsProxy())
206 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); 209 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget();
207 info.GetReturnValue().Set(target); 210 info.GetReturnValue().Set(target);
208 } 211 }
209 212
210 } // namespace v8_inspector 213 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698