Index: content/browser/service_worker/service_worker_storage.cc |
diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc |
index f09127ee81457e61b4101b0c53a124e7d3b2fda7..d56de3108dd60ca28d66438d756740ec686f84d9 100644 |
--- a/content/browser/service_worker/service_worker_storage.cc |
+++ b/content/browser/service_worker/service_worker_storage.cc |
@@ -327,6 +327,22 @@ void ServiceWorkerStorage::FindRegistrationForPattern( |
weak_factory_.GetWeakPtr(), scope, callback))); |
} |
+scoped_refptr<ServiceWorkerRegistration> |
+ServiceWorkerStorage::GetUninstallingRegistration(const GURL& scope) { |
+ if (state_ != INITIALIZED || !context_) |
+ return NULL; |
+ for (RegistrationRefsById::const_iterator it = |
+ uninstalling_registrations_.begin(); |
+ it != uninstalling_registrations_.end(); |
+ ++it) { |
+ if (it->second->pattern() == scope) { |
+ DCHECK(it->second->is_uninstalling()); |
+ return it->second; |
+ } |
+ } |
+ return NULL; |
+} |
+ |
void ServiceWorkerStorage::FindRegistrationForId( |
int64 registration_id, |
const GURL& origin, |
@@ -418,7 +434,7 @@ void ServiceWorkerStorage::StoreRegistration( |
data.has_fetch_handler = true; |
data.version_id = version->version_id(); |
data.last_update_check = base::Time::Now(); |
- data.is_active = false; // initially stored in the waiting state |
+ data.is_active = (version == registration->active_version()); |
ResourceList resources; |
version->script_cache_map()->GetResources(&resources); |
@@ -435,6 +451,8 @@ void ServiceWorkerStorage::StoreRegistration( |
base::Bind(&ServiceWorkerStorage::DidStoreRegistration, |
weak_factory_.GetWeakPtr(), |
callback))); |
+ |
+ registration->set_is_deleted(false); |
} |
void ServiceWorkerStorage::UpdateToActiveState( |
@@ -492,7 +510,7 @@ void ServiceWorkerStorage::DeleteRegistration( |
ServiceWorkerRegistration* registration = |
context_->GetLiveRegistration(registration_id); |
if (registration) |
- registration->set_is_deleted(); |
+ registration->set_is_deleted(true); |
} |
scoped_ptr<ServiceWorkerResponseReader> |
@@ -606,6 +624,41 @@ void ServiceWorkerStorage::NotifyDoneInstallingRegistration( |
} |
} |
+void ServiceWorkerStorage::NotifyUninstallingRegistration( |
+ ServiceWorkerRegistration* registration) { |
michaeln
2014/08/12 02:15:36
maybe a DCHECK to assert that reg is not already b
falken
2014/08/12 09:06:06
Done. Also added to the other Notify* functions fo
|
+ uninstalling_registrations_[registration->id()] = registration; |
+ |
+ DeleteRegistration(registration->id(), |
michaeln
2014/08/12 02:15:36
I was wondering where this method call went and wa
|
+ registration->script_url().GetOrigin(), |
+ base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
+} |
+ |
+void ServiceWorkerStorage::NotifyAbortedUninstallingRegistration( |
+ ServiceWorkerRegistration* registration) { |
+ uninstalling_registrations_.erase(registration->id()); |
+ installing_registrations_[registration->id()] = registration; |
michaeln
2014/08/12 02:15:36
should this be a call to NotifyInstallingRegistrat
falken
2014/08/12 09:06:06
Done. I decided for symmetry to make SWRegistratio
|
+ |
+ if (registration->waiting_version()) { |
+ StoreRegistration(registration, |
+ registration->waiting_version(), |
+ base::Bind(&ServiceWorkerStorage::DidRestoreRegistration, |
+ weak_factory_.GetWeakPtr(), |
+ registration->id())); |
+ } else if (registration->active_version()) { |
+ StoreRegistration(registration, |
+ registration->active_version(), |
+ base::Bind(&ServiceWorkerStorage::DidRestoreRegistration, |
+ weak_factory_.GetWeakPtr(), |
+ registration->id())); |
+ } |
+ registration->set_is_deleted(false); |
+} |
+ |
+void ServiceWorkerStorage::NotifyUninstalledRegistration( |
+ ServiceWorkerRegistration* registration) { |
+ uninstalling_registrations_.erase(registration->id()); |
+} |
+ |
void ServiceWorkerStorage::Disable() { |
state_ = DISABLED; |
if (disk_cache_) |
@@ -881,6 +934,13 @@ void ServiceWorkerStorage::DidStoreRegistration( |
StartPurgingResources(newly_purgeable_resources); |
} |
+void ServiceWorkerStorage::DidRestoreRegistration( |
+ int64 registration_id, |
+ ServiceWorkerStatusCode status) { |
+ if (status == SERVICE_WORKER_OK) |
+ installing_registrations_.erase(registration_id); |
michaeln
2014/08/12 02:15:36
And this be a call to NotifyDoneInstallingRegistr
falken
2014/08/12 09:06:06
My idea actually was to leave it in the map, that
|
+} |
+ |
void ServiceWorkerStorage::DidUpdateToActiveState( |
const StatusCallback& callback, |
ServiceWorkerDatabase::Status status) { |
@@ -924,7 +984,7 @@ ServiceWorkerStorage::GetOrCreateRegistration( |
data.scope, data.script, data.registration_id, context_); |
if (pending_deletions_.find(data.registration_id) != |
pending_deletions_.end()) { |
- registration->set_is_deleted(); |
+ registration->set_is_deleted(true); |
} |
scoped_refptr<ServiceWorkerVersion> version = |
context_->GetLiveVersion(data.version_id); |