| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ |
| 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ | 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "net/server/http_listen_socket.h" | 13 #include "net/server/http_listen_socket.h" |
| 14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 15 | 15 |
| 16 class DevToolsClientHost; | 16 class DevToolsClientHost; |
| 17 class DevToolsHttpServer; | 17 class DevToolsHttpServer; |
| 18 class TabContents; | 18 class TabContents; |
| 19 | 19 |
| 20 class DevToolsHttpProtocolHandler | 20 class DevToolsHttpProtocolHandler |
| 21 : public HttpListenSocket::Delegate, | 21 : public HttpListenSocket::Delegate, |
| 22 public net::URLRequest::Delegate, | 22 public net::URLRequest::Delegate, |
| 23 public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> { | 23 public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> { |
| 24 public: | 24 public: |
| 25 explicit DevToolsHttpProtocolHandler(int port); | 25 static scoped_refptr<DevToolsHttpProtocolHandler> Start( |
| 26 int port, |
| 27 const std::string& frontend_url); |
| 26 | 28 |
| 27 // This method should be called after the object construction. | 29 // Called from the main thread in order to stop protocol handler. |
| 28 void Start(); | 30 // Will schedule tear down task on IO thread. |
| 29 | |
| 30 // This method should be called before the object destruction. | |
| 31 void Stop(); | 31 void Stop(); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 friend class base::RefCountedThreadSafe<DevToolsHttpProtocolHandler>; | 34 friend class base::RefCountedThreadSafe<DevToolsHttpProtocolHandler>; |
| 35 |
| 36 DevToolsHttpProtocolHandler(int port, const std::string& frontend_url); |
| 35 virtual ~DevToolsHttpProtocolHandler(); | 37 virtual ~DevToolsHttpProtocolHandler(); |
| 38 void Start(); |
| 36 | 39 |
| 37 // HttpListenSocket::Delegate implementation. | 40 // HttpListenSocket::Delegate implementation. |
| 38 virtual void OnHttpRequest(HttpListenSocket* socket, | 41 virtual void OnHttpRequest(HttpListenSocket* socket, |
| 39 const HttpServerRequestInfo& info); | 42 const HttpServerRequestInfo& info); |
| 40 virtual void OnWebSocketRequest(HttpListenSocket* socket, | 43 virtual void OnWebSocketRequest(HttpListenSocket* socket, |
| 41 const HttpServerRequestInfo& info); | 44 const HttpServerRequestInfo& info); |
| 42 virtual void OnWebSocketMessage(HttpListenSocket* socket, | 45 virtual void OnWebSocketMessage(HttpListenSocket* socket, |
| 43 const std::string& data); | 46 const std::string& data); |
| 44 virtual void OnClose(HttpListenSocket* socket); | 47 virtual void OnClose(HttpListenSocket* socket); |
| 45 | 48 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 void Send404(HttpListenSocket* socket); | 69 void Send404(HttpListenSocket* socket); |
| 67 void Send500(HttpListenSocket* socket, | 70 void Send500(HttpListenSocket* socket, |
| 68 const std::string& message); | 71 const std::string& message); |
| 69 void AcceptWebSocket(HttpListenSocket* socket, | 72 void AcceptWebSocket(HttpListenSocket* socket, |
| 70 const HttpServerRequestInfo& request); | 73 const HttpServerRequestInfo& request); |
| 71 void ReleaseSocket(HttpListenSocket* socket); | 74 void ReleaseSocket(HttpListenSocket* socket); |
| 72 | 75 |
| 73 TabContents* GetTabContents(int session_id); | 76 TabContents* GetTabContents(int session_id); |
| 74 | 77 |
| 75 int port_; | 78 int port_; |
| 79 std::string overriden_frontend_url_; |
| 76 scoped_refptr<HttpListenSocket> server_; | 80 scoped_refptr<HttpListenSocket> server_; |
| 77 typedef std::map<net::URLRequest*, HttpListenSocket*> | 81 typedef std::map<net::URLRequest*, HttpListenSocket*> |
| 78 RequestToSocketMap; | 82 RequestToSocketMap; |
| 79 RequestToSocketMap request_to_socket_io_; | 83 RequestToSocketMap request_to_socket_io_; |
| 80 typedef std::map<HttpListenSocket*, std::set<net::URLRequest*> > | 84 typedef std::map<HttpListenSocket*, std::set<net::URLRequest*> > |
| 81 SocketToRequestsMap; | 85 SocketToRequestsMap; |
| 82 SocketToRequestsMap socket_to_requests_io_; | 86 SocketToRequestsMap socket_to_requests_io_; |
| 83 typedef std::map<net::URLRequest*, scoped_refptr<net::IOBuffer> > | 87 typedef std::map<net::URLRequest*, scoped_refptr<net::IOBuffer> > |
| 84 BuffersMap; | 88 BuffersMap; |
| 85 BuffersMap request_to_buffer_io_; | 89 BuffersMap request_to_buffer_io_; |
| 86 typedef std::map<HttpListenSocket*, DevToolsClientHost*> | 90 typedef std::map<HttpListenSocket*, DevToolsClientHost*> |
| 87 SocketToClientHostMap; | 91 SocketToClientHostMap; |
| 88 SocketToClientHostMap socket_to_client_host_ui_; | 92 SocketToClientHostMap socket_to_client_host_ui_; |
| 89 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpProtocolHandler); | 93 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpProtocolHandler); |
| 90 }; | 94 }; |
| 91 | 95 |
| 92 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ | 96 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ |
| OLD | NEW |