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
3 // found in the LICENSE file.
5 #include "content/browser/devtools/shared_worker_devtools_agent_host.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/devtools/shared_worker_devtools_manager.h"
9 #include "content/browser/shared_worker/shared_worker_instance.h"
10 #include "content/browser/shared_worker/shared_worker_service_impl.h"
11 #include "content/public/browser/browser_thread.h"
17 void TerminateSharedWorkerOnIO(
18 WorkerDevToolsAgentHost::WorkerId worker_id
) {
19 SharedWorkerServiceImpl::GetInstance()->TerminateWorker(
20 worker_id
.first
, worker_id
.second
);
25 SharedWorkerDevToolsAgentHost::SharedWorkerDevToolsAgentHost(
27 const SharedWorkerInstance
& shared_worker
)
28 : WorkerDevToolsAgentHost(worker_id
),
29 shared_worker_(new SharedWorkerInstance(shared_worker
)) {
32 DevToolsAgentHost::Type
SharedWorkerDevToolsAgentHost::GetType() {
33 return TYPE_SHARED_WORKER
;
36 std::string
SharedWorkerDevToolsAgentHost::GetTitle() {
37 return base::UTF16ToUTF8(shared_worker_
->name());
40 GURL
SharedWorkerDevToolsAgentHost::GetURL() {
41 return shared_worker_
->url();
44 bool SharedWorkerDevToolsAgentHost::Activate() {
48 bool SharedWorkerDevToolsAgentHost::Close() {
49 BrowserThread::PostTask(BrowserThread::IO
, FROM_HERE
,
50 base::Bind(&TerminateSharedWorkerOnIO
, worker_id()));
54 bool SharedWorkerDevToolsAgentHost::Matches(
55 const SharedWorkerInstance
& other
) {
56 return shared_worker_
->Matches(other
);
59 SharedWorkerDevToolsAgentHost::~SharedWorkerDevToolsAgentHost() {
60 SharedWorkerDevToolsManager::GetInstance()->RemoveInspectedWorkerData(
64 } // namespace content