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