Commit 3adc7312 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2010-03-04 Andrey Kosyakov <caseq@chromium.org>

        Reviewed by Pavel Feldman.

        Added support for worker instrumentation in inspector
        (display list of active workers, allow debugging of workers
        by injecting fake JS implementation)

        https://bugs.webkit.org/show_bug.cgi?id=35568

        * English.lproj/localizedStrings.js:
        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * bindings/js/JSInjectedScriptHostCustom.cpp:
        (WebCore::InjectedScriptHost::createInjectedScript):
        (WebCore::InjectedScriptHost::injectedScriptFor):
        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
        (WebCore::InjectedScriptHost::createInjectedScript):
        (WebCore::InjectedScriptHost::injectedScriptFor):
        * dom/Document.cpp:
        (WebCore::Document::inspectorController):
        * dom/Document.h:
        * dom/ScriptExecutionContext.h:
        (WebCore::ScriptExecutionContext::inspectorController):
        * inspector/InjectedScriptHost.cpp:
        (WebCore::InjectedScriptHost::InjectedScriptHost):
        (WebCore::InjectedScriptHost::injectScript):
        (WebCore::InjectedScriptHost::nextWorkerId):
        (WebCore::InjectedScriptHost::didCreateWorker):
        (WebCore::InjectedScriptHost::willDestroyWorker):
        * inspector/InjectedScriptHost.h:
        * inspector/InjectedScriptHost.idl:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::populateScriptObjects):
        (WebCore::InspectorController::resetScriptObjects):
        (WebCore::InspectorController::didCommitLoad):
        (WebCore::InspectorController::didCreateWorker):
        (WebCore::InspectorController::willDestroyWorker):
        * inspector/InspectorController.h:
        * inspector/InspectorFrontend.cpp:
        (WebCore::InspectorFrontend::didCreateWorker):
        (WebCore::InspectorFrontend::willDestroyWorker):
        * inspector/InspectorFrontend.h:
        * inspector/InspectorWorkerResource.h: Added.
        (WebCore::InspectorWorkerResource::create):
        (WebCore::InspectorWorkerResource::id):
        (WebCore::InspectorWorkerResource::url):
        (WebCore::InspectorWorkerResource::isSharedWorker):
        (WebCore::InspectorWorkerResource::InspectorWorkerResource):
        * inspector/front-end/Checkbox.js: Added.
        (WebInspector.Checkbox.callbackWrapper):
        (WebInspector.Checkbox):
        (WebInspector.Checkbox.prototype.checked):
        * inspector/front-end/InjectedFakeWorker.js:
        (InjectedFakeWorker.FakeWorker):
        (InjectedFakeWorker.FakeWorker.prototype.terminate):
        (InjectedFakeWorker.FakeWorker.prototype._handleException):
        (InjectedFakeWorker.FakeWorker.prototype._importScripts):
        (InjectedFakeWorker.FakeWorker.prototype._loadScript):
        (InjectedFakeWorker.FakeWorker.prototype._expandURLAndCheckOrigin):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel):
        (WebInspector.ScriptsPanel.prototype.debuggerWasEnabled):
        (WebInspector.ScriptsPanel.prototype.debuggerWasDisabled):
        (WebInspector.ScriptsPanel.prototype.reset):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/WorkersSidebarPane.js: Added.
        (WebInspector.WorkersSidebarPane):
        (WebInspector.WorkersSidebarPane.prototype.addWorker):
        (WebInspector.WorkersSidebarPane.prototype.removeWorker):
        (WebInspector.WorkersSidebarPane.prototype.setInstrumentation):
        (WebInspector.WorkersSidebarPane.prototype.reset):
        (WebInspector.WorkersSidebarPane.prototype._onTriggerInstrument):
        (WebInspector.Worker):
        (WebInspector.didCreateWorker):
        (WebInspector.willDestroyWorker):
        * inspector/front-end/inspector.css:
        * inspector/front-end/inspector.html:
        * workers/AbstractWorker.cpp:
        (WebCore::AbstractWorker::AbstractWorker):
        (WebCore::AbstractWorker::~AbstractWorker):
        (WebCore::AbstractWorker::onDestroyWorker):
        (WebCore::AbstractWorker::contextDestroyed):
        * workers/AbstractWorker.h:
        (WebCore::AbstractWorker::id):
        * workers/SharedWorker.cpp:
        (WebCore::SharedWorker::SharedWorker):
        * workers/Worker.cpp:
        (WebCore::Worker::Worker):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55522 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6044a6e5
2010-03-04 Andrey Kosyakov <caseq@chromium.org>
Reviewed by Pavel Feldman.
Added support for worker instrumentation in inspector
(display list of active workers, allow debugging of workers
by injecting fake JS implementation)
https://bugs.webkit.org/show_bug.cgi?id=35568
* English.lproj/localizedStrings.js:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::InjectedScriptHost::createInjectedScript):
(WebCore::InjectedScriptHost::injectedScriptFor):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::InjectedScriptHost::createInjectedScript):
(WebCore::InjectedScriptHost::injectedScriptFor):
* dom/Document.cpp:
(WebCore::Document::inspectorController):
* dom/Document.h:
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::inspectorController):
* inspector/InjectedScriptHost.cpp:
(WebCore::InjectedScriptHost::InjectedScriptHost):
(WebCore::InjectedScriptHost::injectScript):
(WebCore::InjectedScriptHost::nextWorkerId):
(WebCore::InjectedScriptHost::didCreateWorker):
(WebCore::InjectedScriptHost::willDestroyWorker):
* inspector/InjectedScriptHost.h:
* inspector/InjectedScriptHost.idl:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::populateScriptObjects):
(WebCore::InspectorController::resetScriptObjects):
(WebCore::InspectorController::didCommitLoad):
(WebCore::InspectorController::didCreateWorker):
(WebCore::InspectorController::willDestroyWorker):
* inspector/InspectorController.h:
* inspector/InspectorFrontend.cpp:
(WebCore::InspectorFrontend::didCreateWorker):
(WebCore::InspectorFrontend::willDestroyWorker):
* inspector/InspectorFrontend.h:
* inspector/InspectorWorkerResource.h: Added.
(WebCore::InspectorWorkerResource::create):
(WebCore::InspectorWorkerResource::id):
(WebCore::InspectorWorkerResource::url):
(WebCore::InspectorWorkerResource::isSharedWorker):
(WebCore::InspectorWorkerResource::InspectorWorkerResource):
* inspector/front-end/Checkbox.js: Added.
(WebInspector.Checkbox.callbackWrapper):
(WebInspector.Checkbox):
(WebInspector.Checkbox.prototype.checked):
* inspector/front-end/InjectedFakeWorker.js:
(InjectedFakeWorker.FakeWorker):
(InjectedFakeWorker.FakeWorker.prototype.terminate):
(InjectedFakeWorker.FakeWorker.prototype._handleException):
(InjectedFakeWorker.FakeWorker.prototype._importScripts):
(InjectedFakeWorker.FakeWorker.prototype._loadScript):
(InjectedFakeWorker.FakeWorker.prototype._expandURLAndCheckOrigin):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel):
(WebInspector.ScriptsPanel.prototype.debuggerWasEnabled):
(WebInspector.ScriptsPanel.prototype.debuggerWasDisabled):
(WebInspector.ScriptsPanel.prototype.reset):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/WorkersSidebarPane.js: Added.
(WebInspector.WorkersSidebarPane):
(WebInspector.WorkersSidebarPane.prototype.addWorker):
(WebInspector.WorkersSidebarPane.prototype.removeWorker):
(WebInspector.WorkersSidebarPane.prototype.setInstrumentation):
(WebInspector.WorkersSidebarPane.prototype.reset):
(WebInspector.WorkersSidebarPane.prototype._onTriggerInstrument):
(WebInspector.Worker):
(WebInspector.didCreateWorker):
(WebInspector.willDestroyWorker):
* inspector/front-end/inspector.css:
* inspector/front-end/inspector.html:
* workers/AbstractWorker.cpp:
(WebCore::AbstractWorker::AbstractWorker):
(WebCore::AbstractWorker::~AbstractWorker):
(WebCore::AbstractWorker::onDestroyWorker):
(WebCore::AbstractWorker::contextDestroyed):
* workers/AbstractWorker.h:
(WebCore::AbstractWorker::id):
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::SharedWorker):
* workers/Worker.cpp:
(WebCore::Worker::Worker):
2010-03-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
Reviewed by Tor Arne Vestbø.
......
Bvar localizedStrings = new Object;
......
......@@ -1614,6 +1614,7 @@
'inspector/InspectorResource.h',
'inspector/InspectorTimelineAgent.cpp',
'inspector/InspectorTimelineAgent.h',
'inspector/InspectorWorkerResource.h',
'inspector/JavaScriptCallFrame.cpp',
'inspector/JavaScriptCallFrame.h',
'inspector/ScriptBreakpoint.h',
......@@ -3731,6 +3732,7 @@
'inspector/front-end/Callback.js',
'inspector/front-end/CallStackSidebarPane.js',
'inspector/front-end/ChangesView.js',
'inspector/front-end/Checkbox.js',
'inspector/front-end/Color.js',
'inspector/front-end/ConsolePanel.js',
'inspector/front-end/ConsoleView.js',
......@@ -3807,6 +3809,7 @@
'inspector/front-end/View.js',
'inspector/front-end/WatchExpressionsSidebarPane.js',
'inspector/front-end/WelcomeView.js',
'inspector/front-end/WorkersSidebarPane.js',
'inspector/front-end/audits.css',
'inspector/front-end/inspector.css',
'inspector/front-end/inspectorSyntaxHighlight.css',
......
......@@ -42716,6 +42716,10 @@
RelativePath="..\inspector\InspectorTimelineAgent.h"
>
</File>
<File
RelativePath="..\inspector\InspectorWorkerResource.h"
>
</File>
<File
RelativePath="..\inspector\JavaScriptCallFrame.cpp"
>
......@@ -42795,6 +42799,10 @@
RelativePath="..\inspector\front-end\ChangesView.js"
>
</File>
<File
RelativePath="..\inspector\front-end\Checkbox.js"
>
</File>
<File
RelativePath="..\inspector\front-end\Color.js"
>
......@@ -43103,6 +43111,10 @@
RelativePath="..\inspector\front-end\WelcomeView.js"
>
</File>
<File
RelativePath="..\inspector\front-end\WorkersSidebarPane.js"
>
</File>
</Filter>
</Filter>
<Filter
......
/*
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -75,7 +75,7 @@ using namespace JSC;
namespace WebCore {
static ScriptObject createInjectedScript(const String& source, InjectedScriptHost* injectedScriptHost, ScriptState* scriptState, long id)
ScriptObject InjectedScriptHost::createInjectedScript(const String& source, ScriptState* scriptState, long id)
{
SourceCode sourceCode = makeSource(source);
JSLock lock(SilenceAssertionsOnly);
......@@ -91,7 +91,7 @@ static ScriptObject createInjectedScript(const String& source, InjectedScriptHos
return ScriptObject();
MarkedArgumentBuffer args;
args.append(toJS(scriptState, globalObject, injectedScriptHost));
args.append(toJS(scriptState, globalObject, this));
args.append(globalThisValue);
args.append(jsNumber(scriptState, id));
JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args);
......@@ -221,12 +221,11 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
if (injectedScript)
return InjectedScript(ScriptObject(scriptState, injectedScript));
ASSERT(!m_injectedScriptSource.isEmpty());
ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId);
globalObject->setInjectedScript(injectedScriptObject.jsObject());
InjectedScript result(injectedScriptObject);
m_idToInjectedScript.set(m_nextInjectedScriptId, result);
m_nextInjectedScriptId++;
ASSERT(!m_injectedScriptSource.isEmpty());
pair<long, ScriptObject> injectedScriptObject = injectScript(m_injectedScriptSource, scriptState);
globalObject->setInjectedScript(injectedScriptObject.second.jsObject());
InjectedScript result(injectedScriptObject.second);
m_idToInjectedScript.set(injectedScriptObject.first, result);
return result;
}
......
......@@ -79,7 +79,7 @@ static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHos
return instance;
}
static ScriptObject createInjectedScript(const String& scriptSource, InjectedScriptHost* injectedScriptHost, ScriptState* inspectedScriptState, long id)
ScriptObject InjectedScriptHost::createInjectedScript(const String& scriptSource, ScriptState* inspectedScriptState, long id)
{
v8::HandleScope scope;
......@@ -90,7 +90,7 @@ static ScriptObject createInjectedScript(const String& scriptSource, InjectedScr
// instead of calling toV8() that would create the
// wrapper in the current context.
// FIXME: make it possible to use generic bindings factory for InjectedScriptHost.
v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(injectedScriptHost);
v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(this);
if (scriptHostWrapper.IsEmpty())
return ScriptObject();
......@@ -240,11 +240,10 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScrip
return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
ASSERT(!m_injectedScriptSource.isEmpty());
ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId);
InjectedScript result(injectedScriptObject);
m_idToInjectedScript.set(m_nextInjectedScriptId, result);
++m_nextInjectedScriptId;
global->SetHiddenValue(key, injectedScriptObject.v8Object());
pair<long, ScriptObject> injectedScript = injectScript(m_injectedScriptSource, inspectedScriptState);
InjectedScript result(injectedScript.second);
m_idToInjectedScript.set(injectedScript.first, result);
global->SetHiddenValue(key, injectedScript.second.v8Object());
return result;
}
......
......@@ -4798,6 +4798,11 @@ InspectorTimelineAgent* Document::inspectorTimelineAgent() const
{
return page() ? page()->inspectorTimelineAgent() : 0;
}
InspectorController* Document::inspectorController() const
{
return page() ? page()->inspectorController() : 0;
}
#endif
} // namespace WebCore
......@@ -450,6 +450,7 @@ public:
Settings* settings() const; // can be NULL
#if ENABLE(INSPECTOR)
InspectorTimelineAgent* inspectorTimelineAgent() const; // can be NULL
virtual InspectorController* inspectorController() const; // can be NULL
#endif
PassRefPtr<Range> createRange();
......
......@@ -49,6 +49,9 @@ namespace WebCore {
class SecurityOrigin;
class ScriptString;
class String;
#if ENABLE(INSPECTOR)
class InspectorController;
#endif
enum MessageDestination {
#if ENABLE(INSPECTOR)
......@@ -84,6 +87,9 @@ namespace WebCore {
virtual String userAgent(const KURL&) const = 0;
SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
#if ENABLE(INSPECTOR)
virtual InspectorController* inspectorController() const { return 0; }
#endif
virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL) = 0;
......
/*
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -70,6 +70,7 @@ namespace WebCore {
InjectedScriptHost::InjectedScriptHost(InspectorController* inspectorController)
: m_inspectorController(inspectorController)
, m_nextInjectedScriptId(1)
, m_lastWorkerId(1 << 31) // Distinguish ids of fake workers from real ones, to minimize the chances they overlap.
{
}
......@@ -194,6 +195,31 @@ InspectorFrontend* InjectedScriptHost::inspectorFrontend()
return m_inspectorController->m_frontend.get();
}
pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState)
{
long id = m_nextInjectedScriptId++;
return std::make_pair(id, createInjectedScript(source, scriptState, id));
}
#if ENABLE(WORKERS)
long InjectedScriptHost::nextWorkerId()
{
return ++m_lastWorkerId;
}
void InjectedScriptHost::didCreateWorker(long id, const String& url, bool isSharedWorker)
{
if (m_inspectorController)
m_inspectorController->didCreateWorker(id, url, isSharedWorker);
}
void InjectedScriptHost::willDestroyWorker(long id)
{
if (m_inspectorController)
m_inspectorController->willDestroyWorker(id);
}
#endif // ENABLE(WORKERS)
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
......@@ -79,9 +79,15 @@ public:
#endif
#if ENABLE(DOM_STORAGE)
void selectDOMStorage(Storage* storage);
#endif
#if ENABLE(WORKERS)
long nextWorkerId();
void didCreateWorker(long id, const String& url, bool isSharedWorker);
void willDestroyWorker(long id);
#endif
void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException);
pair<long, ScriptObject> injectScript(const String& source, ScriptState*);
InjectedScript injectedScriptFor(ScriptState*);
InjectedScript injectedScriptForId(long);
void discardInjectedScripts();
......@@ -91,10 +97,12 @@ private:
InjectedScriptHost(InspectorController* inspectorController);
InspectorDOMAgent* inspectorDOMAgent();
InspectorFrontend* inspectorFrontend();
ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id);
InspectorController* m_inspectorController;
String m_injectedScriptSource;
long m_nextInjectedScriptId;
long m_lastWorkerId;
typedef HashMap<long, InjectedScript> IdToInjectedScriptMap;
IdToInjectedScriptMap m_idToInjectedScript;
};
......
/*
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -55,6 +55,11 @@ module core {
[Custom] void selectDOMStorage(in DOMObject storage);
#endif
#if defined(ENABLE_WORKERS) && ENABLE_WORKERS
void didCreateWorker(in long id, in DOMString url, in boolean isFakeWorker);
void willDestroyWorker(in long id);
long nextWorkerId();
#endif
[Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException);
};
}
......@@ -63,6 +63,7 @@
#include "InspectorFrontend.h"
#include "InspectorFrontendHost.h"
#include "InspectorResource.h"
#include "InspectorWorkerResource.h"
#include "InspectorTimelineAgent.h"
#include "Page.h"
#include "ProgressTracker.h"
......@@ -689,7 +690,11 @@ void InspectorController::populateScriptObjects()
for (DOMStorageResourcesMap::iterator it = m_domStorageResources.begin(); it != domStorageEnd; ++it)
it->second->bind(m_frontend.get());
#endif
#if ENABLE(WORKERS)
WorkersMap::iterator workersEnd = m_workers.end();
for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it)
m_frontend->didCreateWorker(*it->second);
#endif
if (m_profilerEnabled)
m_frontend->profilerWasEnabled();
......@@ -720,7 +725,9 @@ void InspectorController::resetScriptObjects()
for (DOMStorageResourcesMap::iterator it = m_domStorageResources.begin(); it != domStorageEnd; ++it)
it->second->unbind();
#endif
#if ENABLE(WORKERS)
m_workers.clear();
#endif
if (m_timelineAgent)
m_timelineAgent->reset();
......@@ -807,10 +814,10 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
if (ResourcesMap* resourceMap = m_frameResources.get(frame))
pruneResources(resourceMap, loader);
ScriptState* scriptState = mainWorldScriptState(loader->frame());
for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
it != m_scriptsToEvaluateOnLoad.end(); ++it) {
ScriptSourceCode scriptSourceCode(*it);
loader->frame()->script()->evaluate(scriptSourceCode);
m_injectedScriptHost->injectScript(*it, scriptState);
}
}
......@@ -1153,6 +1160,32 @@ void InspectorController::stopTimelineProfiler()
m_frontend->timelineProfilerWasStopped();
}
#if ENABLE(WORKERS)
void InspectorController::didCreateWorker(long id, const String& url, bool isSharedWorker)
{
if (!enabled())
return;
RefPtr<InspectorWorkerResource> workerResource(InspectorWorkerResource::create(id, url, isSharedWorker));
m_workers.set(id, workerResource);
if (m_frontend)
m_frontend->didCreateWorker(*workerResource);
}
void InspectorController::willDestroyWorker(long id)
{
if (!enabled())
return;
WorkersMap::iterator workerResource = m_workers.find(id);
if (workerResource == m_workers.end())
return;
if (m_frontend)
m_frontend->willDestroyWorker(*workerResource->second);
m_workers.remove(workerResource);
}
#endif // ENABLE(WORKERS)
#if ENABLE(DATABASE)
void InspectorController::selectDatabase(Database* database)
{
......
......@@ -85,6 +85,7 @@ class ConsoleMessage;
class InspectorDatabaseResource;
class InspectorDOMStorageResource;
class InspectorResource;
class InspectorWorkerResource;
class InspectorController
#if ENABLE(JAVASCRIPT_DEBUGGER)
......@@ -186,11 +187,14 @@ public:
void mainResourceFiredLoadEvent(DocumentLoader*, const KURL&);
void mainResourceFiredDOMContentEvent(DocumentLoader*, const KURL&);
void didInsertDOMNode(Node*);
void didRemoveDOMNode(Node*);
void didModifyDOMAttr(Element*);
#if ENABLE(WORKERS)
void didCreateWorker(long id, const String& url, bool isSharedWorker);
void willDestroyWorker(long id);
#endif
void getCookies(long callId);
#if ENABLE(DATABASE)
......@@ -365,6 +369,11 @@ private:
Timer<InspectorController> m_startProfiling;
ProfilesMap m_profiles;
#endif
#if ENABLE(WORKERS)
typedef HashMap<long, RefPtr<InspectorWorkerResource> > WorkersMap;
WorkersMap m_workers;
#endif
};
inline void InspectorController::didInsertDOMNode(Node* node)
......
......@@ -37,6 +37,7 @@
#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorController.h"
#include "InspectorWorkerResource.h"
#include "Node.h"
#include "ScriptFunctionCall.h"
#include "ScriptObject.h"
......@@ -452,6 +453,26 @@ void InspectorFrontend::didGetEventListenersForNode(int callId, int nodeId, Scri
function.call();
}
#if ENABLE(WORKERS)
void InspectorFrontend::didCreateWorker(const InspectorWorkerResource& worker)
{
ScriptFunctionCall function(m_webInspector, "dispatch");
function.appendArgument("didCreateWorker");
function.appendArgument(worker.id());
function.appendArgument(worker.url());
function.appendArgument(worker.isSharedWorker());
function.call();
}
void InspectorFrontend::willDestroyWorker(const InspectorWorkerResource& worker)
{
ScriptFunctionCall function(m_webInspector, "dispatch");
function.appendArgument("willDestroyWorker");
function.appendArgument(worker.id());
function.call();
}
#endif // ENABLE(WORKERS)
void InspectorFrontend::didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString)
{
ScriptFunctionCall function(m_webInspector, "dispatch");
......
......@@ -45,6 +45,7 @@ namespace WebCore {
class ScriptString;
class SerializedScriptValue;
class Storage;
class InspectorWorkerResource;
class InspectorFrontend : public Noncopyable {
public:
......@@ -126,6 +127,11 @@ namespace WebCore {
void timelineProfilerWasStopped();
void addRecordToTimeline(const ScriptObject&);
#if ENABLE(WORKERS)
void didCreateWorker(const InspectorWorkerResource&);
void willDestroyWorker(const InspectorWorkerResource&);
#endif // ENABLE(WORKER)
void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString);
void didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException);
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef InspectorWorkerResource_h
#define InspectorWorkerResource_h
#if ENABLE(WORKERS) && ENABLE(INSPECTOR)
#include "PlatformString.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class InspectorWorkerResource : public RefCounted<InspectorWorkerResource> {
public:
static PassRefPtr<InspectorWorkerResource> create(long id, const String& url, bool isSharedWorker)
{
return adoptRef(new InspectorWorkerResource(id, url, isSharedWorker));
}
long id() const { return m_id; }
const String& url() const { return m_url; }
bool isSharedWorker() const { return m_isSharedWorker; }
private:
InspectorWorkerResource(long id, const String& url, bool isSharedWorker)
: m_id(id)
, m_url(url)
, m_isSharedWorker(isSharedWorker)
{
}
int m_id;
String m_url;
bool m_isSharedWorker;
};
} // namespace WebCore
#endif // ENABLE(WORKERS) && ENABLE(INSPECTOR)
#endif // InspectorWorkerResource_h
/*
* Copyright (C) 2010 Google Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,