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

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

Issue 459403002: DevTools: Added service workers to remote debugging targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remote debugger is now properly notified of service worker being closed 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
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/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/browser/devtools_agent_host_client.h" 15 #include "content/public/browser/devtools_agent_host_client.h"
16 #include "url/gurl.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 class DevToolsExternalAgentProxyDelegate; 20 class DevToolsExternalAgentProxyDelegate;
20 class WebContents; 21 class WebContents;
21 22
22 // Describes interface for managing devtools agents from browser process. 23 // Describes interface for managing devtools agents from browser process.
23 class CONTENT_EXPORT DevToolsAgentHost 24 class CONTENT_EXPORT DevToolsAgentHost
24 : public base::RefCounted<DevToolsAgentHost> { 25 : public base::RefCounted<DevToolsAgentHost> {
25 public: 26 public:
27 // Return value of GetType for agent host associated with WebContents.
28 static const char kTypeWebContents[];
dgozman 2014/08/21 11:50:24 I think we should use enum and let embedder serial
vkuzkokov 2014/08/21 14:17:53 Done.
29
30 // Return value of GetType for agent host associated with shared worker.
31 static const char kTypeWorker[];
dgozman 2014/08/21 11:50:24 kTypeSharedWorker
vkuzkokov 2014/08/21 14:17:53 Done.
32
33 // Return value of GetType for agent host associated with service worker.
34 static const char kTypeServiceWorker[];
35
26 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist. 36 // Returns DevToolsAgentHost with a given |id| or NULL of it does not exist.
27 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id); 37 static scoped_refptr<DevToolsAgentHost> GetForId(const std::string& id);
28 38
29 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|. 39 // Returns DevToolsAgentHost that can be used for inspecting |web_contents|.
30 // New DevToolsAgentHost will be created if it does not exist. 40 // New DevToolsAgentHost will be created if it does not exist.
31 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor( 41 static scoped_refptr<DevToolsAgentHost> GetOrCreateFor(
32 WebContents* web_contents); 42 WebContents* web_contents);
33 43
34 // Returns true iff an instance of DevToolsAgentHost for the |web_contents| 44 // Returns true iff an instance of DevToolsAgentHost for the |web_contents|
35 // does exist. 45 // does exist.
36 static bool HasFor(WebContents* web_contents); 46 static bool HasFor(WebContents* web_contents);
37 47
38 // Returns DevToolsAgentHost that can be used for inspecting shared worker 48 // Returns DevToolsAgentHost that can be used for inspecting shared worker
39 // with given worker process host id and routing id. 49 // with given worker process host id and routing id.
40 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id, 50 static scoped_refptr<DevToolsAgentHost> GetForWorker(int worker_process_id,
41 int worker_route_id); 51 int worker_route_id);
42 52
43 // Creates DevToolsAgentHost that communicates to the target by means of 53 // Creates DevToolsAgentHost that communicates to the target by means of
44 // provided |delegate|. |delegate| ownership is passed to the created agent 54 // provided |delegate|. |delegate| ownership is passed to the created agent
45 // host. 55 // host.
46 static scoped_refptr<DevToolsAgentHost> Create( 56 static scoped_refptr<DevToolsAgentHost> Create(
47 DevToolsExternalAgentProxyDelegate* delegate); 57 DevToolsExternalAgentProxyDelegate* delegate);
48 58
49 static bool IsDebuggerAttached(WebContents* web_contents); 59 static bool IsDebuggerAttached(WebContents* web_contents);
50 60
51 // Returns a list of all existing WebContents that can be debugged. 61 typedef std::vector<scoped_refptr<DevToolsAgentHost> > List;
52 static std::vector<WebContents*> GetInspectableWebContents(); 62
63 // Returns all possible DevToolsAgentHosts.
64 static List GetOrCreateAll();
53 65
54 // Client attaches to this agent host to start debugging it. 66 // Client attaches to this agent host to start debugging it.
55 virtual void AttachClient(DevToolsAgentHostClient* client) = 0; 67 virtual void AttachClient(DevToolsAgentHostClient* client) = 0;
56 68
57 // Already attached client detaches from this agent host to stop debugging it. 69 // Already attached client detaches from this agent host to stop debugging it.
58 virtual void DetachClient() = 0; 70 virtual void DetachClient() = 0;
59 71
60 // Returns true if there is a client attached. 72 // Returns true if there is a client attached.
61 virtual bool IsAttached() = 0; 73 virtual bool IsAttached() = 0;
62 74
(...skipping 12 matching lines...) Expand all
75 // Temporarily detaches render view host from this host. Must be followed by 87 // Temporarily detaches render view host from this host. Must be followed by
76 // a call to ConnectWebContents (may leak the host instance otherwise). 88 // a call to ConnectWebContents (may leak the host instance otherwise).
77 virtual void DisconnectWebContents() = 0; 89 virtual void DisconnectWebContents() = 0;
78 90
79 // Attaches render view host to this host. 91 // Attaches render view host to this host.
80 virtual void ConnectWebContents(WebContents* web_contents) = 0; 92 virtual void ConnectWebContents(WebContents* web_contents) = 0;
81 93
82 // Returns true if DevToolsAgentHost is for worker. 94 // Returns true if DevToolsAgentHost is for worker.
83 virtual bool IsWorker() const = 0; 95 virtual bool IsWorker() const = 0;
84 96
97 // Returns agent host type.
98 virtual std::string GetType() = 0;
99
100 // Returns agent host title.
101 virtual std::string GetTitle() = 0;
102
103 // Returns url associated with agent host.
104 virtual GURL GetURL() = 0;
105
106 // Activates agent host. Returns false if the operation failed.
107 virtual bool Activate() = 0;
108
109 // Closes agent host. Returns false if the operation failed.
110 virtual bool Close() = 0;
111
85 // Terminates all debugging sessions and detaches all clients. 112 // Terminates all debugging sessions and detaches all clients.
86 static void DetachAllClients(); 113 static void DetachAllClients();
87 114
88 typedef base::Callback<void(DevToolsAgentHost*, bool attached)> 115 typedef base::Callback<void(DevToolsAgentHost*, bool attached)>
89 AgentStateCallback; 116 AgentStateCallback;
90 117
91 static void AddAgentStateCallback(const AgentStateCallback& callback); 118 static void AddAgentStateCallback(const AgentStateCallback& callback);
92 static void RemoveAgentStateCallback(const AgentStateCallback& callback); 119 static void RemoveAgentStateCallback(const AgentStateCallback& callback);
93 120
94 protected: 121 protected:
95 friend class base::RefCounted<DevToolsAgentHost>; 122 friend class base::RefCounted<DevToolsAgentHost>;
96 virtual ~DevToolsAgentHost() {} 123 virtual ~DevToolsAgentHost() {}
97 }; 124 };
98 125
99 } // namespace content 126 } // namespace content
100 127
101 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_ 128 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_AGENT_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698