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