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 @@
namespace content {
void IPCDevToolsAgentHost::Attach() {
SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE));
SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE, GetId()));
OnClientAttached();
}
......@@ -26,7 +26,7 @@ void IPCDevToolsAgentHost::DispatchOnInspectorBackend(
void IPCDevToolsAgentHost::InspectElement(int x, int y) {
SendMessageToAgent(new DevToolsAgentMsg_InspectElement(MSG_ROUTING_NONE,
x, y));
GetId(), x, y));
}
IPCDevToolsAgentHost::~IPCDevToolsAgentHost() {
......@@ -34,8 +34,7 @@ IPCDevToolsAgentHost::~IPCDevToolsAgentHost() {
void IPCDevToolsAgentHost::Reattach(const std::string& saved_agent_state) {
SendMessageToAgent(new DevToolsAgentMsg_Reattach(
MSG_ROUTING_NONE,
saved_agent_state));
MSG_ROUTING_NONE, GetId(), saved_agent_state));
OnClientAttached();
}
......
......@@ -54,11 +54,12 @@ void SharedWorkerDevToolsAgent::SaveDevToolsAgentState(
state.utf8()));
}
void SharedWorkerDevToolsAgent::OnAttach() {
void SharedWorkerDevToolsAgent::OnAttach(const std::string& host_id) {
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));
}
......
......@@ -31,8 +31,8 @@ class SharedWorkerDevToolsAgent {
void SaveDevToolsAgentState(const blink::WebString& state);
private:
void OnAttach();
void OnReattach(const std::string&);
void OnAttach(const std::string& host_id);
void OnReattach(const std::string& host_id, const std::string& state);
void OnDetach();
void OnDispatchOnInspectorBackend(const std::string& message);
void OnResumeWorkerContext();
......
......@@ -62,11 +62,13 @@ IPC_MESSAGE_ROUTED1(DevToolsClientMsg_DispatchOnInspectorFrontend,
// These are messages sent from DevToolsClient to DevToolsAgent through the
// browser.
// 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
// connected to this one.
IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_Reattach,
IPC_MESSAGE_ROUTED2(DevToolsAgentMsg_Reattach,
std::string /* host_id */,
std::string /* agent_state */)
// Tells agent that there is no longer a client host connected to it.
......@@ -77,7 +79,8 @@ IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_DispatchOnInspectorBackend,
std::string /* message */)
// Inspect element with the given coordinates.
IPC_MESSAGE_ROUTED2(DevToolsAgentMsg_InspectElement,
IPC_MESSAGE_ROUTED3(DevToolsAgentMsg_InspectElement,
std::string /* host_id */,
int /* x */,
int /* y */)
......
......@@ -125,6 +125,10 @@ int DevToolsAgent::hostIdentifier() {
return routing_id();
}
int DevToolsAgent::debuggerId() {
return routing_id();
}
void DevToolsAgent::saveAgentRuntimeState(
const blink::WebString& state) {
Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8()));
......@@ -273,26 +277,28 @@ void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) {
}
// static
DevToolsAgent* DevToolsAgent::FromHostId(int host_id) {
IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(host_id);
DevToolsAgent* DevToolsAgent::FromRoutingId(int routing_id) {
IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(routing_id);
if (it != g_agent_for_routing_id.Get().end()) {
return it->second;
}
return NULL;
}
void DevToolsAgent::OnAttach() {
void DevToolsAgent::OnAttach(const std::string& host_id) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
web_agent->attach();
web_agent->attach(WebString::fromUTF8(host_id));
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();
if (web_agent) {
web_agent->reattach(WebString::fromUTF8(agent_state));
web_agent->reattach(WebString::fromUTF8(host_id),
WebString::fromUTF8(agent_state));
is_attached_ = true;
}
}
......@@ -312,11 +318,13 @@ void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& 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();
if (web_agent) {
web_agent->attach();
web_agent->attach(WebString::fromUTF8(host_id));
web_agent->inspectElementAt(WebPoint(x, y));
is_attached_ = true;
}
}
......
......@@ -36,8 +36,8 @@ class DevToolsAgent : public RenderViewObserver,
explicit DevToolsAgent(RenderViewImpl* render_view);
virtual ~DevToolsAgent();
// Returns agent instance for its host id.
static DevToolsAgent* FromHostId(int host_id);
// Returns agent instance for its routing id.
static DevToolsAgent* FromRoutingId(int routing_id);
blink::WebDevToolsAgent* GetWebAgent();
......@@ -51,6 +51,7 @@ class DevToolsAgent : public RenderViewObserver,
virtual void sendMessageToInspectorFrontend(const blink::WebString& data);
virtual int hostIdentifier() OVERRIDE;
virtual int debuggerId() OVERRIDE;
virtual void saveAgentRuntimeState(const blink::WebString& state) OVERRIDE;
virtual blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
createClientMessageLoop() OVERRIDE;
......@@ -77,11 +78,12 @@ class DevToolsAgent : public RenderViewObserver,
virtual void setTouchEventEmulationEnabled(bool enabled,
bool allow_pinch) OVERRIDE;
void OnAttach();
void OnReattach(const std::string& agent_state);
void OnAttach(const std::string& host_id);
void OnReattach(const std::string& host_id,
const std::string& agent_state);
void OnDetach();
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,
const std::string& message);
void OnGpuTasksChunk(const std::vector<GpuTaskInfo>& tasks);
......
......@@ -21,21 +21,21 @@ namespace {
class MessageImpl : public WebDevToolsAgent::MessageDescriptor {
public:
MessageImpl(const std::string& message, int host_id)
: msg(message),
host_id(host_id) {
MessageImpl(const std::string& message, int routing_id)
: msg_(message),
routing_id_(routing_id) {
}
virtual ~MessageImpl() {}
virtual WebDevToolsAgent* agent() {
DevToolsAgent* agent = DevToolsAgent::FromHostId(host_id);
DevToolsAgent* agent = DevToolsAgent::FromRoutingId(routing_id_);
if (!agent)
return 0;
return agent->GetWebAgent();
}
virtual WebString message() { return WebString::fromUTF8(msg); }
virtual WebString message() { return WebString::fromUTF8(msg_); }
private:
std::string msg;
int host_id;
std::string msg_;
int routing_id_;
};
} // namespace
......
......@@ -43,11 +43,12 @@ bool EmbeddedWorkerDevToolsAgent::OnMessageReceived(
return handled;
}
void EmbeddedWorkerDevToolsAgent::OnAttach() {
void EmbeddedWorkerDevToolsAgent::OnAttach(const std::string& host_id) {
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));
}
......
......@@ -30,8 +30,8 @@ class EmbeddedWorkerDevToolsAgent : public IPC::Listener {
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
private:
void OnAttach();
void OnReattach(const std::string&);
void OnAttach(const std::string& host_id);
void OnReattach(const std::string& host_id, const std::string& state);
void OnDetach();
void OnDispatchOnInspectorBackend(const std::string& message);
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