diff options
author | yurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 16:49:42 +0000 |
---|---|---|
committer | yurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 16:49:42 +0000 |
commit | 12e02ce91be9aba8fa4f571d412ff27a4baf11d7 (patch) | |
tree | 74a3ecb79b94c69070a5d249601b0d09677c50a2 /content | |
parent | c1f05e3e72fd642fdcf8a84dc1cf46663d20f90f (diff) | |
download | chromium_src-12e02ce91be9aba8fa4f571d412ff27a4baf11d7.zip chromium_src-12e02ce91be9aba8fa4f571d412ff27a4baf11d7.tar.gz chromium_src-12e02ce91be9aba8fa4f571d412ff27a4baf11d7.tar.bz2 |
DevTools: introduce Reattach message, get rid of DevToolsRuntimeProperties map
We want agent to save its state into a string instead of using a map of
runtime properties. Also the serialized state should be taken into account
only when existing client is reattached from one agent to another, this
is why we introduce Reattach message.
Also see https://bugs.webkit.org/show_bug.cgi?id=69335
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/8135002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/debugger/devtools_agent_host.cc | 10 | ||||
-rw-r--r-- | content/browser/debugger/devtools_agent_host.h | 3 | ||||
-rw-r--r-- | content/browser/debugger/devtools_manager.cc | 39 | ||||
-rw-r--r-- | content/browser/debugger/devtools_manager.h | 18 | ||||
-rw-r--r-- | content/browser/debugger/render_view_devtools_agent_host.cc | 12 | ||||
-rw-r--r-- | content/browser/debugger/render_view_devtools_agent_host.h | 3 | ||||
-rw-r--r-- | content/common/devtools_messages.h | 23 | ||||
-rw-r--r-- | content/renderer/devtools_agent.cc | 37 | ||||
-rw-r--r-- | content/renderer/devtools_agent.h | 8 | ||||
-rw-r--r-- | content/renderer/worker_devtools_agent_proxy.cc | 2 | ||||
-rw-r--r-- | content/worker/worker_devtools_agent.cc | 7 |
11 files changed, 66 insertions, 96 deletions
diff --git a/content/browser/debugger/devtools_agent_host.cc b/content/browser/debugger/devtools_agent_host.cc index 50edfd9..0d206c9 100644 --- a/content/browser/debugger/devtools_agent_host.cc +++ b/content/browser/debugger/devtools_agent_host.cc @@ -10,10 +10,14 @@ DevToolsAgentHost::DevToolsAgentHost() : close_listener_(NULL) { } -void DevToolsAgentHost::Attach(const DevToolsRuntimeProperties& properties) { - SendMessageToAgent(new DevToolsAgentMsg_Attach( +void DevToolsAgentHost::Attach() { + SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE)); +} + +void DevToolsAgentHost::Reattach(const std::string& saved_agent_state) { + SendMessageToAgent(new DevToolsAgentMsg_Reattach( MSG_ROUTING_NONE, - properties)); + saved_agent_state)); } void DevToolsAgentHost::Detach() { diff --git a/content/browser/debugger/devtools_agent_host.h b/content/browser/debugger/devtools_agent_host.h index 848de04..3eb7a33 100644 --- a/content/browser/debugger/devtools_agent_host.h +++ b/content/browser/debugger/devtools_agent_host.h @@ -29,7 +29,8 @@ class CONTENT_EXPORT DevToolsAgentHost { // Sends the message to the devtools agent hosted by this object. virtual void SendMessageToAgent(IPC::Message* msg) = 0; - virtual void Attach(const DevToolsRuntimeProperties&); + virtual void Attach(); + virtual void Reattach(const std::string& saved_agent_state); virtual void Detach(); // TODO(yurys): get rid of this method diff --git a/content/browser/debugger/devtools_manager.cc b/content/browser/debugger/devtools_manager.cc index 53a1684..87e9ff7 100644 --- a/content/browser/debugger/devtools_manager.cc +++ b/content/browser/debugger/devtools_manager.cc @@ -63,8 +63,8 @@ void DevToolsManager::RegisterDevToolsClientHostFor( void DevToolsManager::RegisterDevToolsClientHostFor( DevToolsAgentHost* agent_host, DevToolsClientHost* client_host) { - DevToolsRuntimeProperties initial_properties; - BindClientHost(agent_host, client_host, initial_properties); + BindClientHost(agent_host, client_host); + agent_host->Attach(); client_host->set_close_listener(this); } @@ -89,18 +89,9 @@ void DevToolsManager::ForwardToDevToolsClient(DevToolsAgentHost* agent_host, client_host->SendMessageToClient(message); } -void DevToolsManager::RuntimePropertyChanged(DevToolsAgentHost* agent_host, - const std::string& name, - const std::string& value) { - RuntimePropertiesMap::iterator it = - runtime_properties_map_.find(agent_host); - if (it == runtime_properties_map_.end()) { - std::pair<DevToolsAgentHost*, DevToolsRuntimeProperties> value( - agent_host, - DevToolsRuntimeProperties()); - it = runtime_properties_map_.insert(value).first; - } - it->second[name] = value; +void DevToolsManager::SaveAgentRuntimeState(DevToolsAgentHost* agent_host, + const std::string& state) { + agent_runtime_states_[agent_host] = state; } void DevToolsManager::ClientHostClosing(DevToolsClientHost* client_host) { @@ -189,8 +180,8 @@ int DevToolsManager::DetachClientHost(RenderViewHost* from_rvh) { int cookie = last_orphan_cookie_++; orphan_client_hosts_[cookie] = - std::pair<DevToolsClientHost*, DevToolsRuntimeProperties>( - client_host, runtime_properties_map_[agent_host]); + std::pair<DevToolsClientHost*, std::string>( + client_host, agent_runtime_states_[agent_host]); UnbindClientHost(agent_host, client_host); return cookie; @@ -204,17 +195,16 @@ void DevToolsManager::AttachClientHost(int client_host_cookie, return; DevToolsClientHost* client_host = (*it).second.first; - DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( - to_rvh); - BindClientHost(agent_host, client_host, (*it).second.second); + DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor(to_rvh); + BindClientHost(agent_host, client_host); + agent_host->Reattach((*it).second.second); - orphan_client_hosts_.erase(client_host_cookie); + orphan_client_hosts_.erase(it); } void DevToolsManager::BindClientHost( DevToolsAgentHost* agent_host, - DevToolsClientHost* client_host, - const DevToolsRuntimeProperties& runtime_properties) { + DevToolsClientHost* client_host) { DCHECK(agent_to_client_host_.find(agent_host) == agent_to_client_host_.end()); DCHECK(client_to_agent_host_.find(client_host) == @@ -228,14 +218,11 @@ void DevToolsManager::BindClientHost( } agent_to_client_host_[agent_host] = client_host; client_to_agent_host_[client_host] = agent_host; - runtime_properties_map_[agent_host] = runtime_properties; agent_host->set_close_listener(this); int process_id = agent_host->GetRenderProcessId(); if (process_id != -1) ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies(process_id); - - agent_host->Attach(runtime_properties); } void DevToolsManager::UnbindClientHost(DevToolsAgentHost* agent_host, @@ -249,7 +236,7 @@ void DevToolsManager::UnbindClientHost(DevToolsAgentHost* agent_host, agent_to_client_host_.erase(agent_host); client_to_agent_host_.erase(client_host); - runtime_properties_map_.erase(agent_host); + agent_runtime_states_.erase(agent_host); if (client_to_agent_host_.empty()) { BrowserThread::PostTask( diff --git a/content/browser/debugger/devtools_manager.h b/content/browser/debugger/devtools_manager.h index 1104203..623e0c9 100644 --- a/content/browser/debugger/devtools_manager.h +++ b/content/browser/debugger/devtools_manager.h @@ -25,8 +25,6 @@ class PrefService; class RenderViewHost; class TabContents; -typedef std::map<std::string, std::string> DevToolsRuntimeProperties; - // This class is a singleton that manages DevToolsClientHost instances and // routes messages between developer tools clients and agents. // @@ -57,9 +55,8 @@ class CONTENT_EXPORT DevToolsManager void ForwardToDevToolsClient(DevToolsAgentHost* agent_host, const IPC::Message& message); - void RuntimePropertyChanged(DevToolsAgentHost* agent_host, - const std::string& name, - const std::string& value); + void SaveAgentRuntimeState(DevToolsAgentHost* agent_host, + const std::string& state); // Sends 'Attach' message to the agent using |dest_rvh| in case // there is a DevToolsClientHost registered for the |inspected_rvh|. @@ -101,8 +98,7 @@ class CONTENT_EXPORT DevToolsManager DevToolsAgentHost* GetAgentHost(DevToolsClientHost* client_host); void BindClientHost(DevToolsAgentHost* agent_host, - DevToolsClientHost* client_host, - const DevToolsRuntimeProperties& runtime_properties); + DevToolsClientHost* client_host); void UnbindClientHost(DevToolsAgentHost* agent_host, DevToolsClientHost* client_host); @@ -120,12 +116,10 @@ class CONTENT_EXPORT DevToolsManager ClientHostToInspectedRvhMap; ClientHostToInspectedRvhMap client_to_agent_host_; - typedef std::map<DevToolsAgentHost*, DevToolsRuntimeProperties> - RuntimePropertiesMap; - RuntimePropertiesMap runtime_properties_map_; + typedef std::map<DevToolsAgentHost*, std::string> AgentRuntimeStates; + AgentRuntimeStates agent_runtime_states_; - typedef std::map<int, - std::pair<DevToolsClientHost*, DevToolsRuntimeProperties> > + typedef std::map<int, std::pair<DevToolsClientHost*, std::string> > OrphanClientHosts; OrphanClientHosts orphan_client_hosts_; int last_orphan_cookie_; diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc index 188756a..a9937da 100644 --- a/content/browser/debugger/render_view_devtools_agent_host.cc +++ b/content/browser/debugger/render_view_devtools_agent_host.cc @@ -78,8 +78,8 @@ bool RenderViewDevToolsAgentHost::OnMessageReceived( bool handled = true; IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, message) IPC_MESSAGE_HANDLER(DevToolsHostMsg_ForwardToClient, OnForwardToClient) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_RuntimePropertyChanged, - OnRuntimePropertyChanged) + IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, + OnSaveAgentRuntimeState) IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCache, OnClearBrowserCache) IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCookies, OnClearBrowserCookies) @@ -88,11 +88,9 @@ bool RenderViewDevToolsAgentHost::OnMessageReceived( return handled; } -void RenderViewDevToolsAgentHost::OnRuntimePropertyChanged( - const std::string& name, - const std::string& value) { - DevToolsManager::GetInstance()->RuntimePropertyChanged( - this, name, value); +void RenderViewDevToolsAgentHost::OnSaveAgentRuntimeState( + const std::string& state) { + DevToolsManager::GetInstance()->SaveAgentRuntimeState(this, state); } void RenderViewDevToolsAgentHost::OnForwardToClient( diff --git a/content/browser/debugger/render_view_devtools_agent_host.h b/content/browser/debugger/render_view_devtools_agent_host.h index 0a3193c..329369b 100644 --- a/content/browser/debugger/render_view_devtools_agent_host.h +++ b/content/browser/debugger/render_view_devtools_agent_host.h @@ -36,8 +36,7 @@ class CONTENT_EXPORT RenderViewDevToolsAgentHost virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; void OnForwardToClient(const IPC::Message& message); - void OnRuntimePropertyChanged(const std::string& name, - const std::string& value); + void OnSaveAgentRuntimeState(const std::string& state); void OnClearBrowserCache(); void OnClearBrowserCookies(); diff --git a/content/common/devtools_messages.h b/content/common/devtools_messages.h index 5f09147..5101049 100644 --- a/content/common/devtools_messages.h +++ b/content/common/devtools_messages.h @@ -45,14 +45,6 @@ #include "content/common/content_export.h" #include "ipc/ipc_message_macros.h" -// Singly-included section. -#ifndef CONTENT_COMMON_DEVTOOLS_MESSAGES_H_ -#define CONTENT_COMMON_DEVTOOLS_MESSAGES_H_ - -typedef std::map<std::string, std::string> DevToolsRuntimeProperties; - -#endif // CONTENT_COMMON_DEVTOOLS_MESSAGES_H_ - #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT @@ -73,8 +65,12 @@ IPC_MESSAGE_ROUTED1(DevToolsClientMsg_DebuggerOutput, // These are messages sent from DevToolsClient to DevToolsAgent through the // browser. // Tells agent that there is a client host connected to it. -IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_Attach, - DevToolsRuntimeProperties /* properties */) +IPC_MESSAGE_ROUTED0(DevToolsAgentMsg_Attach) + +// Tells agent that a client host was disconnected from another agent and +// connected to this one. +IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_Reattach, + std::string /* agent_state */) // Tells agent that there is no longer a client host connected to it. IPC_MESSAGE_ROUTED0(DevToolsAgentMsg_Detach) @@ -144,11 +140,10 @@ IPC_MESSAGE_ROUTED2(DevToolsHostMsg_SaveAs, std::string /* file_name */, std::string /* content */) -// Updates runtime features store in devtools manager in order to support +// Updates agent runtime state stored in devtools manager in order to support // cross-navigation instrumentation. -IPC_MESSAGE_ROUTED2(DevToolsHostMsg_RuntimePropertyChanged, - std::string /* name */, - std::string /* value */) +IPC_MESSAGE_ROUTED1(DevToolsHostMsg_SaveAgentRuntimeState, + std::string /* state */) // Clears browser cache. IPC_MESSAGE_ROUTED0(DevToolsHostMsg_ClearBrowserCache) diff --git a/content/renderer/devtools_agent.cc b/content/renderer/devtools_agent.cc index c9a27bb..1934641 100644 --- a/content/renderer/devtools_agent.cc +++ b/content/renderer/devtools_agent.cc @@ -78,6 +78,7 @@ bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) + IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_FrontendLoaded, OnFrontendLoaded) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, @@ -111,22 +112,9 @@ int DevToolsAgent::hostIdentifier() { return routing_id(); } -void DevToolsAgent::runtimeFeatureStateChanged( - const WebKit::WebString& feature, - bool enabled) { - Send(new DevToolsHostMsg_RuntimePropertyChanged( - routing_id(), - feature.utf8(), - enabled ? "true" : "false")); -} - -void DevToolsAgent::runtimePropertyChanged( - const WebKit::WebString& name, - const WebKit::WebString& value) { - Send(new DevToolsHostMsg_RuntimePropertyChanged( - routing_id(), - name.utf8(), - value.utf8())); +void DevToolsAgent::saveAgentRuntimeState( + const WebKit::WebString& state) { + Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); } WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* @@ -156,18 +144,19 @@ DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { return NULL; } -void DevToolsAgent::OnAttach( - const DevToolsRuntimeProperties& runtime_properties) { +void DevToolsAgent::OnAttach() { WebDevToolsAgent* web_agent = GetWebAgent(); if (web_agent) { web_agent->attach(); is_attached_ = true; - for (DevToolsRuntimeProperties::const_iterator it = - runtime_properties.begin(); - it != runtime_properties.end(); ++it) { - web_agent->setRuntimeProperty(WebString::fromUTF8(it->first), - WebString::fromUTF8(it->second)); - } + } +} + +void DevToolsAgent::OnReattach(const std::string& agent_state) { + WebDevToolsAgent* web_agent = GetWebAgent(); + if (web_agent) { + web_agent->reattach(WebString::fromUTF8(agent_state)); + is_attached_ = true; } } diff --git a/content/renderer/devtools_agent.h b/content/renderer/devtools_agent.h index 64d6254..a527569 100644 --- a/content/renderer/devtools_agent.h +++ b/content/renderer/devtools_agent.h @@ -49,17 +49,15 @@ class DevToolsAgent : public content::RenderViewObserver, virtual void sendDebuggerOutput(const WebKit::WebString& data); virtual int hostIdentifier(); - virtual void runtimeFeatureStateChanged(const WebKit::WebString& feature, - bool enabled); - virtual void runtimePropertyChanged(const WebKit::WebString& name, - const WebKit::WebString& value); + virtual void saveAgentRuntimeState(const WebKit::WebString& state); virtual WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* createClientMessageLoop(); virtual bool exposeV8DebuggerProtocol(); virtual void clearBrowserCache(); virtual void clearBrowserCookies(); - void OnAttach(const DevToolsRuntimeProperties& runtime_properties); + void OnAttach(); + void OnReattach(const std::string& agent_state); void OnDetach(); void OnFrontendLoaded(); void OnDispatchOnInspectorBackend(const std::string& message); diff --git a/content/renderer/worker_devtools_agent_proxy.cc b/content/renderer/worker_devtools_agent_proxy.cc index 6a1907b..7f898ad 100644 --- a/content/renderer/worker_devtools_agent_proxy.cc +++ b/content/renderer/worker_devtools_agent_proxy.cc @@ -44,7 +44,7 @@ bool WorkerDevToolsAgentProxy::OnMessageReceived(const IPC::Message& message) { } void WorkerDevToolsAgentProxy::AttachDevTools() { - Send(new DevToolsAgentMsg_Attach(route_id_, DevToolsRuntimeProperties())); + Send(new DevToolsAgentMsg_Attach(route_id_)); } void WorkerDevToolsAgentProxy::DetachDevTools() { diff --git a/content/worker/worker_devtools_agent.cc b/content/worker/worker_devtools_agent.cc index 1ef2f03..8498fea 100644 --- a/content/worker/worker_devtools_agent.cc +++ b/content/worker/worker_devtools_agent.cc @@ -32,6 +32,7 @@ class WorkerDevToolsAgentImpl : public WorkerDevToolsAgent { bool handled = true; IPC_BEGIN_MESSAGE_MAP(WorkerDevToolsAgentImpl, message) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) + IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, OnDispatchOnInspectorBackend) @@ -42,10 +43,14 @@ class WorkerDevToolsAgentImpl : public WorkerDevToolsAgent { virtual void SendDevToolsMessage(const WebKit::WebString& message); - void OnAttach(const DevToolsRuntimeProperties&) { + void OnAttach() { webworker_->attachDevTools(); } + void OnReattach(const std::string&) { + OnAttach(); + } + void OnDetach() { webworker_->detachDevTools(); } |