| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const net::HttpServerRequestInfo& info); | 94 const net::HttpServerRequestInfo& info); |
| 95 void OnWebSocketMessage(int connection_id, const std::string& data); | 95 void OnWebSocketMessage(int connection_id, const std::string& data); |
| 96 void OnClose(int connection_id); | 96 void OnClose(int connection_id); |
| 97 | 97 |
| 98 void ServerStarted(base::Thread* thread, | 98 void ServerStarted(base::Thread* thread, |
| 99 ServerWrapper* server_wrapper, | 99 ServerWrapper* server_wrapper, |
| 100 scoped_ptr<net::IPEndPoint> ip_address); | 100 scoped_ptr<net::IPEndPoint> ip_address); |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 // DevToolsHttpHandler implementation. | 103 // DevToolsHttpHandler implementation. |
| 104 void Stop() override; | |
| 105 GURL GetFrontendURL() override; | 104 GURL GetFrontendURL() override; |
| 106 | 105 |
| 107 | 106 |
| 108 static void OnTargetListReceivedWeak( | 107 static void OnTargetListReceivedWeak( |
| 109 base::WeakPtr<DevToolsHttpHandlerImpl> handler, | 108 base::WeakPtr<DevToolsHttpHandlerImpl> handler, |
| 110 int connection_id, | 109 int connection_id, |
| 111 const std::string& host, | 110 const std::string& host, |
| 112 const DevToolsManagerDelegate::TargetList& targets); | 111 const DevToolsManagerDelegate::TargetList& targets); |
| 113 void OnTargetListReceived( | 112 void OnTargetListReceived( |
| 114 int connection_id, | 113 int connection_id, |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 if (socket && | 534 if (socket && |
| 536 socket->ListenWithAddressAndPort(address_, port_, backlog_) == net::OK) { | 535 socket->ListenWithAddressAndPort(address_, port_, backlog_) == net::OK) { |
| 537 return socket.Pass(); | 536 return socket.Pass(); |
| 538 } | 537 } |
| 539 return scoped_ptr<net::ServerSocket>(); | 538 return scoped_ptr<net::ServerSocket>(); |
| 540 } | 539 } |
| 541 | 540 |
| 542 // DevToolsHttpHandlerImpl --------------------------------------------------- | 541 // DevToolsHttpHandlerImpl --------------------------------------------------- |
| 543 | 542 |
| 544 DevToolsHttpHandlerImpl::~DevToolsHttpHandlerImpl() { | 543 DevToolsHttpHandlerImpl::~DevToolsHttpHandlerImpl() { |
| 544 TerminateOnUI(thread_, server_wrapper_); |
| 545 STLDeleteValues(&target_map_); | 545 STLDeleteValues(&target_map_); |
| 546 STLDeleteValues(&browser_targets_); | 546 STLDeleteValues(&browser_targets_); |
| 547 STLDeleteValues(&connection_to_client_); | 547 STLDeleteValues(&connection_to_client_); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void DevToolsHttpHandlerImpl::Stop() { | |
| 551 TerminateOnUI(thread_, server_wrapper_); | |
| 552 delete this; | |
| 553 } | |
| 554 | |
| 555 GURL DevToolsHttpHandlerImpl::GetFrontendURL() { | 550 GURL DevToolsHttpHandlerImpl::GetFrontendURL() { |
| 556 if (!server_ip_address_) | 551 if (!server_ip_address_) |
| 557 return GURL(); | 552 return GURL(); |
| 558 return GURL(std::string("http://") + server_ip_address_->ToString() + frontend
_url_); | 553 return GURL(std::string("http://") + server_ip_address_->ToString() + frontend
_url_); |
| 559 } | 554 } |
| 560 | 555 |
| 561 static std::string PathWithoutParams(const std::string& path) { | 556 static std::string PathWithoutParams(const std::string& path) { |
| 562 size_t query_position = path.find("?"); | 557 size_t query_position = path.find("?"); |
| 563 if (query_position != std::string::npos) | 558 if (query_position != std::string::npos) |
| 564 return path.substr(0, query_position); | 559 return path.substr(0, query_position); |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 id.c_str(), | 1150 id.c_str(), |
| 1156 host); | 1151 host); |
| 1157 dictionary->SetString( | 1152 dictionary->SetString( |
| 1158 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 1153 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
| 1159 } | 1154 } |
| 1160 | 1155 |
| 1161 return dictionary; | 1156 return dictionary; |
| 1162 } | 1157 } |
| 1163 | 1158 |
| 1164 } // namespace content | 1159 } // namespace content |
| OLD | NEW |