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

Side by Side Diff: content/public/browser/devtools_agent_host.h

Issue 12319114: Extract debugger target enumeration into a separate class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@debugger
Patch Set: Addressed comments Created 7 years, 9 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
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 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 NullId if there is no agent host associated with the |rvh|.
41 static int DisconnectRenderViewHost(RenderViewHost* rvh); 42 static std::string DisconnectRenderViewHost(RenderViewHost* rvh);
jam 2013/03/06 17:41:52 why is this changing from an integer to a string t
Vladislav Kaznacheev 2013/03/06 18:26:15 Several reasons: 1. It does not have to be an int,
jam 2013/03/06 22:45:27 So a random integer wouldn't be enough? I ask beca
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 // Creates or find DevToolsAgentHosts for RenderViewHosts in a list and
53 // retains them as long as the corresponding RenderViewHosts are valid.
54 static void RetainFor(std::vector<RenderViewHost*> rvh_list);
jam 2013/03/06 17:41:52 RetainFor, GetRetained, and GetId() are only calle
Vladislav Kaznacheev 2013/03/06 18:26:15 Yes, these will be called from at least two places
jam 2013/03/06 22:45:27 Can you explain how they're called from chrome? It
55
56 // Returns retained DevToolsAgentHost for a given id.
57 static DevToolsAgentHost* GetRetained(const std::string& id);
58
59 static const std::string NullId;
60
61 // Returns the unique id of the agent.
62 virtual std::string GetId() = 0;
63
48 // Returns render view host instance for this host if any. 64 // Returns render view host instance for this host if any.
49 virtual RenderViewHost* GetRenderViewHost() = 0; 65 virtual RenderViewHost* GetRenderViewHost() = 0;
50 66
51 protected: 67 protected:
52 friend class base::RefCounted<DevToolsAgentHost>; 68 friend class base::RefCounted<DevToolsAgentHost>;
53 virtual ~DevToolsAgentHost() {} 69 virtual ~DevToolsAgentHost() {}
54 }; 70 };
55 71
56 } // namespace content 72 } // namespace content
57 73
58 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 74 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698