| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_storage.h" | 5 #include "content/browser/service_worker/service_worker_storage.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 ServiceWorkerStorage::CreateRegistration( | 702 ServiceWorkerStorage::CreateRegistration( |
| 703 const ServiceWorkerDatabase::RegistrationData& data) { | 703 const ServiceWorkerDatabase::RegistrationData& data) { |
| 704 scoped_refptr<ServiceWorkerRegistration> registration( | 704 scoped_refptr<ServiceWorkerRegistration> registration( |
| 705 new ServiceWorkerRegistration( | 705 new ServiceWorkerRegistration( |
| 706 data.scope, data.script, data.registration_id, context_)); | 706 data.scope, data.script, data.registration_id, context_)); |
| 707 | 707 |
| 708 scoped_refptr<ServiceWorkerVersion> version = | 708 scoped_refptr<ServiceWorkerVersion> version = |
| 709 context_->GetLiveVersion(data.version_id); | 709 context_->GetLiveVersion(data.version_id); |
| 710 if (!version) { | 710 if (!version) { |
| 711 version = new ServiceWorkerVersion(registration, data.version_id, context_); | 711 version = new ServiceWorkerVersion(registration, data.version_id, context_); |
| 712 version->SetStatus(data.GetVersionStatus()); | 712 version->SetStatus(data.is_active ? |
| 713 ServiceWorkerVersion::ACTIVE : ServiceWorkerVersion::INSTALLED); |
| 713 } | 714 } |
| 714 | 715 |
| 715 if (version->status() == ServiceWorkerVersion::ACTIVE) | 716 if (version->status() == ServiceWorkerVersion::ACTIVE) |
| 716 registration->set_active_version(version); | 717 registration->set_active_version(version); |
| 717 else if (version->status() == ServiceWorkerVersion::INSTALLED) | 718 else if (version->status() == ServiceWorkerVersion::INSTALLED) |
| 718 registration->set_pending_version(version); | 719 registration->set_pending_version(version); |
| 719 else | 720 else |
| 720 NOTREACHED(); | 721 NOTREACHED(); |
| 721 // TODO(michaeln): Hmmm, what if DeleteReg was invoked after | 722 // TODO(michaeln): Hmmm, what if DeleteReg was invoked after |
| 722 // the Find result we're returning here? NOTREACHED condition? | 723 // the Find result we're returning here? NOTREACHED condition? |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 // TODO(michaeln): Store data on disk and do error checking. | 771 // TODO(michaeln): Store data on disk and do error checking. |
| 771 disk_cache_.reset(new ServiceWorkerDiskCache); | 772 disk_cache_.reset(new ServiceWorkerDiskCache); |
| 772 int rv = disk_cache_->InitWithMemBackend( | 773 int rv = disk_cache_->InitWithMemBackend( |
| 773 kMaxMemDiskCacheSize, | 774 kMaxMemDiskCacheSize, |
| 774 base::Bind(&EmptyCompletionCallback)); | 775 base::Bind(&EmptyCompletionCallback)); |
| 775 DCHECK_EQ(net::OK, rv); | 776 DCHECK_EQ(net::OK, rv); |
| 776 return disk_cache_.get(); | 777 return disk_cache_.get(); |
| 777 } | 778 } |
| 778 | 779 |
| 779 } // namespace content | 780 } // namespace content |
| OLD | NEW |