| 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 COMPONENTS_DEVTOOLS_HTTP_HANDLER_DEVTOOLS_HTTP_HANDLER_H_ | 5 #ifndef COMPONENTS_DEVTOOLS_HTTP_HANDLER_DEVTOOLS_HTTP_HANDLER_H_ |
| 6 #define COMPONENTS_DEVTOOLS_HTTP_HANDLER_DEVTOOLS_HTTP_HANDLER_H_ | 6 #define COMPONENTS_DEVTOOLS_HTTP_HANDLER_DEVTOOLS_HTTP_HANDLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "components/devtools_discovery/devtools_target_descriptor.h" | 15 #include "content/public/browser/devtools_agent_host.h" |
| 16 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
| 17 | 17 |
| 18 class GURL; | 18 class GURL; |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class DictionaryValue; | 21 class DictionaryValue; |
| 22 class Thread; | 22 class Thread; |
| 23 class Value; | 23 class Value; |
| 24 } | 24 } |
| 25 | 25 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void OnWebSocketRequest(int connection_id, | 96 void OnWebSocketRequest(int connection_id, |
| 97 const net::HttpServerRequestInfo& info); | 97 const net::HttpServerRequestInfo& info); |
| 98 void OnWebSocketMessage(int connection_id, const std::string& data); | 98 void OnWebSocketMessage(int connection_id, const std::string& data); |
| 99 void OnClose(int connection_id); | 99 void OnClose(int connection_id); |
| 100 | 100 |
| 101 void ServerStarted(base::Thread* thread, | 101 void ServerStarted(base::Thread* thread, |
| 102 ServerWrapper* server_wrapper, | 102 ServerWrapper* server_wrapper, |
| 103 ServerSocketFactory* socket_factory, | 103 ServerSocketFactory* socket_factory, |
| 104 std::unique_ptr<net::IPEndPoint> ip_address); | 104 std::unique_ptr<net::IPEndPoint> ip_address); |
| 105 | 105 |
| 106 devtools_discovery::DevToolsTargetDescriptor* GetDescriptor( | 106 scoped_refptr<content::DevToolsAgentHost> GetAgentHost( |
| 107 const std::string& target_id); | 107 const std::string& target_id); |
| 108 | 108 |
| 109 void SendJson(int connection_id, | 109 void SendJson(int connection_id, |
| 110 net::HttpStatusCode status_code, | 110 net::HttpStatusCode status_code, |
| 111 base::Value* value, | 111 base::Value* value, |
| 112 const std::string& message); | 112 const std::string& message); |
| 113 void Send200(int connection_id, | 113 void Send200(int connection_id, |
| 114 const std::string& data, | 114 const std::string& data, |
| 115 const std::string& mime_type); | 115 const std::string& mime_type); |
| 116 void Send404(int connection_id); | 116 void Send404(int connection_id); |
| 117 void Send500(int connection_id, | 117 void Send500(int connection_id, |
| 118 const std::string& message); | 118 const std::string& message); |
| 119 void AcceptWebSocket(int connection_id, | 119 void AcceptWebSocket(int connection_id, |
| 120 const net::HttpServerRequestInfo& request); | 120 const net::HttpServerRequestInfo& request); |
| 121 | 121 |
| 122 // Returns the front end url without the host at the beginning. | 122 // Returns the front end url without the host at the beginning. |
| 123 std::string GetFrontendURLInternal(const std::string& target_id, | 123 std::string GetFrontendURLInternal(const std::string& target_id, |
| 124 const std::string& host); | 124 const std::string& host); |
| 125 | 125 |
| 126 base::DictionaryValue* SerializeDescriptor( | 126 base::DictionaryValue* SerializeDescriptor( |
| 127 const devtools_discovery::DevToolsTargetDescriptor& descriptor, | 127 scoped_refptr<content::DevToolsAgentHost> agent_host, |
| 128 const std::string& host); | 128 const std::string& host); |
| 129 | 129 |
| 130 // The thread used by the devtools handler to run server socket. | 130 // The thread used by the devtools handler to run server socket. |
| 131 base::Thread* thread_; | 131 base::Thread* thread_; |
| 132 std::string frontend_url_; | 132 std::string frontend_url_; |
| 133 std::string product_name_; | 133 std::string product_name_; |
| 134 std::string user_agent_; | 134 std::string user_agent_; |
| 135 ServerWrapper* server_wrapper_; | 135 ServerWrapper* server_wrapper_; |
| 136 std::unique_ptr<net::IPEndPoint> server_ip_address_; | 136 std::unique_ptr<net::IPEndPoint> server_ip_address_; |
| 137 typedef std::map<int, DevToolsAgentHostClientImpl*> ConnectionToClientMap; | 137 typedef std::map<int, DevToolsAgentHostClientImpl*> ConnectionToClientMap; |
| 138 ConnectionToClientMap connection_to_client_; | 138 ConnectionToClientMap connection_to_client_; |
| 139 const std::unique_ptr<DevToolsHttpHandlerDelegate> delegate_; | 139 const std::unique_ptr<DevToolsHttpHandlerDelegate> delegate_; |
| 140 ServerSocketFactory* socket_factory_; | 140 ServerSocketFactory* socket_factory_; |
| 141 using DescriptorMap = | 141 using DescriptorMap = |
| 142 std::map<std::string, devtools_discovery::DevToolsTargetDescriptor*>; | 142 std::map<std::string, scoped_refptr<content::DevToolsAgentHost>>; |
| 143 DescriptorMap descriptor_map_; | 143 DescriptorMap agent_host_map_; |
| 144 base::WeakPtrFactory<DevToolsHttpHandler> weak_factory_; | 144 base::WeakPtrFactory<DevToolsHttpHandler> weak_factory_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandler); | 146 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandler); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace devtools_http_handler | 149 } // namespace devtools_http_handler |
| 150 | 150 |
| 151 #endif // COMPONENTS_DEVTOOLS_HTTP_HANDLER_DEVTOOLS_HTTP_HANDLER_H_ | 151 #endif // COMPONENTS_DEVTOOLS_HTTP_HANDLER_DEVTOOLS_HTTP_HANDLER_H_ |
| OLD | NEW |