| 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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 | 401 |
| 402 ServiceWorkerDatabase::RegistrationData data; | 402 ServiceWorkerDatabase::RegistrationData data; |
| 403 data.registration_id = registration->id(); | 403 data.registration_id = registration->id(); |
| 404 data.scope = registration->pattern(); | 404 data.scope = registration->pattern(); |
| 405 data.script = version->script_url(); | 405 data.script = version->script_url(); |
| 406 data.has_fetch_handler = true; | 406 data.has_fetch_handler = true; |
| 407 data.version_id = version->version_id(); | 407 data.version_id = version->version_id(); |
| 408 data.last_update_check = registration->last_update_check(); | 408 data.last_update_check = registration->last_update_check(); |
| 409 data.is_active = (version == registration->active_version()); | 409 data.is_active = (version == registration->active_version()); |
| 410 data.max_age = version->max_age(); |
| 410 | 411 |
| 411 ResourceList resources; | 412 ResourceList resources; |
| 412 version->script_cache_map()->GetResources(&resources); | 413 version->script_cache_map()->GetResources(&resources); |
| 413 | 414 |
| 414 if (resources.empty()) { | 415 if (resources.empty()) { |
| 415 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); | 416 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); |
| 416 return; | 417 return; |
| 417 } | 418 } |
| 418 | 419 |
| 419 uint64 resources_total_size_bytes = 0; | 420 uint64 resources_total_size_bytes = 0; |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 registration->set_is_deleted(true); | 1212 registration->set_is_deleted(true); |
| 1212 } | 1213 } |
| 1213 scoped_refptr<ServiceWorkerVersion> version = | 1214 scoped_refptr<ServiceWorkerVersion> version = |
| 1214 context_->GetLiveVersion(data.version_id); | 1215 context_->GetLiveVersion(data.version_id); |
| 1215 if (!version) { | 1216 if (!version) { |
| 1216 version = new ServiceWorkerVersion( | 1217 version = new ServiceWorkerVersion( |
| 1217 registration.get(), data.script, data.version_id, context_); | 1218 registration.get(), data.script, data.version_id, context_); |
| 1218 version->SetStatus(data.is_active ? | 1219 version->SetStatus(data.is_active ? |
| 1219 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED); | 1220 ServiceWorkerVersion::ACTIVATED : ServiceWorkerVersion::INSTALLED); |
| 1220 version->script_cache_map()->SetResources(resources); | 1221 version->script_cache_map()->SetResources(resources); |
| 1222 version->set_max_age(data.max_age); |
| 1221 } | 1223 } |
| 1222 | 1224 |
| 1223 if (version->status() == ServiceWorkerVersion::ACTIVATED) | 1225 if (version->status() == ServiceWorkerVersion::ACTIVATED) |
| 1224 registration->SetActiveVersion(version); | 1226 registration->SetActiveVersion(version); |
| 1225 else if (version->status() == ServiceWorkerVersion::INSTALLED) | 1227 else if (version->status() == ServiceWorkerVersion::INSTALLED) |
| 1226 registration->SetWaitingVersion(version); | 1228 registration->SetWaitingVersion(version); |
| 1227 else | 1229 else |
| 1228 NOTREACHED(); | 1230 NOTREACHED(); |
| 1229 | 1231 |
| 1230 return registration; | 1232 return registration; |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1822 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
| 1821 return; | 1823 return; |
| 1822 } | 1824 } |
| 1823 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1825 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
| 1824 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( | 1826 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( |
| 1825 ServiceWorkerMetrics::DELETE_OK); | 1827 ServiceWorkerMetrics::DELETE_OK); |
| 1826 callback.Run(SERVICE_WORKER_OK); | 1828 callback.Run(SERVICE_WORKER_OK); |
| 1827 } | 1829 } |
| 1828 | 1830 |
| 1829 } // namespace content | 1831 } // namespace content |
| OLD | NEW |