Chromium Code Reviews| 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_agent_host_impl.h" | 5 #include "content/browser/devtools/devtools_agent_host_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "content/browser/devtools/devtools_manager.h" | 15 #include "content/browser/devtools/devtools_manager.h" |
| 16 #include "content/browser/devtools/devtools_session.h" | 16 #include "content/browser/devtools/devtools_session.h" |
| 17 #include "content/browser/devtools/forwarding_agent_host.h" | 17 #include "content/browser/devtools/forwarding_agent_host.h" |
| 18 #include "content/browser/devtools/protocol/page.h" | 18 #include "content/browser/devtools/protocol/page.h" |
| 19 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 19 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 20 #include "content/browser/devtools/service_worker_devtools_agent_host.h" | 20 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
| 21 #include "content/browser/devtools/service_worker_devtools_manager.h" | 21 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 22 #include "content/browser/devtools/shared_worker_devtools_agent_host.h" | 22 #include "content/browser/devtools/shared_worker_devtools_agent_host.h" |
| 23 #include "content/browser/devtools/shared_worker_devtools_manager.h" | 23 #include "content/browser/devtools/shared_worker_devtools_manager.h" |
| 24 #include "content/browser/frame_host/frame_tree_node.h" | |
| 24 #include "content/browser/loader/netlog_observer.h" | 25 #include "content/browser/loader/netlog_observer.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/content_browser_client.h" | 27 #include "content/public/browser/content_browser_client.h" |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; | 32 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; |
| 32 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; | 33 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; |
| 33 | 34 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 51 return "1.2"; | 52 return "1.2"; |
| 52 } | 53 } |
| 53 | 54 |
| 54 // static | 55 // static |
| 55 bool DevToolsAgentHost::IsSupportedProtocolVersion(const std::string& version) { | 56 bool DevToolsAgentHost::IsSupportedProtocolVersion(const std::string& version) { |
| 56 // TODO(dgozman): generate this. | 57 // TODO(dgozman): generate this. |
| 57 return version == "1.0" || version == "1.1" || version == "1.2"; | 58 return version == "1.0" || version == "1.1" || version == "1.2"; |
| 58 } | 59 } |
| 59 | 60 |
| 60 // static | 61 // static |
| 62 std::string DevToolsAgentHost::GetDevToolsFrameIdForFrameTreeNodeId( | |
| 63 int frame_tree_node_id) { | |
|
Charlie Reis
2017/04/24 20:26:42
We've been talking about how to make APIs like thi
alex clarke (OOO till 29th)
2017/04/25 15:01:03
Done.
Charlie Reis
2017/04/26 19:52:55
Thanks!
| |
| 64 FrameTreeNode* frame_tree_node = | |
| 65 FrameTreeNode::GloballyFindByID(frame_tree_node_id); | |
| 66 if (!frame_tree_node) | |
| 67 return ""; | |
| 68 return frame_tree_node->current_frame_host()->devtools_frame_id(); | |
| 69 } | |
| 70 | |
| 71 // static | |
| 61 DevToolsAgentHost::List DevToolsAgentHost::GetOrCreateAll() { | 72 DevToolsAgentHost::List DevToolsAgentHost::GetOrCreateAll() { |
| 62 List result; | 73 List result; |
| 63 SharedWorkerDevToolsAgentHost::List shared_list; | 74 SharedWorkerDevToolsAgentHost::List shared_list; |
| 64 SharedWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&shared_list); | 75 SharedWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&shared_list); |
| 65 for (const auto& host : shared_list) | 76 for (const auto& host : shared_list) |
| 66 result.push_back(host); | 77 result.push_back(host); |
| 67 | 78 |
| 68 ServiceWorkerDevToolsAgentHost::List service_list; | 79 ServiceWorkerDevToolsAgentHost::List service_list; |
| 69 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&service_list); | 80 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&service_list); |
| 70 for (const auto& host : service_list) | 81 for (const auto& host : service_list) |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 if (message_buffer_.size() != message_buffer_size_) | 400 if (message_buffer_.size() != message_buffer_size_) |
| 390 return false; | 401 return false; |
| 391 callback_.Run(chunk.session_id, message_buffer_); | 402 callback_.Run(chunk.session_id, message_buffer_); |
| 392 message_buffer_ = std::string(); | 403 message_buffer_ = std::string(); |
| 393 message_buffer_size_ = 0; | 404 message_buffer_size_ = 0; |
| 394 } | 405 } |
| 395 return true; | 406 return true; |
| 396 } | 407 } |
| 397 | 408 |
| 398 } // namespace content | 409 } // namespace content |
| OLD | NEW |