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

Side by Side Diff: sky/engine/v8_inspector/InjectedScriptManager.cpp

Issue 776743002: Make v8 inspector not crash (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "sky/engine/config.h" 31 #include "sky/engine/config.h"
32 #include "sky/engine/v8_inspector/InjectedScriptManager.h" 32 #include "sky/engine/v8_inspector/InjectedScriptManager.h"
33 33
34 #include "sky/engine/bindings/core/v8/ScriptValue.h" 34 #include "sky/engine/bindings/core/v8/ScriptValue.h"
35 #include "sky/engine/core/inspector/InjectedScriptHost.h" 35 #include "sky/engine/core/inspector/InjectedScriptHost.h"
36 #include "sky/engine/platform/JSONValues.h" 36 #include "sky/engine/platform/JSONValues.h"
37 #include "sky/engine/public/platform/Platform.h"
38 #include "sky/engine/public/platform/WebData.h"
39 #include "sky/engine/v8_inspector/InjectedScript.h" 37 #include "sky/engine/v8_inspector/InjectedScript.h"
40 #include "sky/engine/v8_inspector/JSONParser.h" 38 #include "sky/engine/v8_inspector/JSONParser.h"
39 #include "sky/engine/v8_inspector/read_from_source_tree.h"
41 #include "sky/engine/wtf/PassOwnPtr.h" 40 #include "sky/engine/wtf/PassOwnPtr.h"
42 41
43 namespace blink { 42 namespace blink {
44 43
45 PassOwnPtr<InjectedScriptManager> InjectedScriptManager::createForPage() 44 PassOwnPtr<InjectedScriptManager> InjectedScriptManager::createForPage()
46 { 45 {
47 return adoptPtr(new InjectedScriptManager); 46 return adoptPtr(new InjectedScriptManager);
48 } 47 }
49 48
50 InjectedScriptManager::InjectedScriptManager() 49 InjectedScriptManager::InjectedScriptManager()
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k eys().end()); 139 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k eys().end());
141 for (Vector<int>::iterator k = keys.begin(); k != keys.end(); ++k) { 140 for (Vector<int>::iterator k = keys.begin(); k != keys.end(); ++k) {
142 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(*k); 141 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(*k);
143 if (s != m_idToInjectedScript.end()) 142 if (s != m_idToInjectedScript.end())
144 s->value.releaseObjectGroup(objectGroup); // m_idToInjectedScript ma y change here. 143 s->value.releaseObjectGroup(objectGroup); // m_idToInjectedScript ma y change here.
145 } 144 }
146 } 145 }
147 146
148 String InjectedScriptManager::injectedScriptSource() 147 String InjectedScriptManager::injectedScriptSource()
149 { 148 {
150 const blink::WebData& injectedScriptSourceResource = blink::Platform::curren t()->loadResource("InjectedScriptSource.js"); 149 std::string buffer;
151 return String(injectedScriptSourceResource.data(), injectedScriptSourceResou rce.size()); 150 inspector::ReadFileFromSourceTree("InjectedScriptSource.js", &buffer);
151 return String::fromUTF8(buffer);
152 } 152 }
153 153
154 InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* inspectedSc riptState) 154 InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* inspectedSc riptState)
155 { 155 {
156 ScriptStateToId::iterator it = m_scriptStateToId.find(inspectedScriptState); 156 ScriptStateToId::iterator it = m_scriptStateToId.find(inspectedScriptState);
157 if (it != m_scriptStateToId.end()) { 157 if (it != m_scriptStateToId.end()) {
158 IdToInjectedScriptMap::iterator it1 = m_idToInjectedScript.find(it->valu e); 158 IdToInjectedScriptMap::iterator it1 = m_idToInjectedScript.find(it->valu e);
159 if (it1 != m_idToInjectedScript.end()) 159 if (it1 != m_idToInjectedScript.end())
160 return it1->value; 160 return it1->value;
161 } 161 }
162 162
163 int id = injectedScriptIdFor(inspectedScriptState); 163 int id = injectedScriptIdFor(inspectedScriptState);
164 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource( ), inspectedScriptState, id); 164 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource( ), inspectedScriptState, id);
165 InjectedScript result(injectedScriptValue); 165 InjectedScript result(injectedScriptValue);
166 m_idToInjectedScript.set(id, result); 166 m_idToInjectedScript.set(id, result);
167 167
168 // TODO(yurys): InjecedScript should be available as a regular module rather that using a global variable. 168 // TODO(yurys): InjecedScript should be available as a regular module rather that using a global variable.
169 v8::Isolate* isolate = inspectedScriptState->isolate(); 169 v8::Isolate* isolate = inspectedScriptState->isolate();
170 v8::Local<v8::Object> global = inspectedScriptState->context()->Global(); 170 v8::Local<v8::Object> global = inspectedScriptState->context()->Global();
171 global->Set(v8::String::NewFromUtf8(isolate, "injectedScript"), injectedScri ptValue.v8ValueUnsafe()); 171 global->Set(v8::String::NewFromUtf8(isolate, "injectedScript"), injectedScri ptValue.v8ValueUnsafe());
172 return result; 172 return result;
173 } 173 }
174 174
175 } // namespace blink 175 } // namespace blink
176 176
OLDNEW
« no previous file with comments | « sky/engine/v8_inspector/DebuggerScript.js ('k') | sky/engine/v8_inspector/ScriptDebugServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698