Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: content/public/browser/devtools_http_handler.h

Issue 497223003: Revert of Replace StreamListenSocket with StreamSocket in HttpServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_
6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_ 6 #define CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
13 12
14 class GURL; 13 class GURL;
15 14
16 namespace net { 15 namespace net {
17 class ServerSocket; 16 class StreamListenSocketFactory;
18 class URLRequestContextGetter; 17 class URLRequestContextGetter;
19 } 18 }
20 19
21 namespace content { 20 namespace content {
22 21
23 class DevToolsHttpHandlerDelegate; 22 class DevToolsHttpHandlerDelegate;
24 23
25 // This class is used for managing DevTools remote debugging server. 24 // This class is used for managing DevTools remote debugging server.
26 // Clients can connect to the specified ip:port and start debugging 25 // Clients can connect to the specified ip:port and start debugging
27 // this browser. 26 // this browser.
28 class DevToolsHttpHandler { 27 class DevToolsHttpHandler {
29 public: 28 public:
30
31 // Factory of net::ServerSocket. This is to separate instantiating dev tools
32 // and instantiating server socket.
33 class CONTENT_EXPORT ServerSocketFactory {
34 public:
35 ServerSocketFactory(const std::string& address, int port, int backlog);
36 virtual ~ServerSocketFactory();
37
38 // Returns a new instance of ServerSocket or NULL if an error occurred.
39 // It calls ServerSocket::ListenWithAddressAndPort() with address, port and
40 // backlog passed to constructor.
41 virtual scoped_ptr<net::ServerSocket> CreateAndListen() const;
42
43 protected:
44 // Creates a server socket. ServerSocket::Listen() will be called soon
45 // unless it returns NULL.
46 virtual scoped_ptr<net::ServerSocket> Create() const = 0;
47
48 const std::string address_;
49 const int port_;
50 const int backlog_;
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(ServerSocketFactory);
54 };
55
56 // Returns true if the given protocol version is supported. 29 // Returns true if the given protocol version is supported.
57 CONTENT_EXPORT static bool IsSupportedProtocolVersion( 30 CONTENT_EXPORT static bool IsSupportedProtocolVersion(
58 const std::string& version); 31 const std::string& version);
59 32
60 // Returns frontend resource id for the given resource |name|. 33 // Returns frontend resource id for the given resource |name|.
61 CONTENT_EXPORT static int GetFrontendResourceId( 34 CONTENT_EXPORT static int GetFrontendResourceId(
62 const std::string& name); 35 const std::string& name);
63 36
64 // Takes ownership over |socket_factory| and |delegate|. 37 // Takes ownership over |socket_factory| and |delegate|.
65 // If |active_port_output_directory| is non-empty, it is assumed the 38 // If |active_port_output_directory| is non-empty, it is assumed the
66 // socket_factory was initialized with an ephemeral port (0). The 39 // socket_factory was initialized with an ephemeral port (0). The
67 // port selected by the OS will be written to a well-known file in 40 // port selected by the OS will be written to a well-known file in
68 // the output directory. 41 // the output directory.
69 CONTENT_EXPORT static DevToolsHttpHandler* Start( 42 CONTENT_EXPORT static DevToolsHttpHandler* Start(
70 scoped_ptr<ServerSocketFactory> server_socket_factory, 43 const net::StreamListenSocketFactory* socket_factory,
71 const std::string& frontend_url, 44 const std::string& frontend_url,
72 DevToolsHttpHandlerDelegate* delegate, 45 DevToolsHttpHandlerDelegate* delegate,
73 const base::FilePath& active_port_output_directory); 46 const base::FilePath& active_port_output_directory);
74 47
75 // Called from the main thread in order to stop protocol handler. 48 // Called from the main thread in order to stop protocol handler.
76 // Automatically destroys the handler instance. 49 // Automatically destroys the handler instance.
77 virtual void Stop() = 0; 50 virtual void Stop() = 0;
78 51
79 // Returns the URL for the address to debug |agent_host|. 52 // Returns the URL for the address to debug |agent_host|.
80 virtual GURL GetFrontendURL() = 0; 53 virtual GURL GetFrontendURL() = 0;
81 54
82 protected: 55 protected:
83 virtual ~DevToolsHttpHandler() {} 56 virtual ~DevToolsHttpHandler() {}
84 }; 57 };
85 58
86 } // namespace content 59 } // namespace content
87 60
88 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_ 61 #endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_http_handler_unittest.cc ('k') | content/shell/browser/shell_devtools_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698