| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/protocol/service_worker_handler.h" | 5 #include "content/browser/devtools/protocol/service_worker_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "content/browser/devtools/service_worker_devtools_agent_host.h" | 11 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
| 12 #include "content/browser/devtools/service_worker_devtools_manager.h" | 12 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 13 #include "content/browser/frame_host/frame_tree.h" | 13 #include "content/browser/frame_host/frame_tree.h" |
| 14 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
| 15 #include "content/browser/frame_host/render_frame_host_impl.h" | 15 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 16 #include "content/browser/service_worker/service_worker_context_core.h" | |
| 17 #include "content/browser/service_worker/service_worker_context_watcher.h" | 16 #include "content/browser/service_worker/service_worker_context_watcher.h" |
| 18 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 19 #include "content/browser/service_worker/service_worker_version.h" | 18 #include "content/browser/service_worker/service_worker_version.h" |
| 20 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/devtools_agent_host.h" | 21 #include "content/public/browser/devtools_agent_host.h" |
| 23 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
| 24 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
| 26 #include "content/public/common/push_messaging_status.h" | 25 #include "content/public/common/push_messaging_status.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 return result; | 143 return result; |
| 145 } | 144 } |
| 146 | 145 |
| 147 bool CollectURLs(std::set<GURL>* urls, FrameTreeNode* tree_node) { | 146 bool CollectURLs(std::set<GURL>* urls, FrameTreeNode* tree_node) { |
| 148 urls->insert(tree_node->current_url()); | 147 urls->insert(tree_node->current_url()); |
| 149 return false; | 148 return false; |
| 150 } | 149 } |
| 151 | 150 |
| 152 void StopServiceWorkerOnIO(scoped_refptr<ServiceWorkerContextWrapper> context, | 151 void StopServiceWorkerOnIO(scoped_refptr<ServiceWorkerContextWrapper> context, |
| 153 int64 version_id) { | 152 int64 version_id) { |
| 154 ServiceWorkerContextCore* context_core = context->context(); | |
| 155 if (!context_core) | |
| 156 return; | |
| 157 if (content::ServiceWorkerVersion* version = | 153 if (content::ServiceWorkerVersion* version = |
| 158 context_core->GetLiveVersion(version_id)) { | 154 context->GetLiveVersion(version_id)) { |
| 159 version->StopWorker(base::Bind(&StatusNoOp)); | 155 version->StopWorker(base::Bind(&StatusNoOp)); |
| 160 } | 156 } |
| 161 } | 157 } |
| 162 | 158 |
| 163 void GetDevToolsRouteInfoOnIO( | 159 void GetDevToolsRouteInfoOnIO( |
| 164 scoped_refptr<ServiceWorkerContextWrapper> context, | 160 scoped_refptr<ServiceWorkerContextWrapper> context, |
| 165 int64 version_id, | 161 int64 version_id, |
| 166 const base::Callback<void(int, int)>& callback) { | 162 const base::Callback<void(int, int)>& callback) { |
| 167 ServiceWorkerContextCore* context_core = context->context(); | |
| 168 if (!context_core) | |
| 169 return; | |
| 170 if (content::ServiceWorkerVersion* version = | 163 if (content::ServiceWorkerVersion* version = |
| 171 context_core->GetLiveVersion(version_id)) { | 164 context->GetLiveVersion(version_id)) { |
| 172 BrowserThread::PostTask( | 165 BrowserThread::PostTask( |
| 173 BrowserThread::UI, FROM_HERE, | 166 BrowserThread::UI, FROM_HERE, |
| 174 base::Bind( | 167 base::Bind( |
| 175 callback, version->embedded_worker()->process_id(), | 168 callback, version->embedded_worker()->process_id(), |
| 176 version->embedded_worker()->worker_devtools_agent_route_id())); | 169 version->embedded_worker()->worker_devtools_agent_route_id())); |
| 177 } | 170 } |
| 178 } | 171 } |
| 179 | 172 |
| 180 Response CreateContextErrorResoponse() { | 173 Response CreateContextErrorResoponse() { |
| 181 return Response::InternalError("Could not connect to the context"); | 174 return Response::InternalError("Could not connect to the context"); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 return; | 484 return; |
| 492 host->DetachClient(); | 485 host->DetachClient(); |
| 493 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> | 486 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> |
| 494 set_worker_id(host->GetId())); | 487 set_worker_id(host->GetId())); |
| 495 attached_hosts_.erase(it); | 488 attached_hosts_.erase(it); |
| 496 } | 489 } |
| 497 | 490 |
| 498 } // namespace service_worker | 491 } // namespace service_worker |
| 499 } // namespace devtools | 492 } // namespace devtools |
| 500 } // namespace content | 493 } // namespace content |
| OLD | NEW |