OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_DEVTOOLS_SERVER_H_ |
| 6 #define UI_DEVTOOLS_SERVER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/threading/thread.h" |
| 11 #include "net/server/http_server.h" |
| 12 #include "ui/devtools/DOM.h" |
| 13 #include "ui/devtools/Forward.h" |
| 14 #include "ui/devtools/Protocol.h" |
| 15 #include "ui/devtools/StringUtil.h" |
| 16 #include "ui/devtools/devtools_client.h" |
| 17 |
| 18 namespace ui { |
| 19 namespace devtools { |
| 20 |
| 21 class UiDevToolsServer : public net::HttpServer::Delegate { |
| 22 public: |
| 23 UiDevToolsServer(); |
| 24 ~UiDevToolsServer() override; |
| 25 |
| 26 void Start(const std::string& address_string, uint16_t port); |
| 27 void AttachClient(std::unique_ptr<UiDevToolsClient> client); |
| 28 |
| 29 private: |
| 30 friend class UiDevToolsClient; |
| 31 void StartServer(const std::string& address_string, uint16_t port); |
| 32 void SendOverWebSocket(int connection_id, const String& message); |
| 33 |
| 34 // HttpServer::Delegate |
| 35 void OnConnect(int connection_id) override; |
| 36 void OnHttpRequest(int connection_id, |
| 37 const net::HttpServerRequestInfo& info) override; |
| 38 void OnWebSocketRequest(int connection_id, |
| 39 const net::HttpServerRequestInfo& info) override; |
| 40 void OnWebSocketMessage(int connection_id, const std::string& data) override; |
| 41 void OnClose(int connection_id) override; |
| 42 |
| 43 static UiDevToolsServer* instance_; |
| 44 |
| 45 using ClientsMap = std::map<int, std::unique_ptr<UiDevToolsClient>>; |
| 46 using ConnectionsMap = std::map<int, int>; |
| 47 ClientsMap clients_; |
| 48 ConnectionsMap connections_; |
| 49 std::unique_ptr<base::Thread> thread_; |
| 50 std::unique_ptr<net::HttpServer> server_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer); |
| 53 }; |
| 54 |
| 55 } // namespace devtools |
| 56 } // namespace ui |
| 57 |
| 58 #endif // UI_DEVTOOLS_SERVER_H_ |
OLD | NEW |