OLD | NEW |
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 | 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 class RenderViewHost; | 17 class RenderViewHost; |
17 class WebContents; | 18 class WebContents; |
18 | 19 |
19 // Describes interface for managing devtools agents from browser process. | 20 // Describes interface for managing devtools agents from browser process. |
20 class CONTENT_EXPORT DevToolsAgentHost | 21 class CONTENT_EXPORT DevToolsAgentHost |
21 : public base::RefCounted<DevToolsAgentHost> { | 22 : public base::RefCounted<DevToolsAgentHost> { |
22 public: | 23 public: |
23 // Returns DevToolsAgentHost that can be used for inspecting |rvh|. | 24 // Returns DevToolsAgentHost that can be used for inspecting |rvh|. |
24 // New DevToolsAgentHost will be created if it does not exist. | 25 // New DevToolsAgentHost will be created if it does not exist. |
25 static scoped_refptr<DevToolsAgentHost> GetFor(RenderViewHost* rvh); | 26 static scoped_refptr<DevToolsAgentHost> GetFor(RenderViewHost* rvh); |
26 | 27 |
27 // Returns true iff an instance of DevToolsAgentHost for the |rvh| | 28 // Returns true iff an instance of DevToolsAgentHost for the |rvh| |
28 // does exist. | 29 // does exist. |
29 static bool HasFor(RenderViewHost* rvh); | 30 static bool HasFor(RenderViewHost* rvh); |
30 | 31 |
31 // Returns DevToolsAgentHost that can be used for inspecting shared worker | 32 // Returns DevToolsAgentHost that can be used for inspecting shared worker |
32 // with given worker process host id and routing id. | 33 // with given worker process host id and routing id. |
33 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, | 34 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, |
34 int worker_route_id); | 35 int worker_route_id); |
35 | 36 |
36 static bool IsDebuggerAttached(WebContents* web_contents); | 37 static bool IsDebuggerAttached(WebContents* web_contents); |
37 | 38 |
38 // Detaches given |rvh| from the agent host temporarily and returns a cookie | 39 // Detaches given |rvh| from the agent host temporarily and returns the agent |
39 // that allows to reattach another rvh to that agen thost later. Returns -1 if | 40 // host id that allows to reattach another rvh to that agent host later. |
40 // there is no agent host associated with the |rvh|. | 41 // Returns empty string if there is no agent host associated with the |rvh|. |
41 static int DisconnectRenderViewHost(RenderViewHost* rvh); | 42 static std::string DisconnectRenderViewHost(RenderViewHost* rvh); |
42 | 43 |
43 // Reattaches agent host detached with DisconnectRenderViewHost method above | 44 // Reattaches agent host detached with DisconnectRenderViewHost method above |
44 // to |rvh|. | 45 // to |rvh|. |
45 static void ConnectRenderViewHost(int agent_host_cookie, | 46 static void ConnectRenderViewHost(const std::string& agent_host_cookie, |
46 RenderViewHost* rvh); | 47 RenderViewHost* rvh); |
47 | 48 |
| 49 // Returns a list of all existing RenderViewHost's that can be debugged. |
| 50 static std::vector<RenderViewHost*> GetValidRenderViewHosts(); |
| 51 |
| 52 // Returns the unique id of the agent. |
| 53 virtual std::string GetId() = 0; |
| 54 |
48 // Returns render view host instance for this host if any. | 55 // Returns render view host instance for this host if any. |
49 virtual RenderViewHost* GetRenderViewHost() = 0; | 56 virtual RenderViewHost* GetRenderViewHost() = 0; |
50 | 57 |
51 protected: | 58 protected: |
52 friend class base::RefCounted<DevToolsAgentHost>; | 59 friend class base::RefCounted<DevToolsAgentHost>; |
53 virtual ~DevToolsAgentHost() {} | 60 virtual ~DevToolsAgentHost() {} |
54 }; | 61 }; |
55 | 62 |
56 } // namespace content | 63 } // namespace content |
57 | 64 |
58 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ | 65 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ |
OLD | NEW |