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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
9 #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" |
10 #include "content/browser/loader/netlog_observer.h" | 12 #include "content/browser/loader/netlog_observer.h" |
11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
12 #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" |
13 | 16 |
14 namespace content { | 17 namespace content { |
15 | 18 |
16 // static | 19 // static |
| 20 void DevToolsAgentHost::StartRemoteDebuggingServer( |
| 21 std::unique_ptr<DevToolsSocketFactory> server_socket_factory, |
| 22 const std::string& frontend_url, |
| 23 const base::FilePath& active_port_output_directory, |
| 24 const base::FilePath& debug_frontend_dir, |
| 25 const std::string& product_name, |
| 26 const std::string& user_agent) { |
| 27 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 28 if (!manager->delegate()) |
| 29 return; |
| 30 manager->SetHttpHandler(base::WrapUnique(new DevToolsHttpHandler( |
| 31 manager->delegate(), std::move(server_socket_factory), frontend_url, |
| 32 active_port_output_directory, debug_frontend_dir, product_name, |
| 33 user_agent))); |
| 34 } |
| 35 |
| 36 // static |
| 37 void DevToolsAgentHost::StopRemoteDebuggingServer() { |
| 38 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 39 manager->SetHttpHandler(nullptr); |
| 40 } |
| 41 |
| 42 // static |
17 DevToolsManager* DevToolsManager::GetInstance() { | 43 DevToolsManager* DevToolsManager::GetInstance() { |
18 return base::Singleton<DevToolsManager>::get(); | 44 return base::Singleton<DevToolsManager>::get(); |
19 } | 45 } |
20 | 46 |
21 DevToolsManager::DevToolsManager() | 47 DevToolsManager::DevToolsManager() |
22 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), | 48 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), |
23 attached_hosts_count_(0) { | 49 attached_hosts_count_(0) { |
24 } | 50 } |
25 | 51 |
26 DevToolsManager::~DevToolsManager() { | 52 DevToolsManager::~DevToolsManager() { |
(...skipping 15 matching lines...) Expand all Loading... |
42 --attached_hosts_count_; | 68 --attached_hosts_count_; |
43 if (!attached_hosts_count_) { | 69 if (!attached_hosts_count_) { |
44 BrowserThread::PostTask( | 70 BrowserThread::PostTask( |
45 BrowserThread::IO, | 71 BrowserThread::IO, |
46 FROM_HERE, | 72 FROM_HERE, |
47 base::Bind(&NetLogObserver::Detach)); | 73 base::Bind(&NetLogObserver::Detach)); |
48 } | 74 } |
49 } | 75 } |
50 } | 76 } |
51 | 77 |
| 78 void DevToolsManager::SetHttpHandler( |
| 79 std::unique_ptr<DevToolsHttpHandler> http_handler) { |
| 80 http_handler_ = std::move(http_handler); |
| 81 } |
| 82 |
52 } // namespace content | 83 } // namespace content |
OLD | NEW |