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 "base/files/file_path.h" 11 #include "content/common/content_export.h" 12 13 class GURL; 14 15 namespace net { 16 class StreamListenSocketFactory; 17 class URLRequestContextGetter; 18 } 19 20 namespace content { 21 22 class DevToolsHttpHandlerDelegate; 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. 27 class DevToolsHttpHandler { 28 public: 29 // Returns true if the given protocol version is supported. 30 CONTENT_EXPORT static bool IsSupportedProtocolVersion( 31 const std::string& version); 32 33 // Returns frontend resource id for the given resource |name|. 34 CONTENT_EXPORT static int GetFrontendResourceId( 35 const std::string& name); 36 37 // Takes ownership over |socket_factory| and |delegate|. 38 // If |active_port_output_directory| is non-empty, it is assumed the 39 // socket_factory was initialized with an ephemeral port (0). The 40 // port selected by the OS will be written to a well-known file in 41 // the output directory. 42 CONTENT_EXPORT static DevToolsHttpHandler* Start( 43 const net::StreamListenSocketFactory* socket_factory, 44 const std::string& frontend_url, 45 DevToolsHttpHandlerDelegate* delegate, 46 const base::FilePath& active_port_output_directory); 47 48 // Called from the main thread in order to stop protocol handler. 49 // Automatically destroys the handler instance. 50 virtual void Stop() = 0; 51 52 // Returns the URL for the address to debug |agent_host|. 53 virtual GURL GetFrontendURL() = 0; 54 55 protected: ~DevToolsHttpHandler()56 virtual ~DevToolsHttpHandler() {} 57 }; 58 59 } // namespace content 60 61 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_ 62