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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InjectedScriptHost.h

Issue 1601283003: DevTools: deoilpanize inspector/v8 and related classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed. Created 4 years, 11 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 class V8DebuggerAgent; 50 class V8DebuggerAgent;
51 class V8Debugger; 51 class V8Debugger;
52 52
53 class EventListenerInfo; 53 class EventListenerInfo;
54 54
55 // SECURITY NOTE: Although the InjectedScriptHost is intended for use solely by the inspector, 55 // SECURITY NOTE: Although the InjectedScriptHost is intended for use solely by the inspector,
56 // a reference to the InjectedScriptHost may be leaked to the page being inspect ed. Thus, the 56 // a reference to the InjectedScriptHost may be leaked to the page being inspect ed. Thus, the
57 // InjectedScriptHost must never implemment methods that have more power over th e page than the 57 // InjectedScriptHost must never implemment methods that have more power over th e page than the
58 // page already has itself (e.g. origin restriction bypasses). 58 // page already has itself (e.g. origin restriction bypasses).
59 59
60 class InjectedScriptHost : public RefCountedWillBeGarbageCollectedFinalized<Inje ctedScriptHost> { 60 class InjectedScriptHost : public RefCounted<InjectedScriptHost> {
61 public: 61 public:
62 static PassRefPtrWillBeRawPtr<InjectedScriptHost> create(); 62 static PassRefPtr<InjectedScriptHost> create();
63 ~InjectedScriptHost(); 63 ~InjectedScriptHost();
64 DECLARE_TRACE();
65 64
66 using InspectCallback = Function<void(PassRefPtr<TypeBuilder::Runtime::Remot eObject>, PassRefPtr<JSONObject>)>; 65 using InspectCallback = Function<void(PassRefPtr<TypeBuilder::Runtime::Remot eObject>, PassRefPtr<JSONObject>)>;
66 using ClearConsoleCallback = Function<void()>;
67 67
68 void init(InspectorConsoleAgent* consoleAgent, V8DebuggerAgent* debuggerAgen t, PassOwnPtr<InspectCallback> inspectCallback, V8Debugger* debugger, PassOwnPtr <InjectedScriptHostClient> injectedScriptHostClient) 68 void init(V8DebuggerAgent* debuggerAgent, PassOwnPtr<InspectCallback> inspec tCallback, PassOwnPtr<ClearConsoleCallback> clearConsoleCallback, V8Debugger* de bugger, PassOwnPtr<InjectedScriptHostClient> injectedScriptHostClient)
69 { 69 {
70 m_consoleAgent = consoleAgent;
71 m_debuggerAgent = debuggerAgent; 70 m_debuggerAgent = debuggerAgent;
72 m_inspectCallback = std::move(inspectCallback); 71 m_inspectCallback = std::move(inspectCallback);
72 m_clearConsoleCallback = std::move(clearConsoleCallback);
73 m_debugger = debugger; 73 m_debugger = debugger;
74 m_client = std::move(injectedScriptHostClient); 74 m_client = std::move(injectedScriptHostClient);
75 } 75 }
76 76
77 static EventTarget* eventTargetFromV8Value(v8::Isolate*, v8::Local<v8::Value >); 77 static EventTarget* eventTargetFromV8Value(v8::Isolate*, v8::Local<v8::Value >);
78 78
79 void disconnect(); 79 void disconnect();
80 80
81 class InspectableObject : public NoBaseWillBeGarbageCollectedFinalized<Inspe ctableObject> { 81 class InspectableObject {
82 USING_FAST_MALLOC_WILL_BE_REMOVED(InspectableObject); 82 USING_FAST_MALLOC(InspectableObject);
83 public: 83 public:
84 virtual ScriptValue get(ScriptState*); 84 virtual ScriptValue get(ScriptState*);
85 virtual ~InspectableObject() { } 85 virtual ~InspectableObject() { }
86 DEFINE_INLINE_VIRTUAL_TRACE() { }
87 }; 86 };
88 void addInspectedObject(PassOwnPtrWillBeRawPtr<InspectableObject>); 87 void addInspectedObject(PassOwnPtr<InspectableObject>);
89 void clearInspectedObjects(); 88 void clearInspectedObjects();
90 InspectableObject* inspectedObject(unsigned num); 89 InspectableObject* inspectedObject(unsigned num);
91 90
92 void inspectImpl(PassRefPtr<JSONValue> objectToInspect, PassRefPtr<JSONValue > hints); 91 void inspectImpl(PassRefPtr<JSONValue> objectToInspect, PassRefPtr<JSONValue > hints);
93 void getEventListenersImpl(EventTarget*, WillBeHeapVector<EventListenerInfo> & listenersArray); 92 void getEventListenersImpl(EventTarget*, WillBeHeapVector<EventListenerInfo> & listenersArray);
94 93
95 void clearConsoleMessages(); 94 void clearConsoleMessages();
96 void debugFunction(const String& scriptId, int lineNumber, int columnNumber) ; 95 void debugFunction(const String& scriptId, int lineNumber, int columnNumber) ;
97 void undebugFunction(const String& scriptId, int lineNumber, int columnNumbe r); 96 void undebugFunction(const String& scriptId, int lineNumber, int columnNumbe r);
98 void monitorFunction(const String& scriptId, int lineNumber, int columnNumbe r, const String& functionName); 97 void monitorFunction(const String& scriptId, int lineNumber, int columnNumbe r, const String& functionName);
99 void unmonitorFunction(const String& scriptId, int lineNumber, int columnNum ber); 98 void unmonitorFunction(const String& scriptId, int lineNumber, int columnNum ber);
100 99
101 V8Debugger& debugger() { return *m_debugger; } 100 V8Debugger& debugger() { return *m_debugger; }
102 InjectedScriptHostClient* client() { return m_client.get(); } 101 InjectedScriptHostClient* client() { return m_client.get(); }
103 102
104 // FIXME: store this template in per isolate data 103 // FIXME: store this template in per isolate data
105 void setWrapperTemplate(v8::Local<v8::FunctionTemplate> wrapperTemplate, v8: :Isolate* isolate) { m_wrapperTemplate.Reset(isolate, wrapperTemplate); } 104 void setWrapperTemplate(v8::Local<v8::FunctionTemplate> wrapperTemplate, v8: :Isolate* isolate) { m_wrapperTemplate.Reset(isolate, wrapperTemplate); }
106 v8::Local<v8::FunctionTemplate> wrapperTemplate(v8::Isolate* isolate) { retu rn v8::Local<v8::FunctionTemplate>::New(isolate, m_wrapperTemplate); } 105 v8::Local<v8::FunctionTemplate> wrapperTemplate(v8::Isolate* isolate) { retu rn v8::Local<v8::FunctionTemplate>::New(isolate, m_wrapperTemplate); }
107 106
108 private: 107 private:
109 InjectedScriptHost(); 108 InjectedScriptHost();
110 109
111 RawPtrWillBeMember<InspectorConsoleAgent> m_consoleAgent;
112 V8DebuggerAgent* m_debuggerAgent; 110 V8DebuggerAgent* m_debuggerAgent;
113 OwnPtr<InspectCallback> m_inspectCallback; 111 OwnPtr<InspectCallback> m_inspectCallback;
112 OwnPtr<ClearConsoleCallback> m_clearConsoleCallback;
114 V8Debugger* m_debugger; 113 V8Debugger* m_debugger;
115 WillBeHeapVector<OwnPtrWillBeMember<InspectableObject>> m_inspectedObjects; 114 Vector<OwnPtr<InspectableObject>> m_inspectedObjects;
116 OwnPtrWillBeMember<InspectableObject> m_defaultInspectableObject; 115 OwnPtr<InspectableObject> m_defaultInspectableObject;
117 OwnPtr<InjectedScriptHostClient> m_client; 116 OwnPtr<InjectedScriptHostClient> m_client;
118 v8::Global<v8::FunctionTemplate> m_wrapperTemplate; 117 v8::Global<v8::FunctionTemplate> m_wrapperTemplate;
119 }; 118 };
120 119
121 } // namespace blink 120 } // namespace blink
122 121
123 #endif // InjectedScriptHost_h 122 #endif // InjectedScriptHost_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698