Commit cebd7894 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

DevTools: pass agent host id to the renderer (content).

TBR=jam // for changes to implementations in content/.

Review URL: https://codereview.chromium.org/341513002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278135 0039d316-1c4b-4281-b951-d872f2087c98
parent cf0611f0
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace content { namespace content {
void IPCDevToolsAgentHost::Attach() { void IPCDevToolsAgentHost::Attach() {
SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE)); SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE, GetId()));
OnClientAttached(); OnClientAttached();
} }
...@@ -26,7 +26,7 @@ void IPCDevToolsAgentHost::DispatchOnInspectorBackend( ...@@ -26,7 +26,7 @@ void IPCDevToolsAgentHost::DispatchOnInspectorBackend(
void IPCDevToolsAgentHost::InspectElement(int x, int y) { void IPCDevToolsAgentHost::InspectElement(int x, int y) {
SendMessageToAgent(new DevToolsAgentMsg_InspectElement(MSG_ROUTING_NONE, SendMessageToAgent(new DevToolsAgentMsg_InspectElement(MSG_ROUTING_NONE,
x, y)); GetId(), x, y));
} }
IPCDevToolsAgentHost::~IPCDevToolsAgentHost() { IPCDevToolsAgentHost::~IPCDevToolsAgentHost() {
...@@ -34,8 +34,7 @@ IPCDevToolsAgentHost::~IPCDevToolsAgentHost() { ...@@ -34,8 +34,7 @@ IPCDevToolsAgentHost::~IPCDevToolsAgentHost() {
void IPCDevToolsAgentHost::Reattach(const std::string& saved_agent_state) { void IPCDevToolsAgentHost::Reattach(const std::string& saved_agent_state) {
SendMessageToAgent(new DevToolsAgentMsg_Reattach( SendMessageToAgent(new DevToolsAgentMsg_Reattach(
MSG_ROUTING_NONE, MSG_ROUTING_NONE, GetId(), saved_agent_state));
saved_agent_state));
OnClientAttached(); OnClientAttached();
} }
......
...@@ -54,11 +54,12 @@ void SharedWorkerDevToolsAgent::SaveDevToolsAgentState( ...@@ -54,11 +54,12 @@ void SharedWorkerDevToolsAgent::SaveDevToolsAgentState(
state.utf8())); state.utf8()));
} }
void SharedWorkerDevToolsAgent::OnAttach() { void SharedWorkerDevToolsAgent::OnAttach(const std::string& host_id) {
webworker_->attachDevTools(); webworker_->attachDevTools();
} }
void SharedWorkerDevToolsAgent::OnReattach(const std::string& state) { void SharedWorkerDevToolsAgent::OnReattach(const std::string& host_id,
const std::string& state) {
webworker_->reattachDevTools(WebString::fromUTF8(state)); webworker_->reattachDevTools(WebString::fromUTF8(state));
} }
......
...@@ -31,8 +31,8 @@ class SharedWorkerDevToolsAgent { ...@@ -31,8 +31,8 @@ class SharedWorkerDevToolsAgent {
void SaveDevToolsAgentState(const blink::WebString& state); void SaveDevToolsAgentState(const blink::WebString& state);
private: private:
void OnAttach(); void OnAttach(const std::string& host_id);
void OnReattach(const std::string&); void OnReattach(const std::string& host_id, const std::string& state);
void OnDetach(); void OnDetach();
void OnDispatchOnInspectorBackend(const std::string& message); void OnDispatchOnInspectorBackend(const std::string& message);
void OnResumeWorkerContext(); void OnResumeWorkerContext();
......
...@@ -62,11 +62,13 @@ IPC_MESSAGE_ROUTED1(DevToolsClientMsg_DispatchOnInspectorFrontend, ...@@ -62,11 +62,13 @@ IPC_MESSAGE_ROUTED1(DevToolsClientMsg_DispatchOnInspectorFrontend,
// These are messages sent from DevToolsClient to DevToolsAgent through the // These are messages sent from DevToolsClient to DevToolsAgent through the
// browser. // browser.
// Tells agent that there is a client host connected to it. // Tells agent that there is a client host connected to it.
IPC_MESSAGE_ROUTED0(DevToolsAgentMsg_Attach) IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_Attach,
std::string /* host_id */)
// Tells agent that a client host was disconnected from another agent and // Tells agent that a client host was disconnected from another agent and
// connected to this one. // connected to this one.
IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_Reattach, IPC_MESSAGE_ROUTED2(DevToolsAgentMsg_Reattach,
std::string /* host_id */,
std::string /* agent_state */) std::string /* agent_state */)
// Tells agent that there is no longer a client host connected to it. // Tells agent that there is no longer a client host connected to it.
...@@ -77,7 +79,8 @@ IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_DispatchOnInspectorBackend, ...@@ -77,7 +79,8 @@ IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_DispatchOnInspectorBackend,
std::string /* message */) std::string /* message */)
// Inspect element with the given coordinates. // Inspect element with the given coordinates.
IPC_MESSAGE_ROUTED2(DevToolsAgentMsg_InspectElement, IPC_MESSAGE_ROUTED3(DevToolsAgentMsg_InspectElement,
std::string /* host_id */,
int /* x */, int /* x */,
int /* y */) int /* y */)
......
...@@ -125,6 +125,10 @@ int DevToolsAgent::hostIdentifier() { ...@@ -125,6 +125,10 @@ int DevToolsAgent::hostIdentifier() {
return routing_id(); return routing_id();
} }
int DevToolsAgent::debuggerId() {
return routing_id();
}
void DevToolsAgent::saveAgentRuntimeState( void DevToolsAgent::saveAgentRuntimeState(
const blink::WebString& state) { const blink::WebString& state) {
Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8()));
...@@ -273,26 +277,28 @@ void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) { ...@@ -273,26 +277,28 @@ void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) {
} }
// static // static
DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { DevToolsAgent* DevToolsAgent::FromRoutingId(int routing_id) {
IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(host_id); IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(routing_id);
if (it != g_agent_for_routing_id.Get().end()) { if (it != g_agent_for_routing_id.Get().end()) {
return it->second; return it->second;
} }
return NULL; return NULL;
} }
void DevToolsAgent::OnAttach() { void DevToolsAgent::OnAttach(const std::string& host_id) {
WebDevToolsAgent* web_agent = GetWebAgent(); WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) { if (web_agent) {
web_agent->attach(); web_agent->attach(WebString::fromUTF8(host_id));
is_attached_ = true; is_attached_ = true;
} }
} }
void DevToolsAgent::OnReattach(const std::string& agent_state) { void DevToolsAgent::OnReattach(const std::string& host_id,
const std::string& agent_state) {
WebDevToolsAgent* web_agent = GetWebAgent(); WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) { if (web_agent) {
web_agent->reattach(WebString::fromUTF8(agent_state)); web_agent->reattach(WebString::fromUTF8(host_id),
WebString::fromUTF8(agent_state));
is_attached_ = true; is_attached_ = true;
} }
} }
...@@ -312,11 +318,13 @@ void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& message) { ...@@ -312,11 +318,13 @@ void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& message) {
web_agent->dispatchOnInspectorBackend(WebString::fromUTF8(message)); web_agent->dispatchOnInspectorBackend(WebString::fromUTF8(message));
} }
void DevToolsAgent::OnInspectElement(int x, int y) { void DevToolsAgent::OnInspectElement(
const std::string& host_id, int x, int y) {
WebDevToolsAgent* web_agent = GetWebAgent(); WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) { if (web_agent) {
web_agent->attach(); web_agent->attach(WebString::fromUTF8(host_id));
web_agent->inspectElementAt(WebPoint(x, y)); web_agent->inspectElementAt(WebPoint(x, y));
is_attached_ = true;
} }
} }
......
...@@ -36,8 +36,8 @@ class DevToolsAgent : public RenderViewObserver, ...@@ -36,8 +36,8 @@ class DevToolsAgent : public RenderViewObserver,
explicit DevToolsAgent(RenderViewImpl* render_view); explicit DevToolsAgent(RenderViewImpl* render_view);
virtual ~DevToolsAgent(); virtual ~DevToolsAgent();
// Returns agent instance for its host id. // Returns agent instance for its routing id.
static DevToolsAgent* FromHostId(int host_id); static DevToolsAgent* FromRoutingId(int routing_id);
blink::WebDevToolsAgent* GetWebAgent(); blink::WebDevToolsAgent* GetWebAgent();
...@@ -51,6 +51,7 @@ class DevToolsAgent : public RenderViewObserver, ...@@ -51,6 +51,7 @@ class DevToolsAgent : public RenderViewObserver,
virtual void sendMessageToInspectorFrontend(const blink::WebString& data); virtual void sendMessageToInspectorFrontend(const blink::WebString& data);
virtual int hostIdentifier() OVERRIDE; virtual int hostIdentifier() OVERRIDE;
virtual int debuggerId() OVERRIDE;
virtual void saveAgentRuntimeState(const blink::WebString& state) OVERRIDE; virtual void saveAgentRuntimeState(const blink::WebString& state) OVERRIDE;
virtual blink::WebDevToolsAgentClient::WebKitClientMessageLoop* virtual blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
createClientMessageLoop() OVERRIDE; createClientMessageLoop() OVERRIDE;
...@@ -77,11 +78,12 @@ class DevToolsAgent : public RenderViewObserver, ...@@ -77,11 +78,12 @@ class DevToolsAgent : public RenderViewObserver,
virtual void setTouchEventEmulationEnabled(bool enabled, virtual void setTouchEventEmulationEnabled(bool enabled,
bool allow_pinch) OVERRIDE; bool allow_pinch) OVERRIDE;
void OnAttach(); void OnAttach(const std::string& host_id);
void OnReattach(const std::string& agent_state); void OnReattach(const std::string& host_id,
const std::string& agent_state);
void OnDetach(); void OnDetach();
void OnDispatchOnInspectorBackend(const std::string& message); void OnDispatchOnInspectorBackend(const std::string& message);
void OnInspectElement(int x, int y); void OnInspectElement(const std::string& host_id, int x, int y);
void OnAddMessageToConsole(ConsoleMessageLevel level, void OnAddMessageToConsole(ConsoleMessageLevel level,
const std::string& message); const std::string& message);
void OnGpuTasksChunk(const std::vector<GpuTaskInfo>& tasks); void OnGpuTasksChunk(const std::vector<GpuTaskInfo>& tasks);
......
...@@ -21,21 +21,21 @@ namespace { ...@@ -21,21 +21,21 @@ namespace {
class MessageImpl : public WebDevToolsAgent::MessageDescriptor { class MessageImpl : public WebDevToolsAgent::MessageDescriptor {
public: public:
MessageImpl(const std::string& message, int host_id) MessageImpl(const std::string& message, int routing_id)
: msg(message), : msg_(message),
host_id(host_id) { routing_id_(routing_id) {
} }
virtual ~MessageImpl() {} virtual ~MessageImpl() {}
virtual WebDevToolsAgent* agent() { virtual WebDevToolsAgent* agent() {
DevToolsAgent* agent = DevToolsAgent::FromHostId(host_id); DevToolsAgent* agent = DevToolsAgent::FromRoutingId(routing_id_);
if (!agent) if (!agent)
return 0; return 0;
return agent->GetWebAgent(); return agent->GetWebAgent();
} }
virtual WebString message() { return WebString::fromUTF8(msg); } virtual WebString message() { return WebString::fromUTF8(msg_); }
private: private:
std::string msg; std::string msg_;
int host_id; int routing_id_;
}; };
} // namespace } // namespace
......
...@@ -43,11 +43,12 @@ bool EmbeddedWorkerDevToolsAgent::OnMessageReceived( ...@@ -43,11 +43,12 @@ bool EmbeddedWorkerDevToolsAgent::OnMessageReceived(
return handled; return handled;
} }
void EmbeddedWorkerDevToolsAgent::OnAttach() { void EmbeddedWorkerDevToolsAgent::OnAttach(const std::string& host_id) {
webworker_->attachDevTools(); webworker_->attachDevTools();
} }
void EmbeddedWorkerDevToolsAgent::OnReattach(const std::string& state) { void EmbeddedWorkerDevToolsAgent::OnReattach(const std::string& host_id,
const std::string& state) {
webworker_->reattachDevTools(WebString::fromUTF8(state)); webworker_->reattachDevTools(WebString::fromUTF8(state));
} }
......
...@@ -30,8 +30,8 @@ class EmbeddedWorkerDevToolsAgent : public IPC::Listener { ...@@ -30,8 +30,8 @@ class EmbeddedWorkerDevToolsAgent : public IPC::Listener {
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
private: private:
void OnAttach(); void OnAttach(const std::string& host_id);
void OnReattach(const std::string&); void OnReattach(const std::string& host_id, const std::string& state);
void OnDetach(); void OnDetach();
void OnDispatchOnInspectorBackend(const std::string& message); void OnDispatchOnInspectorBackend(const std::string& message);
void OnResumeWorkerContext(); void OnResumeWorkerContext();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment