Chromium Code Reviews| 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 <vector> | |
| 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; | |
|
sadrul
2016/10/17 16:05:08
Why does UiDevToolsClient need to be friend? Can y
Sarmad Hashmi
2016/10/17 16:58:21
Done. Wasn't sure whether it was necessary to make
| |
| 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 using ClientsList = std::vector<std::unique_ptr<UiDevToolsClient>>; | |
| 44 using ConnectionsMap = std::map<uint32_t, UiDevToolsClient*>; | |
| 45 ClientsList clients_; | |
| 46 ConnectionsMap connections_; | |
| 47 std::unique_ptr<base::Thread> thread_; | |
|
sadrul
2016/10/17 16:05:08
If the user already has an IO thread, then it's pr
Sarmad Hashmi
2016/10/17 16:58:21
Done.
| |
| 48 std::unique_ptr<net::HttpServer> server_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer); | |
| 51 }; | |
| 52 | |
| 53 } // namespace devtools | |
| 54 } // namespace ui | |
| 55 | |
| 56 #endif // UI_DEVTOOLS_SERVER_H_ | |
| OLD | NEW |