| Index: content/browser/service_worker/service_worker_context_wrapper.cc
|
| diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc
|
| index db0b4e9fffe6c94a3dcb2da3194f3e4629a666a8..d66de442b90217708d9689b54e2547cf38f18bee 100644
|
| --- a/content/browser/service_worker/service_worker_context_wrapper.cc
|
| +++ b/content/browser/service_worker/service_worker_context_wrapper.cc
|
| @@ -21,11 +21,13 @@
|
| #include "content/browser/service_worker/service_worker_process_manager.h"
|
| #include "content/browser/service_worker/service_worker_quota_client.h"
|
| #include "content/browser/service_worker/service_worker_request_handler.h"
|
| +#include "content/browser/service_worker/service_worker_utils.h"
|
| #include "content/browser/storage_partition_impl.h"
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/service_worker_context.h"
|
| #include "net/base/net_errors.h"
|
| +#include "net/base/net_util.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
| #include "storage/browser/blob/blob_storage_context.h"
|
| #include "storage/browser/quota/quota_manager_proxy.h"
|
| @@ -278,6 +280,27 @@ void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins(
|
| callback.Run(usage_infos);
|
| }
|
|
|
| +void ServiceWorkerContextWrapper::DidFindRegistrationForCheckHasServiceWorker(
|
| + const GURL& other_url,
|
| + const CheckHasServiceWorkerCallback& callback,
|
| + ServiceWorkerStatusCode status,
|
| + const scoped_refptr<ServiceWorkerRegistration>& registration) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| +
|
| + if (status != SERVICE_WORKER_OK) {
|
| + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| + base::Bind(callback, false));
|
| + return;
|
| + }
|
| +
|
| + DCHECK(registration);
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE,
|
| + base::Bind(callback, registration->active_version() &&
|
| + ServiceWorkerUtils::ScopeMatches(
|
| + registration->pattern(), other_url)));
|
| +}
|
| +
|
| namespace {
|
| void StatusCodeToBoolCallbackAdapter(
|
| const ServiceWorkerContext::ResultCallback& callback,
|
| @@ -309,6 +332,30 @@ void ServiceWorkerContextWrapper::DeleteForOrigin(const GURL& origin_url) {
|
| DeleteForOrigin(origin_url, base::Bind(&EmptySuccessCallback));
|
| }
|
|
|
| +void ServiceWorkerContextWrapper::CheckHasServiceWorker(
|
| + const GURL& url,
|
| + const GURL& other_url,
|
| + const CheckHasServiceWorkerCallback& callback) {
|
| + if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&ServiceWorkerContextWrapper::CheckHasServiceWorker, this,
|
| + url, other_url, callback));
|
| + return;
|
| + }
|
| + if (!context_core_.get()) {
|
| + LOG(ERROR) << "ServiceWorkerContextCore is no longer alive.";
|
| + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
| + base::Bind(callback, false));
|
| + return;
|
| + }
|
| + GURL stripped_url = net::SimplifyUrlForRequest(url);
|
| + context()->storage()->FindRegistrationForDocument(
|
| + stripped_url, base::Bind(&ServiceWorkerContextWrapper::
|
| + DidFindRegistrationForCheckHasServiceWorker,
|
| + this, other_url, callback));
|
| +}
|
| +
|
| void ServiceWorkerContextWrapper::AddObserver(
|
| ServiceWorkerContextObserver* observer) {
|
| observer_list_->AddObserver(observer);
|
|
|