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_HTTP_HANDLER_H_
6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_
10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
18 class URLRequestContextGetter
;
23 class DevToolsHttpHandlerDelegate
;
25 // This class is used for managing DevTools remote debugging server.
26 // Clients can connect to the specified ip:port and start debugging
28 class DevToolsHttpHandler
{
31 // Factory of net::ServerSocket. This is to separate instantiating dev tools
32 // and instantiating server sockets.
33 // All methods including destructor are called on a separate thread
34 // different from any BrowserThread instance.
35 class CONTENT_EXPORT ServerSocketFactory
{
37 virtual ~ServerSocketFactory() {}
39 // Returns a new instance of ServerSocket or nullptr if an error occurred.
40 virtual scoped_ptr
<net::ServerSocket
> CreateForHttpServer();
42 // Creates a named socket for reversed tethering implementation (used with
43 // remote debugging, primarily for mobile).
44 virtual scoped_ptr
<net::ServerSocket
> CreateForTethering(
45 std::string
* out_name
);
48 // Returns true if the given protocol version is supported.
49 CONTENT_EXPORT
static bool IsSupportedProtocolVersion(
50 const std::string
& version
);
52 // Returns frontend resource id for the given resource |name|.
53 CONTENT_EXPORT
static int GetFrontendResourceId(
54 const std::string
& name
);
56 // Takes ownership over |socket_factory| and |delegate|.
57 // If |active_port_output_directory| is non-empty, it is assumed the
58 // socket_factory was initialized with an ephemeral port (0). The
59 // port selected by the OS will be written to a well-known file in
60 // the output directory.
61 CONTENT_EXPORT
static DevToolsHttpHandler
* Start(
62 scoped_ptr
<ServerSocketFactory
> server_socket_factory
,
63 const std::string
& frontend_url
,
64 DevToolsHttpHandlerDelegate
* delegate
,
65 const base::FilePath
& active_port_output_directory
);
67 // Returns the URL for the file at |path| in frontend.
68 virtual GURL
GetFrontendURL(const std::string
& path
) = 0;
70 virtual ~DevToolsHttpHandler() {}
73 } // namespace content
75 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_