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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_MANAGER_H_
6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_MANAGER_H_
10 #include "base/callback.h"
11 #include "content/common/content_export.h"
19 class DevToolsAgentHost
;
20 class DevToolsClientHost
;
22 // DevToolsManager connects a devtools client to inspected agent and routes
23 // devtools messages between the inspected instance represented by the agent
24 // and devtools front-end represented by the client. If inspected agent
25 // gets terminated DevToolsManager will notify corresponding client and
26 // remove it from the map.
27 class CONTENT_EXPORT DevToolsManager
{
29 static DevToolsManager
* GetInstance();
31 virtual ~DevToolsManager() {}
33 // Routes devtools message from |from| client to corresponding
35 virtual bool DispatchOnInspectorBackend(DevToolsClientHost
* from
,
36 const std::string
& message
) = 0;
38 // Disconnects all client hostst.
39 virtual void CloseAllClientHosts() = 0;
41 // Returns agent that has |client_host| attached to it if there is one.
42 virtual DevToolsAgentHost
* GetDevToolsAgentHostFor(
43 DevToolsClientHost
* client_host
) = 0;
45 // Registers new DevToolsClientHost for inspected |agent_host|. If there is
46 // another DevToolsClientHost registered for the |agent_host| at the moment
47 // it is disconnected.
48 virtual void RegisterDevToolsClientHostFor(
49 DevToolsAgentHost
* agent_host
,
50 DevToolsClientHost
* client_host
) = 0;
52 // This method will remove all references from the manager to the
53 // DevToolsClientHost and unregister all listeners related to the
54 // DevToolsClientHost. Called by closing client.
55 virtual void ClientHostClosing(DevToolsClientHost
* client_host
) = 0;
57 typedef base::Callback
<void(DevToolsAgentHost
*, bool attached
)> Callback
;
59 virtual void AddAgentStateCallback(const Callback
& callback
) = 0;
60 virtual void RemoveAgentStateCallback(const Callback
& callback
) = 0;
63 } // namespace content
65 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_MANAGER_H_