| 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" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "content/browser/devtools/devtools_agent_host_impl.h" |
| 14 #include "content/browser/devtools/devtools_manager_impl.h" | 15 #include "content/browser/devtools/devtools_manager_impl.h" |
| 15 #include "content/browser/devtools/embedded_worker_devtools_manager.h" | 16 #include "content/browser/devtools/embedded_worker_devtools_manager.h" |
| 16 #include "content/browser/service_worker/service_worker_context_observer.h" | 17 #include "content/browser/service_worker/service_worker_context_observer.h" |
| 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 18 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 18 #include "content/browser/service_worker/service_worker_registration.h" | 19 #include "content/browser/service_worker/service_worker_registration.h" |
| 19 #include "content/browser/service_worker/service_worker_version.h" | 20 #include "content/browser/service_worker/service_worker_version.h" |
| 20 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/storage_partition.h" | 23 #include "content/public/browser/storage_partition.h" |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 int devtools_agent_route_id = 0; | 615 int devtools_agent_route_id = 0; |
| 615 if (!args->GetInteger(0, &callback_id) || | 616 if (!args->GetInteger(0, &callback_id) || |
| 616 !args->GetDictionary(1, &cmd_args) || | 617 !args->GetDictionary(1, &cmd_args) || |
| 617 !cmd_args->GetInteger("process_id", &process_id) || | 618 !cmd_args->GetInteger("process_id", &process_id) || |
| 618 !cmd_args->GetInteger("devtools_agent_route_id", | 619 !cmd_args->GetInteger("devtools_agent_route_id", |
| 619 &devtools_agent_route_id)) { | 620 &devtools_agent_route_id)) { |
| 620 return; | 621 return; |
| 621 } | 622 } |
| 622 base::Callback<void(ServiceWorkerStatusCode)> callback = | 623 base::Callback<void(ServiceWorkerStatusCode)> callback = |
| 623 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); | 624 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); |
| 624 scoped_refptr<DevToolsAgentHost> agent_host( | 625 scoped_refptr<DevToolsAgentHostImpl> agent_host( |
| 625 EmbeddedWorkerDevToolsManager::GetInstance() | 626 EmbeddedWorkerDevToolsManager::GetInstance() |
| 626 ->GetDevToolsAgentHostForWorker(process_id, devtools_agent_route_id)); | 627 ->GetDevToolsAgentHostForWorker(process_id, devtools_agent_route_id)); |
| 627 if (!agent_host) { | 628 if (!agent_host) { |
| 628 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); | 629 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); |
| 629 return; | 630 return; |
| 630 } | 631 } |
| 631 DevToolsManagerImpl::GetInstance()->Inspect( | 632 agent_host->Inspect(web_ui()->GetWebContents()->GetBrowserContext()); |
| 632 web_ui()->GetWebContents()->GetBrowserContext(), agent_host.get()); | |
| 633 callback.Run(SERVICE_WORKER_OK); | 633 callback.Run(SERVICE_WORKER_OK); |
| 634 } | 634 } |
| 635 | 635 |
| 636 void ServiceWorkerInternalsUI::Unregister(const ListValue* args) { | 636 void ServiceWorkerInternalsUI::Unregister(const ListValue* args) { |
| 637 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 637 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 638 int callback_id; | 638 int callback_id; |
| 639 int partition_id; | 639 int partition_id; |
| 640 std::string scope_string; | 640 std::string scope_string; |
| 641 const DictionaryValue* cmd_args = NULL; | 641 const DictionaryValue* cmd_args = NULL; |
| 642 scoped_refptr<ServiceWorkerContextWrapper> context; | 642 scoped_refptr<ServiceWorkerContextWrapper> context; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 668 return; | 668 return; |
| 669 } | 669 } |
| 670 | 670 |
| 671 base::Callback<void(ServiceWorkerStatusCode)> callback = | 671 base::Callback<void(ServiceWorkerStatusCode)> callback = |
| 672 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); | 672 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); |
| 673 FindRegistrationForPattern( | 673 FindRegistrationForPattern( |
| 674 context, GURL(scope_string), base::Bind(StartActiveWorker, callback)); | 674 context, GURL(scope_string), base::Bind(StartActiveWorker, callback)); |
| 675 } | 675 } |
| 676 | 676 |
| 677 } // namespace content | 677 } // namespace content |
| OLD | NEW |