| 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_manager.h" | 5 #include "content/browser/devtools/devtools_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/browser/devtools/devtools_agent_host_impl.h" | 10 #include "content/browser/devtools/devtools_agent_host_impl.h" |
| 11 #include "content/browser/devtools/devtools_http_handler.h" | 11 #include "content/browser/devtools/devtools_http_handler.h" |
| 12 #include "content/browser/loader/netlog_observer.h" | 12 #include "content/browser/loader/netlog_observer.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
| 15 #include "content/public/browser/devtools_socket_factory.h" | 15 #include "content/public/browser/devtools_socket_factory.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 void DevToolsAgentHost::StartRemoteDebuggingServer( | 20 void DevToolsAgentHost::StartRemoteDebuggingServer( |
| 21 std::unique_ptr<DevToolsSocketFactory> server_socket_factory, | 21 std::unique_ptr<DevToolsSocketFactory> server_socket_factory, |
| 22 const std::string& frontend_url, | 22 const std::string& frontend_url, |
| 23 const base::FilePath& active_port_output_directory, | 23 const base::FilePath& active_port_output_directory, |
| 24 const base::FilePath& debug_frontend_dir, | 24 const base::FilePath& debug_frontend_dir, |
| 25 const std::string& product_name, | 25 const std::string& product_name, |
| 26 const std::string& user_agent) { | 26 const std::string& user_agent, |
| 27 const std::string& v8_version) { |
| 27 DevToolsManager* manager = DevToolsManager::GetInstance(); | 28 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 28 if (!manager->delegate()) | 29 if (!manager->delegate()) |
| 29 return; | 30 return; |
| 30 manager->SetHttpHandler(base::WrapUnique(new DevToolsHttpHandler( | 31 manager->SetHttpHandler(base::WrapUnique(new DevToolsHttpHandler( |
| 31 manager->delegate(), std::move(server_socket_factory), frontend_url, | 32 manager->delegate(), std::move(server_socket_factory), frontend_url, |
| 32 active_port_output_directory, debug_frontend_dir, product_name, | 33 active_port_output_directory, debug_frontend_dir, product_name, |
| 33 user_agent))); | 34 user_agent, v8_version))); |
| 34 } | 35 } |
| 35 | 36 |
| 36 // static | 37 // static |
| 37 void DevToolsAgentHost::StopRemoteDebuggingServer() { | 38 void DevToolsAgentHost::StopRemoteDebuggingServer() { |
| 38 DevToolsManager* manager = DevToolsManager::GetInstance(); | 39 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 39 manager->SetHttpHandler(nullptr); | 40 manager->SetHttpHandler(nullptr); |
| 40 } | 41 } |
| 41 | 42 |
| 42 // static | 43 // static |
| 43 DevToolsManager* DevToolsManager::GetInstance() { | 44 DevToolsManager* DevToolsManager::GetInstance() { |
| 44 return base::Singleton<DevToolsManager>::get(); | 45 return base::Singleton<DevToolsManager>::get(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 DevToolsManager::DevToolsManager() | 48 DevToolsManager::DevToolsManager() |
| 48 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()) { | 49 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()) { |
| 49 } | 50 } |
| 50 | 51 |
| 51 DevToolsManager::~DevToolsManager() { | 52 DevToolsManager::~DevToolsManager() { |
| 52 } | 53 } |
| 53 | 54 |
| 54 void DevToolsManager::SetHttpHandler( | 55 void DevToolsManager::SetHttpHandler( |
| 55 std::unique_ptr<DevToolsHttpHandler> http_handler) { | 56 std::unique_ptr<DevToolsHttpHandler> http_handler) { |
| 56 http_handler_ = std::move(http_handler); | 57 http_handler_ = std::move(http_handler); |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace content | 60 } // namespace content |
| OLD | NEW |