diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 13:52:30 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 13:52:30 +0000 |
commit | 98f5f88b53f774cee109503b0225a5bfb9deb550 (patch) | |
tree | 32af75ae9784181c85e577327d8020192658c519 /chrome/browser/debugger/devtools_protocol_handler.h | |
parent | 198d8d43c5ccff8d0d48bbd3fef31917aa9d3db6 (diff) | |
download | chromium_src-98f5f88b53f774cee109503b0225a5bfb9deb550.zip chromium_src-98f5f88b53f774cee109503b0225a5bfb9deb550.tar.gz chromium_src-98f5f88b53f774cee109503b0225a5bfb9deb550.tar.bz2 |
DevTools. Add V8 Application Remote Debugging Protocol support by apavlov. Original CL: http://codereview.chromium.org/56109
Review URL: http://codereview.chromium.org/66031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13502 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger/devtools_protocol_handler.h')
-rw-r--r-- | chrome/browser/debugger/devtools_protocol_handler.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/chrome/browser/debugger/devtools_protocol_handler.h b/chrome/browser/debugger/devtools_protocol_handler.h new file mode 100644 index 0000000..4af8ebb --- /dev/null +++ b/chrome/browser/debugger/devtools_protocol_handler.h @@ -0,0 +1,81 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_PROTOCOL_HANDLER_H_ +#define CHROME_BROWSER_DEBUGGER_DEVTOOLS_PROTOCOL_HANDLER_H_ + +#include <string> + +#include "base/hash_tables.h" +#include "base/ref_counted.h" +#include "base/scoped_ptr.h" +#include "chrome/browser/debugger/devtools_remote.h" +#include "net/base/listen_socket.h" + +class InspectableTabProxy; +class DevToolsRemoteListenSocket; +class DevToolsRemoteMessage; +class WebContents; + +// Dispatches DevToolsRemoteMessages to their appropriate handlers (Tools) +// based on the value of the Tool message header. +class DevToolsProtocolHandler + : public DevToolsRemoteListener, + public OutboundSocketDelegate, + public ListenSocket::ListenSocketDelegate { + public: + typedef base::hash_map< std::string, scoped_refptr<DevToolsRemoteListener> > + ToolToListenerMap; + + explicit DevToolsProtocolHandler(int port); + virtual ~DevToolsProtocolHandler(); + + // This method should be called after the object construction. + void Start(); + + // This method should be called before the object destruction. + void Stop(); + + // Registers a |listener| to handle messages for a certain |tool_name| Tool. + // |listener| is the new message handler to register. + // As DevToolsRemoteListener inherits base::RefCountedThreadSafe, + // you should have no problems with ownership and destruction. + // |tool_name| is the name of the Tool to associate the listener with. + void RegisterDestination(DevToolsRemoteListener* listener, + const std::string& tool_name); + + // Unregisters a |listener| so that it will no longer handle messages + // directed to the specified |tool_name| tool. + void UnregisterDestination(DevToolsRemoteListener* listener, + const std::string& tool_name); + + InspectableTabProxy* inspectable_tab_proxy() { + return inspectable_tab_proxy_.get(); + } + + // DevToolsRemoteListener interface + virtual void HandleMessage(const DevToolsRemoteMessage& message); + + // OutboundSocketDelegate interface + virtual void Send(const DevToolsRemoteMessage& message); + + // ListenSocket::ListenSocketDelegate interface + virtual void DidAccept(ListenSocket *server, ListenSocket *connection); + virtual void DidRead(ListenSocket *connection, const std::string& data); + virtual void DidClose(ListenSocket *sock); + + private: + void Init(); + void Teardown(); + int port_; + MessageLoop* ui_loop_; + MessageLoop* io_loop_; + ToolToListenerMap tool_to_listener_map_; + scoped_refptr<ListenSocket> connection_; + scoped_refptr<DevToolsRemoteListenSocket> server_; + scoped_ptr<InspectableTabProxy> inspectable_tab_proxy_; + DISALLOW_COPY_AND_ASSIGN(DevToolsProtocolHandler); +}; + +#endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_PROTOCOL_HANDLER_H_ |