Chromium Code Reviews| 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/embedded_worker_devtools_agent_host.h" | 5 #include "content/browser/devtools/embedded_worker_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | |
| 7 #include "content/browser/devtools/devtools_manager_impl.h" | 8 #include "content/browser/devtools/devtools_manager_impl.h" |
| 8 #include "content/browser/devtools/devtools_protocol.h" | 9 #include "content/browser/devtools/devtools_protocol.h" |
| 9 #include "content/browser/devtools/devtools_protocol_constants.h" | 10 #include "content/browser/devtools/devtools_protocol_constants.h" |
| 11 #include "content/browser/shared_worker/shared_worker_service_impl.h" | |
| 10 #include "content/common/devtools_messages.h" | 12 #include "content/common/devtools_messages.h" |
| 11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 13 | 15 |
| 14 namespace content { | 16 namespace content { |
| 15 | 17 |
| 16 EmbeddedWorkerDevToolsAgentHost::EmbeddedWorkerDevToolsAgentHost( | 18 EmbeddedWorkerDevToolsAgentHost::EmbeddedWorkerDevToolsAgentHost( |
| 17 WorkerId worker_id, | 19 WorkerId worker_id, |
| 18 const SharedWorkerInstance& shared_worker) | 20 const SharedWorkerInstance& shared_worker) |
| 19 : shared_worker_(new SharedWorkerInstance(shared_worker)), | 21 : shared_worker_(new SharedWorkerInstance(shared_worker)), |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 31 worker_id_(worker_id) { | 33 worker_id_(worker_id) { |
| 32 if (debug_service_worker_on_start) | 34 if (debug_service_worker_on_start) |
| 33 state_ = WORKER_PAUSED_FOR_DEBUG_ON_START; | 35 state_ = WORKER_PAUSED_FOR_DEBUG_ON_START; |
| 34 WorkerCreated(); | 36 WorkerCreated(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 bool EmbeddedWorkerDevToolsAgentHost::IsWorker() const { | 39 bool EmbeddedWorkerDevToolsAgentHost::IsWorker() const { |
| 38 return true; | 40 return true; |
| 39 } | 41 } |
| 40 | 42 |
| 43 std::string EmbeddedWorkerDevToolsAgentHost::GetType() { | |
| 44 return shared_worker_ ? kTypeWorker : kTypeServiceWorker; | |
| 45 } | |
| 46 | |
| 47 std::string EmbeddedWorkerDevToolsAgentHost::GetTitle() { | |
| 48 return shared_worker_ ? base::UTF16ToUTF8(shared_worker_->name()) : ""; | |
| 49 } | |
| 50 | |
| 51 GURL EmbeddedWorkerDevToolsAgentHost::GetURL() { | |
| 52 return shared_worker_ ? shared_worker_->url() : GURL(); | |
|
dgozman
2014/08/13 15:57:02
Can we get URL for shared worker?
vkuzkokov
2014/08/14 07:48:17
Service worker, you mean? It requires changes in E
dgozman
2014/08/14 08:15:33
Can we make those changes beforehand? Otherwise yo
| |
| 53 } | |
| 54 | |
| 55 bool EmbeddedWorkerDevToolsAgentHost::Activate() { | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 bool EmbeddedWorkerDevToolsAgentHost::Close() { | |
| 60 if (shared_worker_) { | |
| 61 return SharedWorkerServiceImpl::GetInstance()->TerminateWorker( | |
| 62 worker_id_.first, worker_id_.second); | |
| 63 } | |
| 64 return false; | |
|
dgozman
2014/08/13 15:57:02
Why can't we close shared worker?
vkuzkokov
2014/08/14 07:48:17
Ditto.
| |
| 65 } | |
| 66 | |
| 41 void EmbeddedWorkerDevToolsAgentHost::SendMessageToAgent( | 67 void EmbeddedWorkerDevToolsAgentHost::SendMessageToAgent( |
| 42 IPC::Message* message_raw) { | 68 IPC::Message* message_raw) { |
| 43 scoped_ptr<IPC::Message> message(message_raw); | 69 scoped_ptr<IPC::Message> message(message_raw); |
| 44 if (state_ != WORKER_INSPECTED) | 70 if (state_ != WORKER_INSPECTED) |
| 45 return; | 71 return; |
| 46 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { | 72 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { |
| 47 message->set_routing_id(worker_id_.second); | 73 message->set_routing_id(worker_id_.second); |
| 48 host->Send(message.release()); | 74 host->Send(message.release()); |
| 49 } | 75 } |
| 50 } | 76 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend( | 176 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend( |
| 151 this, message); | 177 this, message); |
| 152 } | 178 } |
| 153 | 179 |
| 154 void EmbeddedWorkerDevToolsAgentHost::OnSaveAgentRuntimeState( | 180 void EmbeddedWorkerDevToolsAgentHost::OnSaveAgentRuntimeState( |
| 155 const std::string& state) { | 181 const std::string& state) { |
| 156 saved_agent_state_ = state; | 182 saved_agent_state_ = state; |
| 157 } | 183 } |
| 158 | 184 |
| 159 } // namespace content | 185 } // namespace content |
| OLD | NEW |