| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 base::Bind(CallServiceWorkerVersionMethodWithVersionID, | 69 base::Bind(CallServiceWorkerVersionMethodWithVersionID, |
| 70 method, | 70 method, |
| 71 context, | 71 context, |
| 72 version_id, | 72 version_id, |
| 73 callback)); | 73 callback)); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 77 scoped_refptr<ServiceWorkerVersion> version = | 77 scoped_refptr<ServiceWorkerVersion> version = |
| 78 context->context()->GetLiveVersion(version_id); | 78 context->context()->GetLiveVersion(version_id); |
| 79 if (!version) { | 79 if (!version.get()) { |
| 80 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); | 80 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 (*version.*method)(callback); | 83 (*version.get().*method)(callback); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void DispatchPushEventWithVersionID( | 86 void DispatchPushEventWithVersionID( |
| 87 scoped_refptr<ServiceWorkerContextWrapper> context, | 87 scoped_refptr<ServiceWorkerContextWrapper> context, |
| 88 int64 version_id, | 88 int64 version_id, |
| 89 const ServiceWorkerInternalsUI::StatusCallback& callback) { | 89 const ServiceWorkerInternalsUI::StatusCallback& callback) { |
| 90 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 90 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 91 BrowserThread::PostTask( | 91 BrowserThread::PostTask( |
| 92 BrowserThread::IO, | 92 BrowserThread::IO, |
| 93 FROM_HERE, | 93 FROM_HERE, |
| 94 base::Bind(DispatchPushEventWithVersionID, | 94 base::Bind(DispatchPushEventWithVersionID, |
| 95 context, | 95 context, |
| 96 version_id, | 96 version_id, |
| 97 callback)); | 97 callback)); |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 101 scoped_refptr<ServiceWorkerVersion> version = | 101 scoped_refptr<ServiceWorkerVersion> version = |
| 102 context->context()->GetLiveVersion(version_id); | 102 context->context()->GetLiveVersion(version_id); |
| 103 if (!version) { | 103 if (!version.get()) { |
| 104 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); | 104 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); |
| 105 return; | 105 return; |
| 106 } | 106 } |
| 107 std::string data = "Test push message from ServiceWorkerInternals."; | 107 std::string data = "Test push message from ServiceWorkerInternals."; |
| 108 version->DispatchPushEvent(callback, data); | 108 version->DispatchPushEvent(callback, data); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void UnregisterWithScope( | 111 void UnregisterWithScope( |
| 112 scoped_refptr<ServiceWorkerContextWrapper> context, | 112 scoped_refptr<ServiceWorkerContextWrapper> context, |
| 113 const GURL& scope, | 113 const GURL& scope, |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 !cmd_args->GetInteger("process_id", &process_id) || | 618 !cmd_args->GetInteger("process_id", &process_id) || |
| 619 !cmd_args->GetInteger("devtools_agent_route_id", | 619 !cmd_args->GetInteger("devtools_agent_route_id", |
| 620 &devtools_agent_route_id)) { | 620 &devtools_agent_route_id)) { |
| 621 return; | 621 return; |
| 622 } | 622 } |
| 623 base::Callback<void(ServiceWorkerStatusCode)> callback = | 623 base::Callback<void(ServiceWorkerStatusCode)> callback = |
| 624 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); | 624 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); |
| 625 scoped_refptr<DevToolsAgentHostImpl> agent_host( | 625 scoped_refptr<DevToolsAgentHostImpl> agent_host( |
| 626 EmbeddedWorkerDevToolsManager::GetInstance() | 626 EmbeddedWorkerDevToolsManager::GetInstance() |
| 627 ->GetDevToolsAgentHostForWorker(process_id, devtools_agent_route_id)); | 627 ->GetDevToolsAgentHostForWorker(process_id, devtools_agent_route_id)); |
| 628 if (!agent_host) { | 628 if (!agent_host.get()) { |
| 629 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); | 629 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); |
| 630 return; | 630 return; |
| 631 } | 631 } |
| 632 agent_host->Inspect(web_ui()->GetWebContents()->GetBrowserContext()); | 632 agent_host->Inspect(web_ui()->GetWebContents()->GetBrowserContext()); |
| 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; |
| (...skipping 29 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 |