devtools_http_handler.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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. 4 5#ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_ 6#define CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_ 7 8#include <string> 9 10#include "content/common/content_export.h" 11 12class GURL; 13 14namespace net { 15class StreamListenSocketFactory; 16class URLRequestContextGetter; 17} 18 19namespace content { 20 21class DevToolsHttpHandlerDelegate; 22class RenderViewHost; 23 24// This class is used for managing DevTools remote debugging server. 25// Clients can connect to the specified ip:port and start debugging 26// this browser. 27class DevToolsHttpHandler { 28 public: 29 // Interface responsible for mapping RenderViewHost instances to/from string 30 // identifiers. 31 class RenderViewHostBinding { 32 public: 33 virtual ~RenderViewHostBinding() {} 34 35 // Returns the mapping of RenderViewHost to identifier. 36 virtual std::string GetIdentifier(RenderViewHost* rvh) = 0; 37 38 // Returns the mapping of identifier to RenderViewHost. 39 virtual RenderViewHost* ForIdentifier(const std::string& identifier) = 0; 40 }; 41 42 // Returns frontend resource id for the given resource |name|. 43 CONTENT_EXPORT static int GetFrontendResourceId( 44 const std::string& name); 45 46 // Takes ownership over |socket_factory| and |delegate|. 47 CONTENT_EXPORT static DevToolsHttpHandler* Start( 48 const net::StreamListenSocketFactory* socket_factory, 49 const std::string& frontend_url, 50 DevToolsHttpHandlerDelegate* delegate); 51 52 // Called from the main thread in order to stop protocol handler. 53 // Automatically destroys the handler instance. 54 virtual void Stop() = 0; 55 56 // Set the RenderViewHostBinding instance. If no instance is provided the 57 // default implementation will be used. 58 virtual void SetRenderViewHostBinding(RenderViewHostBinding* binding) = 0; 59 60 // Returns the URL for the address to debug |render_view_host|. 61 virtual GURL GetFrontendURL(RenderViewHost* render_view_host) = 0; 62 63 protected: 64 virtual ~DevToolsHttpHandler() {} 65}; 66 67} // namespace content 68 69#endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_ 70