| OLD | NEW |
| 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 CHROME_BROWSER_DEBUGGER_INSPECTABLE_TAB_PROXY_H_ | 5 #ifndef CHROME_BROWSER_DEBUGGER_INSPECTABLE_TAB_PROXY_H_ |
| 6 #define CHROME_BROWSER_DEBUGGER_INSPECTABLE_TAB_PROXY_H_ | 6 #define CHROME_BROWSER_DEBUGGER_INSPECTABLE_TAB_PROXY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 13 #include "content/browser/debugger/devtools_client_host.h" | 13 #include "content/public/browser/devtools/devtools_client_host.h" |
| 14 | 14 |
| 15 class DebuggerRemoteService; | 15 class DebuggerRemoteService; |
| 16 class DevToolsClientHost; | |
| 17 class DevToolsClientHostImpl; | 16 class DevToolsClientHostImpl; |
| 18 class TabContentsWrapper; | 17 class TabContentsWrapper; |
| 19 | 18 |
| 20 // Proxies debugged tabs' TabContentsWrapper using their UIDs. | 19 // Proxies debugged tabs' TabContentsWrapper using their UIDs. |
| 21 // Keeps track of tabs being debugged so that we can detach from | 20 // Keeps track of tabs being debugged so that we can detach from |
| 22 // them on remote debugger connection loss. | 21 // them on remote debugger connection loss. |
| 23 class InspectableTabProxy { | 22 class InspectableTabProxy { |
| 24 public: | 23 public: |
| 25 typedef base::hash_map<int32, TabContentsWrapper*> TabMap; | 24 typedef base::hash_map<int32, TabContentsWrapper*> TabMap; |
| 26 typedef base::hash_map<int32, DevToolsClientHostImpl*> IdToClientHostMap; | 25 typedef base::hash_map<int32, DevToolsClientHostImpl*> IdToClientHostMap; |
| 27 | 26 |
| 28 InspectableTabProxy(); | 27 InspectableTabProxy(); |
| 29 virtual ~InspectableTabProxy(); | 28 virtual ~InspectableTabProxy(); |
| 30 | 29 |
| 31 // Returns a map of SessionID to TabContentsWrapper for all Browser | 30 // Returns a map of SessionID to TabContentsWrapper for all Browser |
| 32 // instances. Clients should not keep the result around for extended periods | 31 // instances. Clients should not keep the result around for extended periods |
| 33 // of time as tabs might get closed thus invalidating the map. | 32 // of time as tabs might get closed thus invalidating the map. |
| 34 const TabMap& tab_map(); | 33 const TabMap& tab_map(); |
| 35 | 34 |
| 36 // Returns a DevToolsClientHostImpl for the given tab |id|. | 35 // Returns a DevToolsClientHostImpl for the given tab |id|. |
| 37 DevToolsClientHostImpl* ClientHostForTabId(int32 id); | 36 DevToolsClientHostImpl* ClientHostForTabId(int32 id); |
| 38 | 37 |
| 39 // Creates a new DevToolsClientHost implementor instance. | 38 // Creates a new DevToolsClientHost implementor instance. |
| 40 // |id| is the UID of the tab to debug. | 39 // |id| is the UID of the tab to debug. |
| 41 // |service| is the DebuggerRemoteService instance the DevToolsClient | 40 // |service| is the DebuggerRemoteService instance the DevToolsClient |
| 42 // messages shall be dispatched to. | 41 // messages shall be dispatched to. |
| 43 DevToolsClientHost* NewClientHost(int32 id, | 42 content::DevToolsClientHost* NewClientHost(int32 id, |
| 44 DebuggerRemoteService* service); | 43 DebuggerRemoteService* service); |
| 45 | 44 |
| 46 // Gets invoked when a remote debugger is detached. In this case we should | 45 // Gets invoked when a remote debugger is detached. In this case we should |
| 47 // send the corresponding message to the V8 debugger for each of the tabs | 46 // send the corresponding message to the V8 debugger for each of the tabs |
| 48 // the debugger is attached to, and invoke InspectedTabClosing(). | 47 // the debugger is attached to, and invoke InspectedTabClosing(). |
| 49 void OnRemoteDebuggerDetached(); | 48 void OnRemoteDebuggerDetached(); |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 TabMap tab_map_; | 51 TabMap tab_map_; |
| 53 IdToClientHostMap id_to_client_host_map_; | 52 IdToClientHostMap id_to_client_host_map_; |
| 54 DISALLOW_COPY_AND_ASSIGN(InspectableTabProxy); | 53 DISALLOW_COPY_AND_ASSIGN(InspectableTabProxy); |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 | 56 |
| 58 // An internal implementation of DevToolsClientHost that delegates | 57 // An internal implementation of DevToolsClientHost that delegates |
| 59 // messages sent for DevToolsClient to a DebuggerShell instance. | 58 // messages sent for DevToolsClient to a DebuggerShell instance. |
| 60 class DevToolsClientHostImpl : public DevToolsClientHost { | 59 class DevToolsClientHostImpl : public content::DevToolsClientHost { |
| 61 public: | 60 public: |
| 62 DevToolsClientHostImpl( | 61 DevToolsClientHostImpl( |
| 63 int32 id, | 62 int32 id, |
| 64 DebuggerRemoteService* service, | 63 DebuggerRemoteService* service, |
| 65 InspectableTabProxy::IdToClientHostMap* map); | 64 InspectableTabProxy::IdToClientHostMap* map); |
| 66 virtual ~DevToolsClientHostImpl(); | 65 virtual ~DevToolsClientHostImpl(); |
| 67 | 66 |
| 68 DebuggerRemoteService* debugger_remote_service() { | 67 DebuggerRemoteService* debugger_remote_service() { |
| 69 return service_; | 68 return service_; |
| 70 } | 69 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 81 void OnDebuggerOutput(const std::string& msg); | 80 void OnDebuggerOutput(const std::string& msg); |
| 82 virtual void FrameNavigating(const std::string& url); | 81 virtual void FrameNavigating(const std::string& url); |
| 83 void TabClosed(); | 82 void TabClosed(); |
| 84 | 83 |
| 85 int32 id_; | 84 int32 id_; |
| 86 DebuggerRemoteService* service_; | 85 DebuggerRemoteService* service_; |
| 87 InspectableTabProxy::IdToClientHostMap* map_; | 86 InspectableTabProxy::IdToClientHostMap* map_; |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 #endif // CHROME_BROWSER_DEBUGGER_INSPECTABLE_TAB_PROXY_H_ | 89 #endif // CHROME_BROWSER_DEBUGGER_INSPECTABLE_TAB_PROXY_H_ |
| OLD | NEW |