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

Side by Side Diff: components/ui_devtools/devtools_server.h

Issue 2928603002: Create and remove |UiDevToolsServer::server_| in the same thread. (Closed)
Patch Set: . Created 3 years, 5 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_UI_DEVTOOLS_DEVTOOLS_SERVER_H_ 5 #ifndef COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_
6 #define COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_ 6 #define COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 25 matching lines...) Expand all
36 36
37 void AttachClient(std::unique_ptr<UiDevToolsClient> client); 37 void AttachClient(std::unique_ptr<UiDevToolsClient> client);
38 void SendOverWebSocket(int connection_id, const String& message); 38 void SendOverWebSocket(int connection_id, const String& message);
39 39
40 private: 40 private:
41 explicit UiDevToolsServer( 41 explicit UiDevToolsServer(
42 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); 42 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner);
43 43
44 void Start(const std::string& address_string, uint16_t port); 44 void Start(const std::string& address_string, uint16_t port);
45 void StartServer(const std::string& address_string, uint16_t port); 45 void StartServer(const std::string& address_string, uint16_t port);
46 void StopServer();
46 47
47 // HttpServer::Delegate 48 // HttpServer::Delegate
48 void OnConnect(int connection_id) override; 49 void OnConnect(int connection_id) override;
49 void OnHttpRequest(int connection_id, 50 void OnHttpRequest(int connection_id,
50 const net::HttpServerRequestInfo& info) override; 51 const net::HttpServerRequestInfo& info) override;
51 void OnWebSocketRequest(int connection_id, 52 void OnWebSocketRequest(int connection_id,
52 const net::HttpServerRequestInfo& info) override; 53 const net::HttpServerRequestInfo& info) override;
53 void OnWebSocketMessage(int connection_id, const std::string& data) override; 54 void OnWebSocketMessage(int connection_id, const std::string& data) override;
54 void OnClose(int connection_id) override; 55 void OnClose(int connection_id) override;
55 56
56 using ClientsList = std::vector<std::unique_ptr<UiDevToolsClient>>; 57 using ClientsList = std::vector<std::unique_ptr<UiDevToolsClient>>;
57 using ConnectionsMap = std::map<uint32_t, UiDevToolsClient*>; 58 using ConnectionsMap = std::map<uint32_t, UiDevToolsClient*>;
58 ClientsList clients_; 59 ClientsList clients_;
59 ConnectionsMap connections_; 60 ConnectionsMap connections_;
60 61
61 std::unique_ptr<base::Thread> thread_; 62 std::unique_ptr<base::Thread> thread_;
62 std::unique_ptr<net::HttpServer> server_; 63 std::unique_ptr<net::HttpServer> server_;
63 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; 64 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
64 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 65 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
65 66
66 // The server (owned by ash for now) 67 // The server (owned by ash for now)
67 static UiDevToolsServer* devtools_server_; 68 static UiDevToolsServer* devtools_server_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer); 70 DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer);
70 }; 71 };
71 72
72 } // namespace ui_devtools 73 } // namespace ui_devtools
73 74
74 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_ 75 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_
OLDNEW
« no previous file with comments | « no previous file | components/ui_devtools/devtools_server.cc » ('j') | components/ui_devtools/devtools_server.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698