| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "components/devtools_service/devtools_http_server.h" | 5 #include "components/devtools_service/devtools_http_server.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/devtools_service/devtools_agent_host.h" | 19 #include "components/devtools_service/devtools_agent_host.h" |
| 20 #include "components/devtools_service/devtools_registry_impl.h" | 20 #include "components/devtools_service/devtools_registry_impl.h" |
| 21 #include "components/devtools_service/devtools_service.h" | 21 #include "components/devtools_service/devtools_service.h" |
| 22 #include "mojo/public/cpp/system/data_pipe.h" | 22 #include "mojo/public/cpp/system/data_pipe.h" |
| 23 #include "mojo/services/network/public/cpp/web_socket_read_queue.h" | 23 #include "mojo/services/network/public/cpp/web_socket_read_queue.h" |
| 24 #include "mojo/services/network/public/cpp/web_socket_write_queue.h" | 24 #include "mojo/services/network/public/cpp/web_socket_write_queue.h" |
| 25 #include "mojo/services/network/public/interfaces/net_address.mojom.h" | 25 #include "mojo/services/network/public/interfaces/net_address.mojom.h" |
| 26 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 26 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 27 #include "mojo/services/network/public/interfaces/web_socket.mojom.h" | 27 #include "mojo/services/network/public/interfaces/web_socket.mojom.h" |
| 28 #include "mojo/shell/public/cpp/application_impl.h" | 28 #include "mojo/shell/public/cpp/shell.h" |
| 29 | 29 |
| 30 namespace devtools_service { | 30 namespace devtools_service { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 const char kPageUrlPrefix[] = "/devtools/page/"; | 34 const char kPageUrlPrefix[] = "/devtools/page/"; |
| 35 const char kBrowserUrlPrefix[] = "/devtools/browser"; | 35 const char kBrowserUrlPrefix[] = "/devtools/browser"; |
| 36 const char kJsonRequestUrlPrefix[] = "/json"; | 36 const char kJsonRequestUrlPrefix[] = "/json"; |
| 37 | 37 |
| 38 const char kActivateCommand[] = "activate"; | 38 const char kActivateCommand[] = "activate"; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 330 |
| 331 DISALLOW_COPY_AND_ASSIGN(HttpConnectionDelegateImpl); | 331 DISALLOW_COPY_AND_ASSIGN(HttpConnectionDelegateImpl); |
| 332 }; | 332 }; |
| 333 | 333 |
| 334 DevToolsHttpServer::DevToolsHttpServer(DevToolsService* service, | 334 DevToolsHttpServer::DevToolsHttpServer(DevToolsService* service, |
| 335 uint16_t remote_debugging_port) | 335 uint16_t remote_debugging_port) |
| 336 : service_(service), remote_debugging_port_(remote_debugging_port) { | 336 : service_(service), remote_debugging_port_(remote_debugging_port) { |
| 337 VLOG(1) << "Remote debugging HTTP server is started on port " | 337 VLOG(1) << "Remote debugging HTTP server is started on port " |
| 338 << remote_debugging_port << "."; | 338 << remote_debugging_port << "."; |
| 339 mojo::NetworkServicePtr network_service; | 339 mojo::NetworkServicePtr network_service; |
| 340 service_->application()->ConnectToService("mojo:network_service", | 340 service_->shell()->ConnectToService("mojo:network_service", &network_service); |
| 341 &network_service); | |
| 342 | 341 |
| 343 mojo::NetAddressPtr local_address(mojo::NetAddress::New()); | 342 mojo::NetAddressPtr local_address(mojo::NetAddress::New()); |
| 344 local_address->family = mojo::NetAddressFamily::IPV4; | 343 local_address->family = mojo::NetAddressFamily::IPV4; |
| 345 local_address->ipv4 = mojo::NetAddressIPv4::New(); | 344 local_address->ipv4 = mojo::NetAddressIPv4::New(); |
| 346 local_address->ipv4->port = remote_debugging_port; | 345 local_address->ipv4->port = remote_debugging_port; |
| 347 local_address->ipv4->addr.resize(4); | 346 local_address->ipv4->addr.resize(4); |
| 348 local_address->ipv4->addr[0] = 127; | 347 local_address->ipv4->addr[0] = 127; |
| 349 local_address->ipv4->addr[1] = 0; | 348 local_address->ipv4->addr[1] = 0; |
| 350 local_address->ipv4->addr[2] = 0; | 349 local_address->ipv4->addr[2] = 0; |
| 351 local_address->ipv4->addr[3] = 1; | 350 local_address->ipv4->addr[3] = 1; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 iter.value()->id().c_str())); | 493 iter.value()->id().c_str())); |
| 495 list_value.Append(std::move(dict_value)); | 494 list_value.Append(std::move(dict_value)); |
| 496 } | 495 } |
| 497 return MakeJsonResponse(200, &list_value, std::string()); | 496 return MakeJsonResponse(200, &list_value, std::string()); |
| 498 } | 497 } |
| 499 | 498 |
| 500 return MakeJsonResponse(404, nullptr, "Unknown command: " + command); | 499 return MakeJsonResponse(404, nullptr, "Unknown command: " + command); |
| 501 } | 500 } |
| 502 | 501 |
| 503 } // namespace devtools_service | 502 } // namespace devtools_service |
| OLD | NEW |