| 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" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 380 } |
| 381 | 381 |
| 382 Response ServiceWorkerHandler::Disable() { | 382 Response ServiceWorkerHandler::Disable() { |
| 383 if (!enabled_) | 383 if (!enabled_) |
| 384 return Response::OK(); | 384 return Response::OK(); |
| 385 enabled_ = false; | 385 enabled_ = false; |
| 386 | 386 |
| 387 ServiceWorkerDevToolsManager::GetInstance()->RemoveObserver(this); | 387 ServiceWorkerDevToolsManager::GetInstance()->RemoveObserver(this); |
| 388 ClearForceUpdate(); | 388 ClearForceUpdate(); |
| 389 for (const auto& pair : attached_hosts_) | 389 for (const auto& pair : attached_hosts_) |
| 390 pair.second->DetachClient(); | 390 pair.second->DetachClient(this); |
| 391 attached_hosts_.clear(); | 391 attached_hosts_.clear(); |
| 392 DCHECK(context_watcher_); | 392 DCHECK(context_watcher_); |
| 393 context_watcher_->Stop(); | 393 context_watcher_->Stop(); |
| 394 context_watcher_ = nullptr; | 394 context_watcher_ = nullptr; |
| 395 return Response::OK(); | 395 return Response::OK(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 Response ServiceWorkerHandler::SendMessage( | 398 Response ServiceWorkerHandler::SendMessage( |
| 399 const std::string& worker_id, | 399 const std::string& worker_id, |
| 400 const std::string& message) { | 400 const std::string& message) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 ->set_url(host->GetURL().spec()) | 677 ->set_url(host->GetURL().spec()) |
| 678 ->set_version_id(base::Int64ToString( | 678 ->set_version_id(base::Int64ToString( |
| 679 host->service_worker_version_id()))); | 679 host->service_worker_version_id()))); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void ServiceWorkerHandler::ReportWorkerTerminated( | 682 void ServiceWorkerHandler::ReportWorkerTerminated( |
| 683 ServiceWorkerDevToolsAgentHost* host) { | 683 ServiceWorkerDevToolsAgentHost* host) { |
| 684 auto it = attached_hosts_.find(host->GetId()); | 684 auto it = attached_hosts_.find(host->GetId()); |
| 685 if (it == attached_hosts_.end()) | 685 if (it == attached_hosts_.end()) |
| 686 return; | 686 return; |
| 687 host->DetachClient(); | 687 host->DetachClient(this); |
| 688 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> | 688 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> |
| 689 set_worker_id(host->GetId())); | 689 set_worker_id(host->GetId())); |
| 690 attached_hosts_.erase(it); | 690 attached_hosts_.erase(it); |
| 691 } | 691 } |
| 692 | 692 |
| 693 void ServiceWorkerHandler::ClearForceUpdate() { | 693 void ServiceWorkerHandler::ClearForceUpdate() { |
| 694 if (context_) | 694 if (context_) |
| 695 context_->SetForceUpdateOnPageLoad(false); | 695 context_->SetForceUpdateOnPageLoad(false); |
| 696 } | 696 } |
| 697 | 697 |
| 698 } // namespace service_worker | 698 } // namespace service_worker |
| 699 } // namespace devtools | 699 } // namespace devtools |
| 700 } // namespace content | 700 } // namespace content |
| OLD | NEW |