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