| 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 "content/browser/devtools/devtools_http_handler_impl.h" | 5 #include "content/browser/devtools/devtools_http_handler_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 BrowserThread::PostTaskAndReply( | 208 BrowserThread::PostTaskAndReply( |
| 209 BrowserThread::FILE, FROM_HERE, | 209 BrowserThread::FILE, FROM_HERE, |
| 210 base::Bind(&DevToolsHttpHandlerImpl::StopHandlerThread, this), | 210 base::Bind(&DevToolsHttpHandlerImpl::StopHandlerThread, this), |
| 211 base::Bind(&DevToolsHttpHandlerImpl::ResetHandlerThreadAndRelease, this)); | 211 base::Bind(&DevToolsHttpHandlerImpl::ResetHandlerThreadAndRelease, this)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 GURL DevToolsHttpHandlerImpl::GetFrontendURL() { | 214 GURL DevToolsHttpHandlerImpl::GetFrontendURL() { |
| 215 net::IPEndPoint ip_address; | 215 net::IPEndPoint ip_address; |
| 216 if (server_->GetLocalAddress(&ip_address)) | 216 if (server_->GetLocalAddress(&ip_address)) |
| 217 return GURL(); | 217 return GURL(); |
| 218 return GURL(std::string("http://") + ip_address.ToString() + | 218 return GURL(std::string("http://") + ip_address.ToString() + frontend_url_); |
| 219 overridden_frontend_url_); | |
| 220 } | 219 } |
| 221 | 220 |
| 222 static std::string PathWithoutParams(const std::string& path) { | 221 static std::string PathWithoutParams(const std::string& path) { |
| 223 size_t query_position = path.find("?"); | 222 size_t query_position = path.find("?"); |
| 224 if (query_position != std::string::npos) | 223 if (query_position != std::string::npos) |
| 225 return path.substr(0, query_position); | 224 return path.substr(0, query_position); |
| 226 return path; | 225 return path; |
| 227 } | 226 } |
| 228 | 227 |
| 229 static std::string GetMimeType(const std::string& filename) { | 228 static std::string GetMimeType(const std::string& filename) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 &DevToolsHttpHandlerImpl::OnCloseUI, | 382 &DevToolsHttpHandlerImpl::OnCloseUI, |
| 384 this, | 383 this, |
| 385 connection_id)); | 384 connection_id)); |
| 386 } | 385 } |
| 387 | 386 |
| 388 std::string DevToolsHttpHandlerImpl::GetFrontendURLInternal( | 387 std::string DevToolsHttpHandlerImpl::GetFrontendURLInternal( |
| 389 const std::string id, | 388 const std::string id, |
| 390 const std::string& host) { | 389 const std::string& host) { |
| 391 return base::StringPrintf( | 390 return base::StringPrintf( |
| 392 "%s%sws=%s%s%s", | 391 "%s%sws=%s%s%s", |
| 393 overridden_frontend_url_.c_str(), | 392 frontend_url_.c_str(), |
| 394 overridden_frontend_url_.find("?") == std::string::npos ? "?" : "&", | 393 frontend_url_.find("?") == std::string::npos ? "?" : "&", |
| 395 host.c_str(), | 394 host.c_str(), |
| 396 kPageUrlPrefix, | 395 kPageUrlPrefix, |
| 397 id.c_str()); | 396 id.c_str()); |
| 398 } | 397 } |
| 399 | 398 |
| 400 static bool ParseJsonPath( | 399 static bool ParseJsonPath( |
| 401 const std::string& path, | 400 const std::string& path, |
| 402 std::string* command, | 401 std::string* command, |
| 403 std::string* target_id) { | 402 std::string* target_id) { |
| 404 | 403 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 DevToolsManager::GetInstance()->ClientHostClosing(client_host); | 633 DevToolsManager::GetInstance()->ClientHostClosing(client_host); |
| 635 delete client_host; | 634 delete client_host; |
| 636 connection_to_client_host_ui_.erase(connection_id); | 635 connection_to_client_host_ui_.erase(connection_id); |
| 637 } | 636 } |
| 638 } | 637 } |
| 639 | 638 |
| 640 DevToolsHttpHandlerImpl::DevToolsHttpHandlerImpl( | 639 DevToolsHttpHandlerImpl::DevToolsHttpHandlerImpl( |
| 641 const net::StreamListenSocketFactory* socket_factory, | 640 const net::StreamListenSocketFactory* socket_factory, |
| 642 const std::string& frontend_url, | 641 const std::string& frontend_url, |
| 643 DevToolsHttpHandlerDelegate* delegate) | 642 DevToolsHttpHandlerDelegate* delegate) |
| 644 : overridden_frontend_url_(frontend_url), | 643 : frontend_url_(frontend_url), |
| 645 socket_factory_(socket_factory), | 644 socket_factory_(socket_factory), |
| 646 delegate_(delegate) { | 645 delegate_(delegate) { |
| 647 if (overridden_frontend_url_.empty()) | 646 if (frontend_url_.empty()) |
| 648 overridden_frontend_url_ = "/devtools/devtools.html"; | 647 frontend_url_ = "/devtools/devtools.html"; |
| 649 | 648 |
| 650 // Balanced in ResetHandlerThreadAndRelease(). | 649 // Balanced in ResetHandlerThreadAndRelease(). |
| 651 AddRef(); | 650 AddRef(); |
| 652 } | 651 } |
| 653 | 652 |
| 654 // Runs on the handler thread | 653 // Runs on the handler thread |
| 655 void DevToolsHttpHandlerImpl::Init() { | 654 void DevToolsHttpHandlerImpl::Init() { |
| 656 server_ = new net::HttpServer(*socket_factory_.get(), this); | 655 server_ = new net::HttpServer(*socket_factory_.get(), this); |
| 657 } | 656 } |
| 658 | 657 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 id.c_str(), | 778 id.c_str(), |
| 780 host); | 779 host); |
| 781 dictionary->SetString( | 780 dictionary->SetString( |
| 782 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 781 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
| 783 } | 782 } |
| 784 | 783 |
| 785 return dictionary; | 784 return dictionary; |
| 786 } | 785 } |
| 787 | 786 |
| 788 } // namespace content | 787 } // namespace content |
| OLD | NEW |