| 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/service_worker/service_worker_internals_ui.h" | 5 #include "content/browser/service_worker/service_worker_internals_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 void StopActiveWorker( | 78 void StopActiveWorker( |
| 79 ServiceWorkerStatusCode status, | 79 ServiceWorkerStatusCode status, |
| 80 const scoped_refptr<ServiceWorkerRegistration>& registration); | 80 const scoped_refptr<ServiceWorkerRegistration>& registration); |
| 81 | 81 |
| 82 void DispatchSyncEventToActiveWorker( | 82 void DispatchSyncEventToActiveWorker( |
| 83 ServiceWorkerStatusCode status, | 83 ServiceWorkerStatusCode status, |
| 84 const scoped_refptr<ServiceWorkerRegistration>& registration); | 84 const scoped_refptr<ServiceWorkerRegistration>& registration); |
| 85 | 85 |
| 86 void InspectActiveWorker( | 86 void InspectActiveWorker( |
| 87 const base::FilePath& context_path, | 87 const ServiceWorkerContextCore* const service_worker_context, |
| 88 ServiceWorkerStatusCode status, | 88 ServiceWorkerStatusCode status, |
| 89 const scoped_refptr<ServiceWorkerRegistration>& registration); | 89 const scoped_refptr<ServiceWorkerRegistration>& registration); |
| 90 | 90 |
| 91 void InspecteWorkerOnUIThread(const base::FilePath& context_path, | 91 void InspecteWorkerOnUIThread( |
| 92 int64 version_id); | 92 const ServiceWorkerContextCore* const service_worker_context, |
| 93 int64 version_id); |
| 93 | 94 |
| 94 WeakPtr<ServiceWorkerInternalsUI> internals_; | 95 WeakPtr<ServiceWorkerInternalsUI> internals_; |
| 95 scoped_ptr<ListValue> original_args_; | 96 scoped_ptr<ListValue> original_args_; |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 class ServiceWorkerInternalsUI::PartitionObserver | 99 class ServiceWorkerInternalsUI::PartitionObserver |
| 99 : public ServiceWorkerContextObserver { | 100 : public ServiceWorkerContextObserver { |
| 100 public: | 101 public: |
| 101 PartitionObserver(int partition_id, WebUI* web_ui) | 102 PartitionObserver(int partition_id, WebUI* web_ui) |
| 102 : partition_id_(partition_id), web_ui_(web_ui) {} | 103 : partition_id_(partition_id), web_ui_(web_ui) {} |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 } | 481 } |
| 481 | 482 |
| 482 void ServiceWorkerInternalsUI::OperationProxy::InspectWorkerOnIOThread( | 483 void ServiceWorkerInternalsUI::OperationProxy::InspectWorkerOnIOThread( |
| 483 scoped_refptr<ServiceWorkerContextWrapper> context, | 484 scoped_refptr<ServiceWorkerContextWrapper> context, |
| 484 const GURL& scope) { | 485 const GURL& scope) { |
| 485 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 486 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 486 context->context()->storage()->FindRegistrationForPattern( | 487 context->context()->storage()->FindRegistrationForPattern( |
| 487 scope, | 488 scope, |
| 488 base::Bind(&ServiceWorkerInternalsUI::OperationProxy::InspectActiveWorker, | 489 base::Bind(&ServiceWorkerInternalsUI::OperationProxy::InspectActiveWorker, |
| 489 this, | 490 this, |
| 490 context->context()->storage_partition_path())); | 491 context->context())); |
| 491 } | 492 } |
| 492 | 493 |
| 493 namespace { | 494 namespace { |
| 494 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, | 495 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, |
| 495 DictionaryValue* info) { | 496 DictionaryValue* info) { |
| 496 switch (version.running_status) { | 497 switch (version.running_status) { |
| 497 case ServiceWorkerVersion::STOPPED: | 498 case ServiceWorkerVersion::STOPPED: |
| 498 info->SetString("running_status", "STOPPED"); | 499 info->SetString("running_status", "STOPPED"); |
| 499 break; | 500 break; |
| 500 case ServiceWorkerVersion::STARTING: | 501 case ServiceWorkerVersion::STARTING: |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 ServiceWorkerVersion::ACTIVE) { | 642 ServiceWorkerVersion::ACTIVE) { |
| 642 registration->active_version()->DispatchSyncEvent(base::Bind( | 643 registration->active_version()->DispatchSyncEvent(base::Bind( |
| 643 &ServiceWorkerInternalsUI::OperationProxy::OperationComplete, this)); | 644 &ServiceWorkerInternalsUI::OperationProxy::OperationComplete, this)); |
| 644 return; | 645 return; |
| 645 } | 646 } |
| 646 | 647 |
| 647 OperationComplete(SERVICE_WORKER_ERROR_FAILED); | 648 OperationComplete(SERVICE_WORKER_ERROR_FAILED); |
| 648 } | 649 } |
| 649 | 650 |
| 650 void ServiceWorkerInternalsUI::OperationProxy::InspectActiveWorker( | 651 void ServiceWorkerInternalsUI::OperationProxy::InspectActiveWorker( |
| 651 const base::FilePath& context_path, | 652 const ServiceWorkerContextCore* const service_worker_context, |
| 652 ServiceWorkerStatusCode status, | 653 ServiceWorkerStatusCode status, |
| 653 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 654 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| 654 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 655 if (status == SERVICE_WORKER_OK) { | 656 if (status == SERVICE_WORKER_OK) { |
| 656 BrowserThread::PostTask( | 657 BrowserThread::PostTask( |
| 657 BrowserThread::UI, | 658 BrowserThread::UI, |
| 658 FROM_HERE, | 659 FROM_HERE, |
| 659 base::Bind(&OperationProxy::InspecteWorkerOnUIThread, | 660 base::Bind(&OperationProxy::InspecteWorkerOnUIThread, |
| 660 this, | 661 this, |
| 661 context_path, | 662 service_worker_context, |
| 662 registration->active_version()->version_id())); | 663 registration->active_version()->version_id())); |
| 663 return; | 664 return; |
| 664 } | 665 } |
| 665 | 666 |
| 666 OperationComplete(status); | 667 OperationComplete(status); |
| 667 } | 668 } |
| 668 | 669 |
| 669 void ServiceWorkerInternalsUI::OperationProxy::InspecteWorkerOnUIThread( | 670 void ServiceWorkerInternalsUI::OperationProxy::InspecteWorkerOnUIThread( |
| 670 const base::FilePath& context_path, | 671 const ServiceWorkerContextCore* const service_worker_context, |
| 671 int64 version_id) { | 672 int64 version_id) { |
| 672 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 673 scoped_refptr<DevToolsAgentHost> agent_host( | 674 scoped_refptr<DevToolsAgentHost> agent_host( |
| 674 EmbeddedWorkerDevToolsManager::GetInstance() | 675 EmbeddedWorkerDevToolsManager::GetInstance() |
| 675 ->GetDevToolsAgentHostForServiceWorker(context_path, version_id)); | 676 ->GetDevToolsAgentHostForServiceWorker(service_worker_context, |
| 677 version_id)); |
| 676 if (agent_host) { | 678 if (agent_host) { |
| 677 DevToolsManagerImpl::GetInstance()->Inspect( | 679 DevToolsManagerImpl::GetInstance()->Inspect( |
| 678 internals_->web_ui()->GetWebContents()->GetBrowserContext(), | 680 internals_->web_ui()->GetWebContents()->GetBrowserContext(), |
| 679 agent_host.get()); | 681 agent_host.get()); |
| 680 OperationComplete(SERVICE_WORKER_OK); | 682 OperationComplete(SERVICE_WORKER_OK); |
| 681 return; | 683 return; |
| 682 } | 684 } |
| 683 OperationComplete(SERVICE_WORKER_ERROR_NOT_FOUND); | 685 OperationComplete(SERVICE_WORKER_ERROR_NOT_FOUND); |
| 684 } | 686 } |
| 685 | 687 |
| 686 } // namespace content | 688 } // namespace content |
| OLD | NEW |