Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: ui/devtools/devtools_server.h

Issue 2374513002: Add ui devtools server (Closed)
Patch Set: Address @sadrul's comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
sadrul 2016/10/17 17:44:36 UI_DEVTOOLS_DEVTOOLS_SERVER_H_
Sarmad Hashmi 2016/10/17 19:15:29 Done.
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/devtools_client.h"
16 #include "ui/devtools/string_util.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 void SendOverWebSocket(int connection_id, const String& message);
29
30 private:
31 void StartServer(const std::string& address_string, uint16_t port);
32
33 // HttpServer::Delegate
34 void OnConnect(int connection_id) override;
35 void OnHttpRequest(int connection_id,
36 const net::HttpServerRequestInfo& info) override;
37 void OnWebSocketRequest(int connection_id,
38 const net::HttpServerRequestInfo& info) override;
39 void OnWebSocketMessage(int connection_id, const std::string& data) override;
40 void OnClose(int connection_id) override;
41
42 using ClientsList = std::vector<std::unique_ptr<UiDevToolsClient>>;
43 using ConnectionsMap = std::map<uint32_t, UiDevToolsClient*>;
44 ClientsList clients_;
45 ConnectionsMap connections_;
46
47 // TODO(mhashmi): Inject IO thread task runner instead of creating/owning
48 // thread
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698