| 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/service_worker_devtools_agent_host.h" | 5 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 8 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 9 #include "content/browser/service_worker/service_worker_version.h" | 10 #include "content/browser/service_worker/service_worker_version.h" |
| 10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 void StatusNoOp(ServiceWorkerStatusCode status) {} | 18 void StatusNoOp(ServiceWorkerStatusCode status) {} |
| (...skipping 16 matching lines...) Expand all Loading... |
| 34 version->SetDevToolsAttached(attached); | 35 version->SetDevToolsAttached(attached); |
| 35 } | 36 } |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace | 39 } // namespace |
| 39 | 40 |
| 40 ServiceWorkerDevToolsAgentHost::ServiceWorkerDevToolsAgentHost( | 41 ServiceWorkerDevToolsAgentHost::ServiceWorkerDevToolsAgentHost( |
| 41 WorkerId worker_id, | 42 WorkerId worker_id, |
| 42 const ServiceWorkerIdentifier& service_worker, | 43 const ServiceWorkerIdentifier& service_worker, |
| 43 bool debug_service_worker_on_start) | 44 bool debug_service_worker_on_start) |
| 44 : EmbeddedWorkerDevToolsAgentHost(worker_id), | 45 : WorkerDevToolsAgentHost(worker_id), |
| 45 service_worker_(new ServiceWorkerIdentifier(service_worker)) { | 46 service_worker_(new ServiceWorkerIdentifier(service_worker)) { |
| 46 if (debug_service_worker_on_start) | 47 if (debug_service_worker_on_start) |
| 47 set_state(WORKER_PAUSED_FOR_DEBUG_ON_START); | 48 set_state(WORKER_PAUSED_FOR_DEBUG_ON_START); |
| 48 } | 49 } |
| 49 | 50 |
| 50 DevToolsAgentHost::Type ServiceWorkerDevToolsAgentHost::GetType() { | 51 DevToolsAgentHost::Type ServiceWorkerDevToolsAgentHost::GetType() { |
| 51 return TYPE_SERVICE_WORKER; | 52 return TYPE_SERVICE_WORKER; |
| 52 } | 53 } |
| 53 | 54 |
| 54 std::string ServiceWorkerDevToolsAgentHost::GetTitle() { | 55 std::string ServiceWorkerDevToolsAgentHost::GetTitle() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 | 70 |
| 70 bool ServiceWorkerDevToolsAgentHost::Close() { | 71 bool ServiceWorkerDevToolsAgentHost::Close() { |
| 71 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 72 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 72 base::Bind(&TerminateServiceWorkerOnIO, | 73 base::Bind(&TerminateServiceWorkerOnIO, |
| 73 service_worker_->context_weak(), | 74 service_worker_->context_weak(), |
| 74 service_worker_->version_id())); | 75 service_worker_->version_id())); |
| 75 return true; | 76 return true; |
| 76 } | 77 } |
| 77 | 78 |
| 78 void ServiceWorkerDevToolsAgentHost::OnClientAttached() { | 79 void ServiceWorkerDevToolsAgentHost::OnClientAttached() { |
| 79 EmbeddedWorkerDevToolsAgentHost::OnClientAttached(); | 80 WorkerDevToolsAgentHost::OnClientAttached(); |
| 80 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 81 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 81 base::Bind(&SetDevToolsAttachedOnIO, | 82 base::Bind(&SetDevToolsAttachedOnIO, |
| 82 service_worker_->context_weak(), | 83 service_worker_->context_weak(), |
| 83 service_worker_->version_id(), | 84 service_worker_->version_id(), |
| 84 true)); | 85 true)); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void ServiceWorkerDevToolsAgentHost::OnClientDetached() { | 88 void ServiceWorkerDevToolsAgentHost::OnClientDetached() { |
| 88 EmbeddedWorkerDevToolsAgentHost::OnClientDetached(); | 89 WorkerDevToolsAgentHost::OnClientDetached(); |
| 89 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 90 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 90 base::Bind(&SetDevToolsAttachedOnIO, | 91 base::Bind(&SetDevToolsAttachedOnIO, |
| 91 service_worker_->context_weak(), | 92 service_worker_->context_weak(), |
| 92 service_worker_->version_id(), | 93 service_worker_->version_id(), |
| 93 false)); | 94 false)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 bool ServiceWorkerDevToolsAgentHost::Matches( | 97 bool ServiceWorkerDevToolsAgentHost::Matches( |
| 97 const ServiceWorkerIdentifier& other) { | 98 const ServiceWorkerIdentifier& other) { |
| 98 return service_worker_->Matches(other); | 99 return service_worker_->Matches(other); |
| 99 } | 100 } |
| 100 | 101 |
| 101 ServiceWorkerDevToolsAgentHost::~ServiceWorkerDevToolsAgentHost() { | 102 ServiceWorkerDevToolsAgentHost::~ServiceWorkerDevToolsAgentHost() { |
| 103 ServiceWorkerDevToolsManager::GetInstance()->RemoveInspectedWorkerData( |
| 104 worker_id()); |
| 102 } | 105 } |
| 103 | 106 |
| 104 } // namespace content | 107 } // namespace content |
| OLD | NEW |