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/devtools_protocol_handler.h" | 8 #include "content/browser/devtools/devtools_protocol_handler.h" |
9 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 9 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
10 #include "content/browser/devtools/service_worker_devtools_manager.h" | 10 #include "content/browser/devtools/service_worker_devtools_manager.h" |
11 #include "content/browser/service_worker/service_worker_context_core.h" | 11 #include "content/browser/service_worker/service_worker_context_core.h" |
12 #include "content/browser/service_worker/service_worker_version.h" | 12 #include "content/browser/service_worker/service_worker_version.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 void StatusNoOp(ServiceWorkerStatusCode status) {} | 20 void StatusNoOp(ServiceWorkerStatusCode status) {} |
21 | 21 |
22 void TerminateServiceWorkerOnIO( | 22 void TerminateServiceWorkerOnIO( |
23 base::WeakPtr<ServiceWorkerContextCore> context_weak, | 23 base::WeakPtr<ServiceWorkerContextCore> context_weak, |
24 int64 version_id) { | 24 int64_t version_id) { |
25 if (ServiceWorkerContextCore* context = context_weak.get()) { | 25 if (ServiceWorkerContextCore* context = context_weak.get()) { |
26 if (ServiceWorkerVersion* version = context->GetLiveVersion(version_id)) | 26 if (ServiceWorkerVersion* version = context->GetLiveVersion(version_id)) |
27 version->StopWorker(base::Bind(&StatusNoOp)); | 27 version->StopWorker(base::Bind(&StatusNoOp)); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 void UnregisterServiceWorkerOnIO( | 31 void UnregisterServiceWorkerOnIO( |
32 base::WeakPtr<ServiceWorkerContextCore> context_weak, | 32 base::WeakPtr<ServiceWorkerContextCore> context_weak, |
33 int64 version_id) { | 33 int64_t version_id) { |
34 if (ServiceWorkerContextCore* context = context_weak.get()) { | 34 if (ServiceWorkerContextCore* context = context_weak.get()) { |
35 if (ServiceWorkerVersion* version = context->GetLiveVersion(version_id)) { | 35 if (ServiceWorkerVersion* version = context->GetLiveVersion(version_id)) { |
36 version->StopWorker(base::Bind(&StatusNoOp)); | 36 version->StopWorker(base::Bind(&StatusNoOp)); |
37 context->UnregisterServiceWorker( | 37 context->UnregisterServiceWorker( |
38 version->scope(), base::Bind(&StatusNoOp)); | 38 version->scope(), base::Bind(&StatusNoOp)); |
39 } | 39 } |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 void SetDevToolsAttachedOnIO( | 43 void SetDevToolsAttachedOnIO( |
44 base::WeakPtr<ServiceWorkerContextCore> context_weak, | 44 base::WeakPtr<ServiceWorkerContextCore> context_weak, |
45 int64 version_id, | 45 int64_t version_id, |
46 bool attached) { | 46 bool attached) { |
47 if (ServiceWorkerContextCore* context = context_weak.get()) { | 47 if (ServiceWorkerContextCore* context = context_weak.get()) { |
48 if (ServiceWorkerVersion* version = context->GetLiveVersion(version_id)) | 48 if (ServiceWorkerVersion* version = context->GetLiveVersion(version_id)) |
49 version->SetDevToolsAttached(attached); | 49 version->SetDevToolsAttached(attached); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 ServiceWorkerDevToolsAgentHost::ServiceWorkerDevToolsAgentHost( | 55 ServiceWorkerDevToolsAgentHost::ServiceWorkerDevToolsAgentHost( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 void ServiceWorkerDevToolsAgentHost::OnAttachedStateChanged(bool attached) { | 100 void ServiceWorkerDevToolsAgentHost::OnAttachedStateChanged(bool attached) { |
101 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 101 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
102 base::Bind(&SetDevToolsAttachedOnIO, | 102 base::Bind(&SetDevToolsAttachedOnIO, |
103 service_worker_->context_weak(), | 103 service_worker_->context_weak(), |
104 service_worker_->version_id(), | 104 service_worker_->version_id(), |
105 attached)); | 105 attached)); |
106 } | 106 } |
107 | 107 |
108 int64 ServiceWorkerDevToolsAgentHost::service_worker_version_id() const { | 108 int64_t ServiceWorkerDevToolsAgentHost::service_worker_version_id() const { |
109 return service_worker_->version_id(); | 109 return service_worker_->version_id(); |
110 } | 110 } |
111 | 111 |
112 bool ServiceWorkerDevToolsAgentHost::Matches( | 112 bool ServiceWorkerDevToolsAgentHost::Matches( |
113 const ServiceWorkerIdentifier& other) { | 113 const ServiceWorkerIdentifier& other) { |
114 return service_worker_->Matches(other); | 114 return service_worker_->Matches(other); |
115 } | 115 } |
116 | 116 |
117 ServiceWorkerDevToolsAgentHost::~ServiceWorkerDevToolsAgentHost() { | 117 ServiceWorkerDevToolsAgentHost::~ServiceWorkerDevToolsAgentHost() { |
118 ServiceWorkerDevToolsManager::GetInstance()->RemoveInspectedWorkerData( | 118 ServiceWorkerDevToolsManager::GetInstance()->RemoveInspectedWorkerData( |
119 worker_id()); | 119 worker_id()); |
120 } | 120 } |
121 | 121 |
122 } // namespace content | 122 } // namespace content |
OLD | NEW |