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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp

Issue 2087953004: Switch v8 inspector to stl collections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 else 288 else
289 *errorString = "Script compilation failed"; 289 *errorString = "Script compilation failed";
290 return; 290 return;
291 } 291 }
292 292
293 if (!persistScript) 293 if (!persistScript)
294 return; 294 return;
295 295
296 String16 scriptValueId = String16::number(script->GetUnboundScript()->GetId( )); 296 String16 scriptValueId = String16::number(script->GetUnboundScript()->GetId( ));
297 std::unique_ptr<v8::Global<v8::Script>> global(new v8::Global<v8::Script>(m_ debugger->isolate(), script)); 297 std::unique_ptr<v8::Global<v8::Script>> global(new v8::Global<v8::Script>(m_ debugger->isolate(), script));
298 m_compiledScripts.set(scriptValueId, std::move(global)); 298 m_compiledScripts[scriptValueId] = std::move(global);
299 *scriptId = scriptValueId; 299 *scriptId = scriptValueId;
300 } 300 }
301 301
302 void V8RuntimeAgentImpl::runScript(ErrorString* errorString, 302 void V8RuntimeAgentImpl::runScript(ErrorString* errorString,
303 const String16& scriptId, 303 const String16& scriptId,
304 int executionContextId, 304 int executionContextId,
305 const Maybe<String16>& objectGroup, 305 const Maybe<String16>& objectGroup,
306 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, 306 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole,
307 const Maybe<bool>& includeCommandLineAPI, 307 const Maybe<bool>& includeCommandLineAPI,
308 std::unique_ptr<RemoteObject>* result, 308 std::unique_ptr<RemoteObject>* result,
309 Maybe<ExceptionDetails>* exceptionDetails) 309 Maybe<ExceptionDetails>* exceptionDetails)
310 { 310 {
311 if (!m_enabled) { 311 if (!m_enabled) {
312 *errorString = "Runtime agent is not enabled"; 312 *errorString = "Runtime agent is not enabled";
313 return; 313 return;
314 } 314 }
315 315
316 if (!m_compiledScripts.contains(scriptId)) { 316 auto it = m_compiledScripts.find(scriptId);
317 if (it == m_compiledScripts.end()) {
317 *errorString = "Script execution failed"; 318 *errorString = "Script execution failed";
318 return; 319 return;
319 } 320 }
320 321
321 InjectedScript::ContextScope scope(errorString, m_debugger, m_session->conte xtGroupId(), executionContextId); 322 InjectedScript::ContextScope scope(errorString, m_debugger, m_session->conte xtGroupId(), executionContextId);
322 if (!scope.initialize()) 323 if (!scope.initialize())
323 return; 324 return;
324 325
325 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) 326 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false))
326 scope.ignoreExceptionsAndMuteConsole(); 327 scope.ignoreExceptionsAndMuteConsole();
327 328
328 std::unique_ptr<v8::Global<v8::Script>> scriptWrapper = m_compiledScripts.ta ke(scriptId); 329 std::unique_ptr<v8::Global<v8::Script>> scriptWrapper = std::move(it->second );
330 m_compiledScripts.erase(it);
329 v8::Local<v8::Script> script = scriptWrapper->Get(m_debugger->isolate()); 331 v8::Local<v8::Script> script = scriptWrapper->Get(m_debugger->isolate());
330 if (script.IsEmpty()) { 332 if (script.IsEmpty()) {
331 *errorString = "Script execution failed"; 333 *errorString = "Script execution failed";
332 return; 334 return;
333 } 335 }
334 336
335 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI() ) 337 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI() )
336 return; 338 return;
337 339
338 v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->runCompiledScript(s cope.context(), script); 340 v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->runCompiledScript(s cope.context(), script);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 412 }
411 } 413 }
412 414
413 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject > objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints) 415 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject > objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints)
414 { 416 {
415 if (m_enabled) 417 if (m_enabled)
416 m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints) ); 418 m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints) );
417 } 419 }
418 420
419 } // namespace blink 421 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698