| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/worker_devtools_agent_host.h" | 5 #include "content/browser/devtools/worker_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/json/json_reader.h" |
| 8 #include "content/browser/devtools/devtools_protocol_handler.h" | 9 #include "content/browser/devtools/devtools_protocol_handler.h" |
| 9 #include "content/browser/devtools/protocol/schema_handler.h" | 10 #include "content/browser/devtools/protocol/schema_handler.h" |
| 10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 BrowserContext* WorkerDevToolsAgentHost::GetBrowserContext() { | 16 BrowserContext* WorkerDevToolsAgentHost::GetBrowserContext() { |
| 16 RenderProcessHost* rph = RenderProcessHost::FromID(worker_id_.first); | 17 RenderProcessHost* rph = RenderProcessHost::FromID(worker_id_.first); |
| 17 return rph ? rph->GetBrowserContext() : nullptr; | 18 return rph ? rph->GetBrowserContext() : nullptr; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 38 } else if (state_ == WORKER_PAUSED_FOR_REATTACH) { | 39 } else if (state_ == WORKER_PAUSED_FOR_REATTACH) { |
| 39 state_ = WORKER_UNINSPECTED; | 40 state_ = WORKER_UNINSPECTED; |
| 40 } | 41 } |
| 41 } | 42 } |
| 42 | 43 |
| 43 bool WorkerDevToolsAgentHost::DispatchProtocolMessage( | 44 bool WorkerDevToolsAgentHost::DispatchProtocolMessage( |
| 44 const std::string& message) { | 45 const std::string& message) { |
| 45 if (state_ != WORKER_INSPECTED) | 46 if (state_ != WORKER_INSPECTED) |
| 46 return true; | 47 return true; |
| 47 | 48 |
| 49 std::unique_ptr<base::Value> value = base::JSONReader::Read(message); |
| 48 int call_id; | 50 int call_id; |
| 49 std::string method; | 51 std::string method; |
| 50 if (protocol_handler_->HandleOptionalMessage(session_id(), message, &call_id, | 52 if (protocol_handler_->HandleOptionalMessage( |
| 51 &method)) | 53 session_id(), std::move(value), &call_id, &method)) { |
| 52 return true; | 54 return true; |
| 55 } |
| 53 | 56 |
| 54 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { | 57 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { |
| 55 host->Send(new DevToolsAgentMsg_DispatchOnInspectorBackend( | 58 host->Send(new DevToolsAgentMsg_DispatchOnInspectorBackend( |
| 56 worker_id_.second, session_id(), call_id, method, message)); | 59 worker_id_.second, session_id(), call_id, method, message)); |
| 57 } | 60 } |
| 58 return true; | 61 return true; |
| 59 } | 62 } |
| 60 | 63 |
| 61 bool WorkerDevToolsAgentHost::OnMessageReceived( | 64 bool WorkerDevToolsAgentHost::OnMessageReceived( |
| 62 const IPC::Message& msg) { | 65 const IPC::Message& msg) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 156 |
| 154 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( | 157 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( |
| 155 const DevToolsMessageChunk& message) { | 158 const DevToolsMessageChunk& message) { |
| 156 if (!IsAttached()) | 159 if (!IsAttached()) |
| 157 return; | 160 return; |
| 158 | 161 |
| 159 chunk_processor_.ProcessChunkedMessageFromAgent(message); | 162 chunk_processor_.ProcessChunkedMessageFromAgent(message); |
| 160 } | 163 } |
| 161 | 164 |
| 162 } // namespace content | 165 } // namespace content |
| OLD | NEW |