| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "net/server/http_server.h" | 15 #include "net/server/http_server.h" |
| 16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 17 | 17 |
| 18 class DevToolsClientHost; | 18 class DevToolsClientHost; |
| 19 class DevToolsHttpServer; | 19 class DevToolsHttpServer; |
| 20 class TabContents; | 20 class TabContents; |
| 21 class TabContentsWrapper; | 21 class TabContentsWrapper; |
| 22 | 22 |
| 23 class DevToolsHttpProtocolHandler | 23 class DevToolsHttpProtocolHandler |
| 24 : public HttpServer::Delegate, | 24 : public net::HttpServer::Delegate, |
| 25 public net::URLRequest::Delegate, | 25 public net::URLRequest::Delegate, |
| 26 public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> { | 26 public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> { |
| 27 public: | 27 public: |
| 28 typedef std::vector<TabContentsWrapper*> InspectableTabs; | 28 typedef std::vector<TabContentsWrapper*> InspectableTabs; |
| 29 class TabContentsProvider { | 29 class TabContentsProvider { |
| 30 public: | 30 public: |
| 31 TabContentsProvider() {} | 31 TabContentsProvider() {} |
| 32 virtual ~TabContentsProvider() {} | 32 virtual ~TabContentsProvider() {} |
| 33 virtual InspectableTabs GetInspectableTabs() = 0; | 33 virtual InspectableTabs GetInspectableTabs() = 0; |
| 34 private: | 34 private: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 49 private: | 49 private: |
| 50 friend class base::RefCountedThreadSafe<DevToolsHttpProtocolHandler>; | 50 friend class base::RefCountedThreadSafe<DevToolsHttpProtocolHandler>; |
| 51 | 51 |
| 52 DevToolsHttpProtocolHandler(const std::string& ip, | 52 DevToolsHttpProtocolHandler(const std::string& ip, |
| 53 int port, | 53 int port, |
| 54 const std::string& frontend_url, | 54 const std::string& frontend_url, |
| 55 TabContentsProvider* provider); | 55 TabContentsProvider* provider); |
| 56 virtual ~DevToolsHttpProtocolHandler(); | 56 virtual ~DevToolsHttpProtocolHandler(); |
| 57 void Start(); | 57 void Start(); |
| 58 | 58 |
| 59 // HttpServer::Delegate implementation. | 59 // net::HttpServer::Delegate implementation. |
| 60 virtual void OnHttpRequest(int connection_id, | 60 virtual void OnHttpRequest(int connection_id, |
| 61 const HttpServerRequestInfo& info); | 61 const net::HttpServerRequestInfo& info); |
| 62 virtual void OnWebSocketRequest(int connection_id, | 62 virtual void OnWebSocketRequest(int connection_id, |
| 63 const HttpServerRequestInfo& info); | 63 const net::HttpServerRequestInfo& info); |
| 64 virtual void OnWebSocketMessage(int connection_id, | 64 virtual void OnWebSocketMessage(int connection_id, |
| 65 const std::string& data); | 65 const std::string& data); |
| 66 virtual void OnClose(int connection_id); | 66 virtual void OnClose(int connection_id); |
| 67 | 67 |
| 68 virtual void OnRootRequestUI(int connection_id, | 68 virtual void OnRootRequestUI(int connection_id, |
| 69 const HttpServerRequestInfo& info); | 69 const net::HttpServerRequestInfo& info); |
| 70 virtual void OnJsonRequestUI(int connection_id, | 70 virtual void OnJsonRequestUI(int connection_id, |
| 71 const HttpServerRequestInfo& info); | 71 const net::HttpServerRequestInfo& info); |
| 72 virtual void OnWebSocketRequestUI(int connection_id, | 72 virtual void OnWebSocketRequestUI(int connection_id, |
| 73 const HttpServerRequestInfo& info); | 73 const net::HttpServerRequestInfo& info); |
| 74 virtual void OnWebSocketMessageUI(int connection_id, | 74 virtual void OnWebSocketMessageUI(int connection_id, |
| 75 const std::string& data); | 75 const std::string& data); |
| 76 virtual void OnCloseUI(int connection_id); | 76 virtual void OnCloseUI(int connection_id); |
| 77 | 77 |
| 78 // net::URLRequest::Delegate implementation. | 78 // net::URLRequest::Delegate implementation. |
| 79 virtual void OnResponseStarted(net::URLRequest* request); | 79 virtual void OnResponseStarted(net::URLRequest* request); |
| 80 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); | 80 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); |
| 81 | 81 |
| 82 void Init(); | 82 void Init(); |
| 83 void Teardown(); | 83 void Teardown(); |
| 84 void Bind(net::URLRequest* request, int connection_id); | 84 void Bind(net::URLRequest* request, int connection_id); |
| 85 void RequestCompleted(net::URLRequest* request); | 85 void RequestCompleted(net::URLRequest* request); |
| 86 | 86 |
| 87 void Send200(int connection_id, | 87 void Send200(int connection_id, |
| 88 const std::string& data, | 88 const std::string& data, |
| 89 const std::string& mime_type = "text/html"); | 89 const std::string& mime_type = "text/html"); |
| 90 void Send404(int connection_id); | 90 void Send404(int connection_id); |
| 91 void Send500(int connection_id, | 91 void Send500(int connection_id, |
| 92 const std::string& message); | 92 const std::string& message); |
| 93 void AcceptWebSocket(int connection_id, | 93 void AcceptWebSocket(int connection_id, |
| 94 const HttpServerRequestInfo& request); | 94 const net::HttpServerRequestInfo& request); |
| 95 | 95 |
| 96 TabContents* GetTabContents(int session_id); | 96 TabContents* GetTabContents(int session_id); |
| 97 | 97 |
| 98 std::string ip_; | 98 std::string ip_; |
| 99 int port_; | 99 int port_; |
| 100 std::string overriden_frontend_url_; | 100 std::string overriden_frontend_url_; |
| 101 scoped_refptr<HttpServer> server_; | 101 scoped_refptr<net::HttpServer> server_; |
| 102 typedef std::map<net::URLRequest*, int> | 102 typedef std::map<net::URLRequest*, int> |
| 103 RequestToSocketMap; | 103 RequestToSocketMap; |
| 104 RequestToSocketMap request_to_connection_io_; | 104 RequestToSocketMap request_to_connection_io_; |
| 105 typedef std::map<int, std::set<net::URLRequest*> > | 105 typedef std::map<int, std::set<net::URLRequest*> > |
| 106 ConnectionToRequestsMap; | 106 ConnectionToRequestsMap; |
| 107 ConnectionToRequestsMap connection_to_requests_io_; | 107 ConnectionToRequestsMap connection_to_requests_io_; |
| 108 typedef std::map<net::URLRequest*, scoped_refptr<net::IOBuffer> > | 108 typedef std::map<net::URLRequest*, scoped_refptr<net::IOBuffer> > |
| 109 BuffersMap; | 109 BuffersMap; |
| 110 BuffersMap request_to_buffer_io_; | 110 BuffersMap request_to_buffer_io_; |
| 111 typedef std::map<int, DevToolsClientHost*> | 111 typedef std::map<int, DevToolsClientHost*> |
| 112 ConnectionToClientHostMap; | 112 ConnectionToClientHostMap; |
| 113 ConnectionToClientHostMap connection_to_client_host_ui_; | 113 ConnectionToClientHostMap connection_to_client_host_ui_; |
| 114 scoped_ptr<TabContentsProvider> tab_contents_provider_; | 114 scoped_ptr<TabContentsProvider> tab_contents_provider_; |
| 115 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpProtocolHandler); | 115 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpProtocolHandler); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ | 118 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_ |
| OLD | NEW |