Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: content/public/browser/devtools_agent_host.h

Issue 449043002: [DevTools] Make DevTools clients talk directly to DevToolsAgentHost instead of using DevToolsManage… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/browser/devtools_agent_host.h
diff --git a/content/public/browser/devtools_agent_host.h b/content/public/browser/devtools_agent_host.h
index dd18a53886b177a6fce02e3e1777d2564c224c3d..be4d20881c81e5a85de69525fe8f72aeebb0a2fb 100644
--- a/content/public/browser/devtools_agent_host.h
+++ b/content/public/browser/devtools_agent_host.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
@@ -22,6 +23,26 @@ class WebContents;
class CONTENT_EXPORT DevToolsAgentHost
: public base::RefCounted<DevToolsAgentHost> {
public:
+ enum DetachReason {
+ DETACHED_BY_CLIENT,
+ REPLACED_WITH_ANOTHER_CLIENT,
+ HOST_CLOSED
+ };
+
+ // Client can attach to the agent host and start inspecting it.
+ class Client {
pfeldman 2014/08/07 14:41:58 It would be great if Detach and DTAH::DispatchProt
+ public:
+ virtual ~Client() {}
+
+ // Dispatches given protocol message on the client.
+ virtual void SendMessageFromAgentHost(DevToolsAgentHost* agent_host,
+ const std::string& message) = 0;
+
+ // This method is called when attached agent host is detached.
+ virtual void AgentHostDetached(DevToolsAgentHost* agent_host,
+ DetachReason reason) = 0;
+ };
+
// Returns DevToolsAgentHost with a given |id| or NULL of it does not exist.
static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id);
@@ -54,9 +75,18 @@ class CONTENT_EXPORT DevToolsAgentHost
// Returns a list of all existing RenderViewHost's that can be debugged.
static std::vector<RenderViewHost*> GetValidRenderViewHosts();
+ // Client attaches to this agent host to start debugging it.
+ virtual void AttachClient(Client* client) = 0;
+
+ // Already attached client detaches from this agent host to stop debugging it.
+ virtual void DetachClient() = 0;
+
// Returns true if there is a client attached.
virtual bool IsAttached() = 0;
+ // Sends a message to the agent.
+ virtual void DispatchOnInspectorBackend(const std::string& message) = 0;
+
// Starts inspecting element at position (|x|, |y|) in the specified page.
virtual void InspectElement(int x, int y) = 0;
@@ -76,6 +106,15 @@ class CONTENT_EXPORT DevToolsAgentHost
// Returns true if DevToolsAgentHost is for worker.
virtual bool IsWorker() const = 0;
+ // Terminates all debugging sessions and detaches all clients.
+ static void DetachAllClients();
+
+ typedef base::Callback<void(DevToolsAgentHost*, bool attached)>
+ AgentStateCallback;
+
+ static void AddAgentStateCallback(const AgentStateCallback& callback);
+ static void RemoveAgentStateCallback(const AgentStateCallback& callback);
+
protected:
friend class base::RefCounted<DevToolsAgentHost>;
virtual ~DevToolsAgentHost() {}

Powered by Google App Engine
This is Rietveld 408576698