Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / v8 / PageScriptDebugServer.cpp
index 8311d67..0fcfb34 100644 (file)
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8ScriptRunner.h"
 #include "bindings/v8/V8WindowShell.h"
+#include "core/frame/FrameConsole.h"
 #include "core/frame/FrameHost.h"
 #include "core/frame/LocalFrame.h"
-#include "core/frame/PageConsole.h"
 #include "core/frame/UseCounter.h"
 #include "core/inspector/InspectorInstrumentation.h"
+#include "core/inspector/InspectorTraceEvents.h"
 #include "core/inspector/ScriptDebugListener.h"
 #include "core/page/Page.h"
 #include "wtf/OwnPtr.h"
@@ -89,12 +90,23 @@ PageScriptDebugServer& PageScriptDebugServer::shared()
     return server;
 }
 
+v8::Isolate* PageScriptDebugServer::s_mainThreadIsolate = 0;
+
+void PageScriptDebugServer::setMainThreadIsolate(v8::Isolate* isolate)
+{
+    s_mainThreadIsolate = isolate;
+}
+
 PageScriptDebugServer::PageScriptDebugServer()
-    : ScriptDebugServer(v8::Isolate::GetCurrent())
+    : ScriptDebugServer(s_mainThreadIsolate)
     , m_pausedPage(0)
 {
 }
 
+PageScriptDebugServer::~PageScriptDebugServer()
+{
+}
+
 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page)
 {
     ScriptController& scriptController = page->mainFrame()->script();
@@ -143,16 +155,21 @@ void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page*
     // FIXME: Remove all breakpoints set by the agent.
 }
 
+void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task)
+{
+    ScriptDebugServer::interruptAndRun(task, s_mainThreadIsolate);
+}
+
 void PageScriptDebugServer::setClientMessageLoop(PassOwnPtr<ClientMessageLoop> clientMessageLoop)
 {
     m_clientMessageLoop = clientMessageLoop;
 }
 
-void PageScriptDebugServer::compileScript(ScriptState* state, const String& expression, const String& sourceURL, String* scriptId, String* exceptionMessage)
+void PageScriptDebugServer::compileScript(ScriptState* scriptState, const String& expression, const String& sourceURL, String* scriptId, String* exceptionMessage)
 {
-    ExecutionContext* executionContext = state->executionContext();
+    ExecutionContext* executionContext = scriptState->executionContext();
     RefPtr<LocalFrame> protect = toDocument(executionContext)->frame();
-    ScriptDebugServer::compileScript(state, expression, sourceURL, scriptId, exceptionMessage);
+    ScriptDebugServer::compileScript(scriptState, expression, sourceURL, scriptId, exceptionMessage);
     if (!scriptId->isNull())
         m_compiledScriptURLs.set(*scriptId, sourceURL);
 }
@@ -163,21 +180,25 @@ void PageScriptDebugServer::clearCompiledScripts()
     m_compiledScriptURLs.clear();
 }
 
-void PageScriptDebugServer::runScript(ScriptState* state, const String& scriptId, ScriptValue* result, bool* wasThrown, String* exceptionMessage)
+void PageScriptDebugServer::runScript(ScriptState* scriptState, const String& scriptId, ScriptValue* result, bool* wasThrown, String* exceptionMessage)
 {
     String sourceURL = m_compiledScriptURLs.take(scriptId);
 
-    ExecutionContext* executionContext = state->executionContext();
+    ExecutionContext* executionContext = scriptState->executionContext();
     LocalFrame* frame = toDocument(executionContext)->frame();
+    TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EvaluateScript", "data", InspectorEvaluateScriptEvent::data(frame, sourceURL, TextPosition::minimumPosition().m_line.oneBasedInt()));
+    TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack());
+    // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing.
     InspectorInstrumentationCookie cookie;
     if (frame)
         cookie = InspectorInstrumentation::willEvaluateScript(frame, sourceURL, TextPosition::minimumPosition().m_line.oneBasedInt());
 
     RefPtr<LocalFrame> protect = frame;
-    ScriptDebugServer::runScript(state, scriptId, result, wasThrown, exceptionMessage);
+    ScriptDebugServer::runScript(scriptState, scriptId, result, wasThrown, exceptionMessage);
 
     if (frame)
         InspectorInstrumentation::didEvaluateScript(cookie);
+    TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data());
 }
 
 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handle<v8::Context> context)
@@ -286,13 +307,13 @@ String PageScriptDebugServer::preprocessEventListener(LocalFrame* frame, const S
 
 void PageScriptDebugServer::muteWarningsAndDeprecations()
 {
-    PageConsole::mute();
+    FrameConsole::mute();
     UseCounter::muteForInspector();
 }
 
 void PageScriptDebugServer::unmuteWarningsAndDeprecations()
 {
-    PageConsole::unmute();
+    FrameConsole::unmute();
     UseCounter::unmuteForInspector();
 }