 Chromium Code Reviews
 Chromium Code Reviews Issue 2300703005:
  DevTools: merge devtools_http_handler into content - it is used in all the embedders anyways.  (Closed)
    
  
    Issue 2300703005:
  DevTools: merge devtools_http_handler into content - it is used in all the embedders anyways.  (Closed) 
  | 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 manager->SetHttpHandler(base::WrapUnique(new DevToolsHttpHandler( | |
| 
dgozman
2016/09/02 19:33:07
if (!delegate) return;
 | |
| 29 manager->delegate(), std::move(server_socket_factory), frontend_url, | |
| 30 active_port_output_directory, debug_frontend_dir, product_name, | |
| 31 user_agent))); | |
| 32 } | |
| 33 | |
| 34 // static | |
| 35 void DevToolsAgentHost::StopRemoteDebuggingServer() { | |
| 36 DevToolsManager* manager = DevToolsManager::GetInstance(); | |
| 37 manager->SetHttpHandler(nullptr); | |
| 38 } | |
| 39 | |
| 40 // static | |
| 17 DevToolsManager* DevToolsManager::GetInstance() { | 41 DevToolsManager* DevToolsManager::GetInstance() { | 
| 18 return base::Singleton<DevToolsManager>::get(); | 42 return base::Singleton<DevToolsManager>::get(); | 
| 19 } | 43 } | 
| 20 | 44 | 
| 21 DevToolsManager::DevToolsManager() | 45 DevToolsManager::DevToolsManager() | 
| 22 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), | 46 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), | 
| 23 attached_hosts_count_(0) { | 47 attached_hosts_count_(0) { | 
| 24 } | 48 } | 
| 25 | 49 | 
| 26 DevToolsManager::~DevToolsManager() { | 50 DevToolsManager::~DevToolsManager() { | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 42 --attached_hosts_count_; | 66 --attached_hosts_count_; | 
| 43 if (!attached_hosts_count_) { | 67 if (!attached_hosts_count_) { | 
| 44 BrowserThread::PostTask( | 68 BrowserThread::PostTask( | 
| 45 BrowserThread::IO, | 69 BrowserThread::IO, | 
| 46 FROM_HERE, | 70 FROM_HERE, | 
| 47 base::Bind(&NetLogObserver::Detach)); | 71 base::Bind(&NetLogObserver::Detach)); | 
| 48 } | 72 } | 
| 49 } | 73 } | 
| 50 } | 74 } | 
| 51 | 75 | 
| 76 void DevToolsManager::SetHttpHandler( | |
| 77 std::unique_ptr<DevToolsHttpHandler> http_handler) { | |
| 78 http_handler_ = std::move(http_handler); | |
| 79 } | |
| 80 | |
| 52 } // namespace content | 81 } // namespace content | 
| OLD | NEW |