| 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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "content/browser/devtools/devtools_session.h" | 9 #include "content/browser/devtools/devtools_session.h" |
| 10 #include "content/browser/devtools/protocol/inspector_handler.h" | 10 #include "content/browser/devtools/protocol/inspector_handler.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return state_ == WORKER_INSPECTED || state_ == WORKER_UNINSPECTED || | 100 return state_ == WORKER_INSPECTED || state_ == WORKER_UNINSPECTED || |
| 101 state_ == WORKER_READY_FOR_DEBUG_ON_START; | 101 state_ == WORKER_READY_FOR_DEBUG_ON_START; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void WorkerDevToolsAgentHost::WorkerReadyForInspection() { | 104 void WorkerDevToolsAgentHost::WorkerReadyForInspection() { |
| 105 if (state_ == WORKER_PAUSED_FOR_REATTACH) { | 105 if (state_ == WORKER_PAUSED_FOR_REATTACH) { |
| 106 DCHECK(IsAttached()); | 106 DCHECK(IsAttached()); |
| 107 state_ = WORKER_INSPECTED; | 107 state_ = WORKER_INSPECTED; |
| 108 AttachToWorker(); | 108 AttachToWorker(); |
| 109 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { | 109 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { |
| 110 std::string state_cookie; | 110 for (auto& it : chunk_processors_) { |
| 111 auto it = chunk_processors_.find(session()->session_id()); | 111 host->Send(new DevToolsAgentMsg_Reattach( |
| 112 if (it != chunk_processors_.end()) | 112 worker_id_.second, GetId(), it.first, it.second->state_cookie())); |
| 113 state_cookie = it->second->state_cookie(); | 113 } |
| 114 host->Send(new DevToolsAgentMsg_Reattach( | |
| 115 worker_id_.second, GetId(), session()->session_id(), state_cookie)); | |
| 116 } | 114 } |
| 117 OnAttachedStateChanged(true); | 115 OnAttachedStateChanged(true); |
| 118 } else if (state_ == WORKER_PAUSED_FOR_DEBUG_ON_START) { | 116 } else if (state_ == WORKER_PAUSED_FOR_DEBUG_ON_START) { |
| 119 state_ = WORKER_READY_FOR_DEBUG_ON_START; | 117 state_ = WORKER_READY_FOR_DEBUG_ON_START; |
| 120 } | 118 } |
| 121 } | 119 } |
| 122 | 120 |
| 123 void WorkerDevToolsAgentHost::WorkerRestarted(WorkerId worker_id) { | 121 void WorkerDevToolsAgentHost::WorkerRestarted(WorkerId worker_id) { |
| 124 DCHECK_EQ(WORKER_TERMINATED, state_); | 122 DCHECK_EQ(WORKER_TERMINATED, state_); |
| 125 state_ = IsAttached() ? WORKER_PAUSED_FOR_REATTACH : WORKER_UNINSPECTED; | 123 state_ = IsAttached() ? WORKER_PAUSED_FOR_REATTACH : WORKER_UNINSPECTED; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 171 |
| 174 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( | 172 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( |
| 175 const DevToolsMessageChunk& message) { | 173 const DevToolsMessageChunk& message) { |
| 176 auto it = chunk_processors_.find(message.session_id); | 174 auto it = chunk_processors_.find(message.session_id); |
| 177 if (it != chunk_processors_.end()) | 175 if (it != chunk_processors_.end()) |
| 178 it->second->ProcessChunkedMessageFromAgent(message); | 176 it->second->ProcessChunkedMessageFromAgent(message); |
| 179 } | 177 } |
| 180 | 178 |
| 181 void WorkerDevToolsAgentHost::SendChunkedMessage(int session_id, | 179 void WorkerDevToolsAgentHost::SendChunkedMessage(int session_id, |
| 182 const std::string& message) { | 180 const std::string& message) { |
| 183 if (session() && session()->session_id() == session_id) | 181 auto it = sessions().find(session_id); |
| 184 session()->SendMessageToClient(message); | 182 if (it != sessions().end()) |
| 183 it->second->SendMessageToClient(message); |
| 185 } | 184 } |
| 186 | 185 |
| 187 } // namespace content | 186 } // namespace content |
| OLD | NEW |