| Index: content/browser/service_worker/service_worker_registration_handle.cc
|
| diff --git a/content/browser/service_worker/service_worker_registration_handle.cc b/content/browser/service_worker/service_worker_registration_handle.cc
|
| index b32f5a92b9fe3f3a70bbc72674c686eb612632dd..916a19ae52d9d8395db164af4a40ae1023f6c9ee 100644
|
| --- a/content/browser/service_worker/service_worker_registration_handle.cc
|
| +++ b/content/browser/service_worker/service_worker_registration_handle.cc
|
| @@ -45,6 +45,23 @@ ServiceWorkerRegistrationHandle::GetObjectInfo() {
|
| return info;
|
| }
|
|
|
| +ServiceWorkerObjectInfo
|
| +ServiceWorkerRegistrationHandle::CreateServiceWorkerHandleAndPass(
|
| + ServiceWorkerVersion* version) {
|
| + ServiceWorkerObjectInfo info;
|
| + if (context_ && version) {
|
| + scoped_ptr<ServiceWorkerHandle> handle =
|
| + ServiceWorkerHandle::Create(context_,
|
| + dispatcher_host_,
|
| + kDocumentMainThreadId,
|
| + provider_id_,
|
| + version);
|
| + info = handle->GetObjectInfo();
|
| + dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass());
|
| + }
|
| + return info;
|
| +}
|
| +
|
| void ServiceWorkerRegistrationHandle::IncrementRefCount() {
|
| DCHECK_GT(ref_count_, 0);
|
| ++ref_count_;
|
| @@ -71,6 +88,14 @@ void ServiceWorkerRegistrationHandle::OnRegistrationFailed(
|
| ClearVersionAttributes();
|
| }
|
|
|
| +void ServiceWorkerRegistrationHandle::OnUpdateFound(
|
| + ServiceWorkerRegistration* registration) {
|
| + if (!dispatcher_host_)
|
| + return; // Could be NULL in some tests.
|
| + dispatcher_host_->Send(new ServiceWorkerMsg_UpdateFound(
|
| + kDocumentMainThreadId, GetObjectInfo()));
|
| +}
|
| +
|
| void ServiceWorkerRegistrationHandle::SetVersionAttributes(
|
| ServiceWorkerVersion* installing_version,
|
| ServiceWorkerVersion* waiting_version,
|
| @@ -95,44 +120,21 @@ void ServiceWorkerRegistrationHandle::SetVersionAttributes(
|
| if (!mask.changed())
|
| return;
|
|
|
| - ServiceWorkerVersionAttributes attributes;
|
| - if (mask.installing_changed()) {
|
| - attributes.installing =
|
| - CreateServiceWorkerHandleAndPass(installing_version);
|
| - }
|
| - if (mask.waiting_changed()) {
|
| - attributes.waiting =
|
| - CreateServiceWorkerHandleAndPass(waiting_version);
|
| - }
|
| - if (mask.active_changed()) {
|
| - attributes.active =
|
| - CreateServiceWorkerHandleAndPass(active_version);
|
| - }
|
| + ServiceWorkerVersionAttributes attrs;
|
| + if (mask.installing_changed())
|
| + attrs.installing = CreateServiceWorkerHandleAndPass(installing_version);
|
| + if (mask.waiting_changed())
|
| + attrs.waiting = CreateServiceWorkerHandleAndPass(waiting_version);
|
| + if (mask.active_changed())
|
| + attrs.active = CreateServiceWorkerHandleAndPass(active_version);
|
| + attrs.changed_mask = mask.changed();
|
|
|
| dispatcher_host_->Send(new ServiceWorkerMsg_SetVersionAttributes(
|
| - kDocumentMainThreadId, provider_id_, handle_id_,
|
| - mask.changed(), attributes));
|
| + kDocumentMainThreadId, provider_id_, handle_id_, attrs));
|
| }
|
|
|
| void ServiceWorkerRegistrationHandle::ClearVersionAttributes() {
|
| SetVersionAttributes(NULL, NULL, NULL);
|
| }
|
|
|
| -ServiceWorkerObjectInfo
|
| -ServiceWorkerRegistrationHandle::CreateServiceWorkerHandleAndPass(
|
| - ServiceWorkerVersion* version) {
|
| - ServiceWorkerObjectInfo info;
|
| - if (context_ && version) {
|
| - scoped_ptr<ServiceWorkerHandle> handle =
|
| - ServiceWorkerHandle::Create(context_,
|
| - dispatcher_host_,
|
| - kDocumentMainThreadId,
|
| - provider_id_,
|
| - version);
|
| - info = handle->GetObjectInfo();
|
| - dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass());
|
| - }
|
| - return info;
|
| -}
|
| -
|
| } // namespace content
|
|
|