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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/devtools_client_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 class DevToolsExternalAgentProxyDelegate; 18 class DevToolsExternalAgentProxyDelegate;
18 class RenderViewHost; 19 class RenderViewHost;
19 class WebContents; 20 class WebContents;
20 21
21 // Describes interface for managing devtools agents from browser process. 22 // Describes interface for managing devtools agents from browser process.
22 class CONTENT_EXPORT DevToolsAgentHost 23 class CONTENT_EXPORT DevToolsAgentHost
23 : public base::RefCounted<DevToolsAgentHost> { 24 : public base::RefCounted<DevToolsAgentHost> {
24 public: 25 public:
26 // Client can attach to the agent host and start inspecting it.
27 class Client {
jam 2014/08/08 01:23:28 nit: move this to a separate header and call it De
dgozman 2014/08/08 11:51:55 Done.
28 public:
29 virtual ~Client() {}
30
31 // Dispatches given protocol message on the client.
32 virtual void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
33 const std::string& message) = 0;
34
35 // This method is called when attached agent host is closed.
36 virtual void AgentHostClosed(DevToolsAgentHost* agent_host,
37 bool replaced_with_another_client) = 0;
38 };
39
25 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist. 40 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist.
26 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); 41 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id);
27 42
28 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|. 43 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|.
29 // New DevToolsAgentHost will be created if it does not exist. 44 // New DevToolsAgentHost will be created if it does not exist.
30 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor( 45 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor(
31 WebContents* web_contents); 46 WebContents* web_contents);
32 47
33 // Returns DevToolsAgentHost that can be used for inspecting |rvh|. 48 // Returns DevToolsAgentHost that can be used for inspecting |rvh|.
34 // New DevToolsAgentHost will be created if it does not exist. 49 // New DevToolsAgentHost will be created if it does not exist.
(...skipping 12 matching lines...) Expand all
47 // provided |delegate|. |delegate| ownership is passed to the created agent 62 // provided |delegate|. |delegate| ownership is passed to the created agent
48 // host. 63 // host.
49 static scoped_refptr<DevToolsAgentHost> Create( 64 static scoped_refptr<DevToolsAgentHost> Create(
50 DevToolsExternalAgentProxyDelegate* delegate); 65 DevToolsExternalAgentProxyDelegate* delegate);
51 66
52 static bool IsDebuggerAttached(WebContents* web_contents); 67 static bool IsDebuggerAttached(WebContents* web_contents);
53 68
54 // Returns a list of all existing RenderViewHost's that can be debugged. 69 // Returns a list of all existing RenderViewHost's that can be debugged.
55 static std::vector<RenderViewHost*> GetValidRenderViewHosts(); 70 static std::vector<RenderViewHost*> GetValidRenderViewHosts();
56 71
72 // Client attaches to this agent host to start debugging it.
73 virtual void AttachClient(Client* client) = 0;
74
75 // Already attached client detaches from this agent host to stop debugging it.
76 virtual void DetachClient() = 0;
77
57 // Returns true if there is a client attached. 78 // Returns true if there is a client attached.
58 virtual bool IsAttached() = 0; 79 virtual bool IsAttached() = 0;
59 80
81 // Sends a message to the agent.
82 virtual void DispatchOnInspectorBackend(const std::string& message) = 0;
pfeldman 2014/08/07 17:31:14 I wish we could rename it to DispatchProtocolMessa
dgozman 2014/08/08 11:51:56 Done.
83
60 // Starts inspecting element at position (|x|, |y|) in the specified page. 84 // Starts inspecting element at position (|x|, |y|) in the specified page.
61 virtual void InspectElement(int x, int y) = 0; 85 virtual void InspectElement(int x, int y) = 0;
62 86
63 // Returns the unique id of the agent. 87 // Returns the unique id of the agent.
64 virtual std::string GetId() = 0; 88 virtual std::string GetId() = 0;
65 89
66 // Returns render view host instance for this host if any. 90 // Returns render view host instance for this host if any.
67 virtual RenderViewHost* GetRenderViewHost() = 0; 91 virtual RenderViewHost* GetRenderViewHost() = 0;
68 92
69 // Temporarily detaches render view host from this host. Must be followed by 93 // Temporarily detaches render view host from this host. Must be followed by
70 // a call to ConnectRenderViewHost (may leak the host instance otherwise). 94 // a call to ConnectRenderViewHost (may leak the host instance otherwise).
71 virtual void DisconnectRenderViewHost() = 0; 95 virtual void DisconnectRenderViewHost() = 0;
72 96
73 // Attaches render view host to this host. 97 // Attaches render view host to this host.
74 virtual void ConnectRenderViewHost(RenderViewHost* rvh) = 0; 98 virtual void ConnectRenderViewHost(RenderViewHost* rvh) = 0;
75 99
76 // Returns true if DevToolsAgentHost is for worker. 100 // Returns true if DevToolsAgentHost is for worker.
77 virtual bool IsWorker() const = 0; 101 virtual bool IsWorker() const = 0;
78 102
103 // Terminates all debugging sessions and detaches all clients.
104 static void DetachAllClients();
105
106 typedef base::Callback<void(DevToolsAgentHost*, bool attached)>
107 AgentStateCallback;
108
109 static void AddAgentStateCallback(const AgentStateCallback& callback);
110 static void RemoveAgentStateCallback(const AgentStateCallback& callback);
111
79 protected: 112 protected:
80 friend class base::RefCounted<DevToolsAgentHost>; 113 friend class base::RefCounted<DevToolsAgentHost>;
81 virtual ~DevToolsAgentHost() {} 114 virtual ~DevToolsAgentHost() {}
82 }; 115 };
83 116
84 } // namespace content 117 } // namespace content
85 118
86 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 119 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/devtools_client_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698