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_DEVTOOLS_SERVER_H_ | |
sadrul
2016/10/20 16:56:29
Update the include guards in all the header files.
Sarmad Hashmi
2016/10/20 21:49:22
Done.
| |
6 #define UI_DEVTOOLS_DEVTOOLS_SERVER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/threading/thread.h" | |
11 #include "components/ui_devtools/DOM.h" | |
12 #include "components/ui_devtools/Forward.h" | |
13 #include "components/ui_devtools/Protocol.h" | |
14 #include "components/ui_devtools/devtools_client.h" | |
15 #include "components/ui_devtools/string_util.h" | |
16 #include "net/server/http_server.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 // Returns an empty unique_ptr if ui devtools flag isn't enabled. | |
27 static std::unique_ptr<UiDevToolsServer> Create(); | |
28 | |
29 void AttachClient(std::unique_ptr<UiDevToolsClient> client); | |
30 void SendOverWebSocket(int connection_id, const String& message); | |
31 | |
32 private: | |
33 void Start(const std::string& address_string, uint16_t port); | |
34 void StartServer(const std::string& address_string, uint16_t port); | |
35 | |
36 // HttpServer::Delegate | |
37 void OnConnect(int connection_id) override; | |
38 void OnHttpRequest(int connection_id, | |
39 const net::HttpServerRequestInfo& info) override; | |
40 void OnWebSocketRequest(int connection_id, | |
41 const net::HttpServerRequestInfo& info) override; | |
42 void OnWebSocketMessage(int connection_id, const std::string& data) override; | |
43 void OnClose(int connection_id) override; | |
44 | |
45 using ClientsList = std::vector<std::unique_ptr<UiDevToolsClient>>; | |
46 using ConnectionsMap = std::map<uint32_t, UiDevToolsClient*>; | |
47 ClientsList clients_; | |
48 ConnectionsMap connections_; | |
49 | |
50 // TODO(mhashmi): Inject IO thread task runner instead of creating/owning | |
51 // thread | |
52 std::unique_ptr<base::Thread> thread_; | |
53 std::unique_ptr<net::HttpServer> server_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer); | |
56 }; | |
57 | |
58 } // namespace devtools | |
59 } // namespace ui | |
60 | |
61 #endif // UI_DEVTOOLS_DEVTOOLS_SERVER_H_ | |
OLD | NEW |