| 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 "content/browser/devtools/devtools_protocol_handler.h" | 8 #include "content/browser/devtools/devtools_protocol_handler.h" |
| 8 #include "content/browser/devtools/protocol/schema_handler.h" | 9 #include "content/browser/devtools/protocol/schema_handler.h" |
| 9 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 BrowserContext* WorkerDevToolsAgentHost::GetBrowserContext() { | 15 BrowserContext* WorkerDevToolsAgentHost::GetBrowserContext() { |
| 15 RenderProcessHost* rph = RenderProcessHost::FromID(worker_id_.first); | 16 RenderProcessHost* rph = RenderProcessHost::FromID(worker_id_.first); |
| 16 return rph ? rph->GetBrowserContext() : nullptr; | 17 return rph ? rph->GetBrowserContext() : nullptr; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 114 } |
| 114 state_ = WORKER_TERMINATED; | 115 state_ = WORKER_TERMINATED; |
| 115 Release(); // Balanced in WorkerCreated(). | 116 Release(); // Balanced in WorkerCreated(). |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool WorkerDevToolsAgentHost::IsTerminated() { | 119 bool WorkerDevToolsAgentHost::IsTerminated() { |
| 119 return state_ == WORKER_TERMINATED; | 120 return state_ == WORKER_TERMINATED; |
| 120 } | 121 } |
| 121 | 122 |
| 122 WorkerDevToolsAgentHost::WorkerDevToolsAgentHost(WorkerId worker_id) | 123 WorkerDevToolsAgentHost::WorkerDevToolsAgentHost(WorkerId worker_id) |
| 123 : schema_handler_(new devtools::schema::SchemaHandler()), | 124 : DevToolsAgentHostImpl(base::GenerateGUID()), |
| 125 schema_handler_(new devtools::schema::SchemaHandler()), |
| 124 protocol_handler_(new DevToolsProtocolHandler(this)), | 126 protocol_handler_(new DevToolsProtocolHandler(this)), |
| 125 chunk_processor_(base::Bind(&WorkerDevToolsAgentHost::SendMessageToClient, | 127 chunk_processor_(base::Bind(&WorkerDevToolsAgentHost::SendMessageToClient, |
| 126 base::Unretained(this))), | 128 base::Unretained(this))), |
| 127 state_(WORKER_UNINSPECTED), | 129 state_(WORKER_UNINSPECTED), |
| 128 worker_id_(worker_id) { | 130 worker_id_(worker_id) { |
| 129 protocol_handler_->dispatcher()->SetSchemaHandler(schema_handler_.get()); | 131 protocol_handler_->dispatcher()->SetSchemaHandler(schema_handler_.get()); |
| 130 WorkerCreated(); | 132 WorkerCreated(); |
| 131 } | 133 } |
| 132 | 134 |
| 133 WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() { | 135 WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 153 | 155 |
| 154 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( | 156 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( |
| 155 const DevToolsMessageChunk& message) { | 157 const DevToolsMessageChunk& message) { |
| 156 if (!IsAttached()) | 158 if (!IsAttached()) |
| 157 return; | 159 return; |
| 158 | 160 |
| 159 chunk_processor_.ProcessChunkedMessageFromAgent(message); | 161 chunk_processor_.ProcessChunkedMessageFromAgent(message); |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace content | 164 } // namespace content |
| OLD | NEW |