| OLD | NEW |
| 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_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 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 "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/devtools_http_handler.h" | 16 #include "content/public/browser/devtools_http_handler.h" |
| 17 #include "content/public/browser/devtools_http_handler_delegate.h" | 17 #include "content/public/browser/devtools_http_handler_delegate.h" |
| 18 #include "net/server/http_server.h" | 18 #include "net/server/http_server.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class DictionaryValue; |
| 21 class Thread; | 22 class Thread; |
| 23 class Value; |
| 22 } | 24 } |
| 23 | 25 |
| 24 namespace net { | 26 namespace net { |
| 25 class StreamListenSocketFactory; | 27 class StreamListenSocketFactory; |
| 26 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace content { | 31 namespace content { |
| 30 | 32 |
| 31 class DevToolsClientHost; | 33 class DevToolsClientHost; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 61 const net::HttpServerRequestInfo& info) OVERRIDE; | 63 const net::HttpServerRequestInfo& info) OVERRIDE; |
| 62 virtual void OnWebSocketRequest( | 64 virtual void OnWebSocketRequest( |
| 63 int connection_id, | 65 int connection_id, |
| 64 const net::HttpServerRequestInfo& info) OVERRIDE; | 66 const net::HttpServerRequestInfo& info) OVERRIDE; |
| 65 virtual void OnWebSocketMessage(int connection_id, | 67 virtual void OnWebSocketMessage(int connection_id, |
| 66 const std::string& data) OVERRIDE; | 68 const std::string& data) OVERRIDE; |
| 67 virtual void OnClose(int connection_id) OVERRIDE; | 69 virtual void OnClose(int connection_id) OVERRIDE; |
| 68 | 70 |
| 69 void OnJsonRequestUI(int connection_id, | 71 void OnJsonRequestUI(int connection_id, |
| 70 const net::HttpServerRequestInfo& info); | 72 const net::HttpServerRequestInfo& info); |
| 73 void OnNewTargetRequestUI(int connection_id, |
| 74 const net::HttpServerRequestInfo& info); |
| 75 void OnCloseTargetRequestUI(int connection_id, |
| 76 const net::HttpServerRequestInfo& info); |
| 71 void OnThumbnailRequestUI(int connection_id, | 77 void OnThumbnailRequestUI(int connection_id, |
| 72 const net::HttpServerRequestInfo& info); | 78 const net::HttpServerRequestInfo& info); |
| 73 void OnWebSocketRequestUI(int connection_id, | 79 void OnWebSocketRequestUI(int connection_id, |
| 74 const net::HttpServerRequestInfo& info); | 80 const net::HttpServerRequestInfo& info); |
| 75 void OnWebSocketMessageUI(int connection_id, const std::string& data); | 81 void OnWebSocketMessageUI(int connection_id, const std::string& data); |
| 76 void OnCloseUI(int connection_id); | 82 void OnCloseUI(int connection_id); |
| 77 | 83 |
| 78 void Init(); | 84 void Init(); |
| 79 void TeardownAndRelease(); | 85 void TeardownAndRelease(); |
| 80 | 86 |
| 81 void Send200(int connection_id, | 87 void Send200(int connection_id, |
| 82 const std::string& data, | 88 const std::string& data, |
| 83 const std::string& mime_type = "text/html"); | 89 const std::string& mime_type = "text/html"); |
| 90 void SendJson(int connection_id, |
| 91 const net::HttpServerRequestInfo& info, |
| 92 const base::Value& value); |
| 84 void Send404(int connection_id); | 93 void Send404(int connection_id); |
| 85 void Send500(int connection_id, | 94 void Send500(int connection_id, |
| 86 const std::string& message); | 95 const std::string& message); |
| 87 void AcceptWebSocket(int connection_id, | 96 void AcceptWebSocket(int connection_id, |
| 88 const net::HttpServerRequestInfo& request); | 97 const net::HttpServerRequestInfo& request); |
| 89 | 98 |
| 90 PageList GeneratePageList(); | 99 PageList GeneratePageList(); |
| 91 | 100 |
| 92 // Returns the front end url without the host at the beginning. | 101 // Returns the front end url without the host at the beginning. |
| 93 std::string GetFrontendURLInternal(const std::string rvh_id, | 102 std::string GetFrontendURLInternal(const std::string rvh_id, |
| 94 const std::string& host); | 103 const std::string& host); |
| 95 | 104 |
| 105 PageInfo CreatePageInfo(RenderViewHost* rvh); |
| 106 |
| 107 base::DictionaryValue* SerializePageInfo(const PageInfo& page_info, |
| 108 const std::string& host); |
| 109 |
| 96 // The thread used by the devtools handler to run server socket. | 110 // The thread used by the devtools handler to run server socket. |
| 97 scoped_ptr<base::Thread> thread_; | 111 scoped_ptr<base::Thread> thread_; |
| 98 | 112 |
| 99 std::string overridden_frontend_url_; | 113 std::string overridden_frontend_url_; |
| 100 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; | 114 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; |
| 101 scoped_refptr<net::HttpServer> server_; | 115 scoped_refptr<net::HttpServer> server_; |
| 102 typedef std::map<int, content::DevToolsClientHost*> | 116 typedef std::map<int, content::DevToolsClientHost*> |
| 103 ConnectionToClientHostMap; | 117 ConnectionToClientHostMap; |
| 104 ConnectionToClientHostMap connection_to_client_host_ui_; | 118 ConnectionToClientHostMap connection_to_client_host_ui_; |
| 105 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; | 119 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; |
| 106 RenderViewHostBinding* binding_; | 120 RenderViewHostBinding* binding_; |
| 107 scoped_ptr<RenderViewHostBinding> default_binding_; | 121 scoped_ptr<RenderViewHostBinding> default_binding_; |
| 108 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); | 122 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); |
| 109 }; | 123 }; |
| 110 | 124 |
| 111 } // namespace content | 125 } // namespace content |
| 112 | 126 |
| 113 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 127 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
| OLD | NEW |