| 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 #include "components/ui_devtools/devtools_server.h" | 5 #include "components/ui_devtools/devtools_server.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/user_metrics.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "components/ui_devtools/switches.h" | 18 #include "components/ui_devtools/switches.h" |
| 18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 19 #include "net/log/net_log.h" | 20 #include "net/log/net_log.h" |
| 20 #include "net/server/http_server_request_info.h" | 21 #include "net/server/http_server_request_info.h" |
| 21 #include "net/socket/server_socket.h" | 22 #include "net/socket/server_socket.h" |
| 22 #include "net/socket/tcp_server_socket.h" | 23 #include "net/socket/tcp_server_socket.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 new net::TCPServerSocket(nullptr, net::NetLogSource())); | 127 new net::TCPServerSocket(nullptr, net::NetLogSource())); |
| 127 constexpr int kBacklog = 1; | 128 constexpr int kBacklog = 1; |
| 128 if (socket->ListenWithAddressAndPort(address_string, port, kBacklog) != | 129 if (socket->ListenWithAddressAndPort(address_string, port, kBacklog) != |
| 129 net::OK) | 130 net::OK) |
| 130 return; | 131 return; |
| 131 server_ = base::MakeUnique<net::HttpServer>(std::move(socket), this); | 132 server_ = base::MakeUnique<net::HttpServer>(std::move(socket), this); |
| 132 } | 133 } |
| 133 | 134 |
| 134 // HttpServer::Delegate Implementation | 135 // HttpServer::Delegate Implementation |
| 135 void UiDevToolsServer::OnConnect(int connection_id) { | 136 void UiDevToolsServer::OnConnect(int connection_id) { |
| 136 NOTIMPLEMENTED(); | 137 base::RecordAction(base::UserMetricsAction("UI_DevTools_Connect")); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void UiDevToolsServer::OnHttpRequest(int connection_id, | 140 void UiDevToolsServer::OnHttpRequest(int connection_id, |
| 140 const net::HttpServerRequestInfo& info) { | 141 const net::HttpServerRequestInfo& info) { |
| 141 NOTIMPLEMENTED(); | 142 NOTIMPLEMENTED(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 void UiDevToolsServer::OnWebSocketRequest( | 145 void UiDevToolsServer::OnWebSocketRequest( |
| 145 int connection_id, | 146 int connection_id, |
| 146 const net::HttpServerRequestInfo& info) { | 147 const net::HttpServerRequestInfo& info) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return; | 180 return; |
| 180 UiDevToolsClient* client = it->second; | 181 UiDevToolsClient* client = it->second; |
| 181 DCHECK(client); | 182 DCHECK(client); |
| 182 main_thread_task_runner_->PostTask( | 183 main_thread_task_runner_->PostTask( |
| 183 FROM_HERE, | 184 FROM_HERE, |
| 184 base::Bind(&UiDevToolsClient::Disconnect, base::Unretained(client))); | 185 base::Bind(&UiDevToolsClient::Disconnect, base::Unretained(client))); |
| 185 connections_.erase(it); | 186 connections_.erase(it); |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace ui_devtools | 189 } // namespace ui_devtools |
| OLD | NEW |