| OLD | NEW |
| 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" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "components/ui_devtools/DOM.h" | 12 #include "components/ui_devtools/DOM.h" |
| 13 #include "components/ui_devtools/Forward.h" | 13 #include "components/ui_devtools/Forward.h" |
| 14 #include "components/ui_devtools/Protocol.h" | 14 #include "components/ui_devtools/Protocol.h" |
| 15 #include "components/ui_devtools/devtools_client.h" | 15 #include "components/ui_devtools/devtools_client.h" |
| 16 #include "components/ui_devtools/devtools_export.h" | |
| 17 #include "components/ui_devtools/string_util.h" | 16 #include "components/ui_devtools/string_util.h" |
| 18 #include "net/server/http_server.h" | 17 #include "net/server/http_server.h" |
| 19 | 18 |
| 20 namespace ui { | 19 namespace ui { |
| 21 namespace devtools { | 20 namespace devtools { |
| 22 | 21 |
| 23 class UiDevToolsServer : public net::HttpServer::Delegate { | 22 class UiDevToolsServer : public net::HttpServer::Delegate { |
| 24 public: | 23 public: |
| 25 ~UiDevToolsServer() override; | 24 ~UiDevToolsServer() override; |
| 26 | 25 |
| 27 // Returns an empty unique_ptr if ui devtools flag isn't enabled or if a | 26 // Returns an empty unique_ptr if ui devtools flag isn't enabled or if a |
| 28 // server instance has already been created. | 27 // server instance has already been created. |
| 29 static UI_DEVTOOLS_EXPORT std::unique_ptr<UiDevToolsServer> Create( | 28 static std::unique_ptr<UiDevToolsServer> Create( |
| 30 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); | 29 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); |
| 31 | 30 |
| 32 // Returns a list of attached UiDevToolsClient name + URL | 31 // Returns a list of attached UiDevToolsClient name + URL |
| 33 using NameUrlPair = std::pair<std::string, std::string>; | 32 using NameUrlPair = std::pair<std::string, std::string>; |
| 34 static UI_DEVTOOLS_EXPORT std::vector<NameUrlPair> GetClientNamesAndUrls(); | 33 static std::vector<NameUrlPair> GetClientNamesAndUrls(); |
| 35 | 34 |
| 36 void AttachClient(std::unique_ptr<UiDevToolsClient> client); | 35 void AttachClient(std::unique_ptr<UiDevToolsClient> client); |
| 37 void SendOverWebSocket(int connection_id, const String& message); | 36 void SendOverWebSocket(int connection_id, const String& message); |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 explicit UiDevToolsServer( | 39 explicit UiDevToolsServer( |
| 41 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); | 40 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); |
| 42 | 41 |
| 43 void Start(const std::string& address_string, uint16_t port); | 42 void Start(const std::string& address_string, uint16_t port); |
| 44 void StartServer(const std::string& address_string, uint16_t port); | 43 void StartServer(const std::string& address_string, uint16_t port); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 65 // The server (owned by ash for now) | 64 // The server (owned by ash for now) |
| 66 static UiDevToolsServer* devtools_server_; | 65 static UiDevToolsServer* devtools_server_; |
| 67 | 66 |
| 68 DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer); | 67 DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer); |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 } // namespace devtools | 70 } // namespace devtools |
| 72 } // namespace ui | 71 } // namespace ui |
| 73 | 72 |
| 74 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_ | 73 #endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_ |
| OLD | NEW |