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

Side by Side Diff: content/browser/debugger/devtools_manager.h

Issue 7648032: DevTools: introduce DevToolsAgentHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_
6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ 6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "content/browser/debugger/devtools_client_host.h" 12 #include "content/browser/debugger/devtools_client_host.h"
13 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h"
15 13
16 namespace IPC { 14 namespace IPC {
17 class Message; 15 class Message;
18 } 16 }
19 17
18 class DevToolsAgentHost;
20 class DevToolsNetLogObserver; 19 class DevToolsNetLogObserver;
21 class GURL; 20 class GURL;
22 class IOThread; 21 class IOThread;
23 class PrefService; 22 class PrefService;
24 class RenderViewHost; 23 class RenderViewHost;
25 class TabContents; 24 class TabContents;
26 25
27 typedef std::map<std::string, std::string> DevToolsRuntimeProperties; 26 typedef std::map<std::string, std::string> DevToolsRuntimeProperties;
28 27
29 // This class is a singleton that manages DevToolsClientHost instances and 28 // This class is a singleton that manages DevToolsClientHost instances and
30 // routes messages between developer tools clients and agents. 29 // routes messages between developer tools clients and agents.
31 class DevToolsManager : public DevToolsClientHost::CloseListener, 30 class DevToolsManager : public DevToolsClientHost::CloseListener {
32 public NotificationObserver {
33 public: 31 public:
34 static DevToolsManager* GetInstance(); 32 static DevToolsManager* GetInstance();
35 33
36 DevToolsManager(); 34 DevToolsManager();
37 virtual ~DevToolsManager(); 35 virtual ~DevToolsManager();
38 36
39 // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if 37 // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if
40 // there is no alive DevToolsClientHost registered for |inspected_rvh|. 38 // there is no alive DevToolsClientHost registered for |inspected_rvh|.
41 DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh); 39 DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh);
pfeldman 2011/08/16 06:48:57 Could you group rvh methods and comment on the blo
yurys 2011/08/16 08:14:48 Done.
40 DevToolsClientHost* GetDevToolsClientHostFor(DevToolsAgentHost* agent_host);
42 41
43 // Registers new DevToolsClientHost for |inspected_rvh|. There must be no 42 // Registers new DevToolsClientHost for |inspected_rvh|. There must be no
44 // other DevToolsClientHosts registered for the RenderViewHost at the moment. 43 // other DevToolsClientHosts registered for the RenderViewHost at the moment.
45 void RegisterDevToolsClientHostFor(RenderViewHost* inspected_rvh, 44 void RegisterDevToolsClientHostFor(RenderViewHost* inspected_rvh,
46 DevToolsClientHost* client_host); 45 DevToolsClientHost* client_host);
47 void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh); 46 void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh);
47 void UnregisterDevToolsClientHostFor(DevToolsAgentHost* agent_host);
48 48
49 bool ForwardToDevToolsAgent(DevToolsClientHost* from, 49 bool ForwardToDevToolsAgent(DevToolsClientHost* from,
50 const IPC::Message& message); 50 const IPC::Message& message);
51 void ForwardToDevToolsClient(RenderViewHost* inspected_rvh, 51 void ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
52 const IPC::Message& message); 52 const IPC::Message& message);
53 53
54 void RuntimePropertyChanged(RenderViewHost* inspected_rvh, 54 void RuntimePropertyChanged(RenderViewHost* inspected_rvh,
55 const std::string& name, 55 const std::string& name,
56 const std::string& value); 56 const std::string& value);
57 57
(...skipping 21 matching lines...) Expand all
79 // Closes all open developer tools windows. 79 // Closes all open developer tools windows.
80 void CloseAllClientHosts(); 80 void CloseAllClientHosts();
81 81
82 private: 82 private:
83 // DevToolsClientHost::CloseListener override. 83 // DevToolsClientHost::CloseListener override.
84 // This method will remove all references from the manager to the 84 // This method will remove all references from the manager to the
85 // DevToolsClientHost and unregister all listeners related to the 85 // DevToolsClientHost and unregister all listeners related to the
86 // DevToolsClientHost. 86 // DevToolsClientHost.
87 virtual void ClientHostClosing(DevToolsClientHost* host); 87 virtual void ClientHostClosing(DevToolsClientHost* host);
88 88
89 // Overridden from NotificationObserver: 89 // Returns DevToolsAgentHost inspected by the DevToolsClientHost.
90 virtual void Observe(int type, 90 DevToolsAgentHost* GetAgentHost(DevToolsClientHost* client_host);
91 const NotificationSource& source,
92 const NotificationDetails& details);
93
94 // Returns RenderViewHost for the tab that is inspected by devtools
95 // client hosted by DevToolsClientHost.
96 RenderViewHost* GetInspectedRenderViewHost(DevToolsClientHost* client_host);
97 91
98 void SendAttachToAgent(RenderViewHost* inspected_rvh); 92 void SendAttachToAgent(RenderViewHost* inspected_rvh);
99 void SendDetachToAgent(RenderViewHost* inspected_rvh); 93 void SendDetachToAgent(DevToolsAgentHost*);
100 94
101 void BindClientHost(RenderViewHost* inspected_rvh, 95 void BindClientHost(RenderViewHost* inspected_rvh,
pfeldman 2011/08/16 06:48:57 Bind and Unbind should operate similar terms. Coul
yurys 2011/08/16 08:14:48 Done.
102 DevToolsClientHost* client_host, 96 DevToolsClientHost* client_host,
103 const DevToolsRuntimeProperties& runtime_properties); 97 const DevToolsRuntimeProperties& runtime_properties);
104 98
105 void UnbindClientHost(RenderViewHost* inspected_rvh, 99 void UnbindClientHost(DevToolsAgentHost* agent_host,
106 DevToolsClientHost* client_host); 100 DevToolsClientHost* client_host);
107 101
108 // These two maps are for tracking dependencies between inspected tabs and 102 // These two maps are for tracking dependencies between inspected tabs and
109 // their DevToolsClientHosts. They are useful for routing devtools messages 103 // their DevToolsClientHosts. They are useful for routing devtools messages
110 // and allow us to have at most one devtools client host per tab. 104 // and allow us to have at most one devtools client host per tab.
111 // 105 //
112 // DevToolsManager start listening to DevToolsClientHosts when they are put 106 // DevToolsManager start listening to DevToolsClientHosts when they are put
113 // into these maps and removes them when they are closing. 107 // into these maps and removes them when they are closing.
114 typedef std::map<RenderViewHost*, DevToolsClientHost*> 108 typedef std::map<DevToolsAgentHost*, DevToolsClientHost*>
115 InspectedRvhToClientHostMap; 109 AgentToClientHostMap;
116 InspectedRvhToClientHostMap inspected_rvh_to_client_host_; 110 AgentToClientHostMap agent_to_client_host_;
117 111
118 typedef std::map<DevToolsClientHost*, RenderViewHost*> 112 typedef std::map<DevToolsClientHost*, DevToolsAgentHost*>
119 ClientHostToInspectedRvhMap; 113 ClientHostToInspectedRvhMap;
120 ClientHostToInspectedRvhMap client_host_to_inspected_rvh_; 114 ClientHostToInspectedRvhMap client_to_agent_host_;
121 115
122 typedef std::map<RenderViewHost*, DevToolsRuntimeProperties> 116 typedef std::map<DevToolsAgentHost*, DevToolsRuntimeProperties>
123 RuntimePropertiesMap; 117 RuntimePropertiesMap;
124 RuntimePropertiesMap runtime_properties_map_; 118 RuntimePropertiesMap runtime_properties_map_;
125 119
126 typedef std::map<int, 120 typedef std::map<int,
127 std::pair<DevToolsClientHost*, DevToolsRuntimeProperties> > 121 std::pair<DevToolsClientHost*, DevToolsRuntimeProperties> >
128 OrphanClientHosts; 122 OrphanClientHosts;
129 OrphanClientHosts orphan_client_hosts_; 123 OrphanClientHosts orphan_client_hosts_;
130 int last_orphan_cookie_; 124 int last_orphan_cookie_;
131 125
132 NotificationRegistrar registrar_;
133
134 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); 126 DISALLOW_COPY_AND_ASSIGN(DevToolsManager);
135 }; 127 };
136 128
137 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ 129 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698