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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); | 399 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); |
400 return; | 400 return; |
401 } | 401 } |
402 | 402 |
403 DCHECK_NE(version->fetch_handler_existence(), | 403 DCHECK_NE(version->fetch_handler_existence(), |
404 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN); | 404 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN); |
405 | 405 |
406 ServiceWorkerDatabase::RegistrationData data; | 406 ServiceWorkerDatabase::RegistrationData data; |
407 data.registration_id = registration->id(); | 407 data.registration_id = registration->id(); |
408 data.scope = registration->pattern(); | 408 data.scope = registration->pattern(); |
| 409 data.use_cache = registration->use_cache(); |
409 data.script = version->script_url(); | 410 data.script = version->script_url(); |
410 data.has_fetch_handler = version->fetch_handler_existence() == | 411 data.has_fetch_handler = version->fetch_handler_existence() == |
411 ServiceWorkerVersion::FetchHandlerExistence::EXISTS; | 412 ServiceWorkerVersion::FetchHandlerExistence::EXISTS; |
412 data.version_id = version->version_id(); | 413 data.version_id = version->version_id(); |
413 data.last_update_check = registration->last_update_check(); | 414 data.last_update_check = registration->last_update_check(); |
414 data.is_active = (version == registration->active_version()); | 415 data.is_active = (version == registration->active_version()); |
415 data.foreign_fetch_scopes = version->foreign_fetch_scopes(); | 416 data.foreign_fetch_scopes = version->foreign_fetch_scopes(); |
416 data.foreign_fetch_origins = version->foreign_fetch_origins(); | 417 data.foreign_fetch_origins = version->foreign_fetch_origins(); |
417 if (version->origin_trial_tokens()) | 418 if (version->origin_trial_tokens()) |
418 data.origin_trial_tokens = *version->origin_trial_tokens(); | 419 data.origin_trial_tokens = *version->origin_trial_tokens(); |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 | 1106 |
1106 ServiceWorkerRegistration* registration = | 1107 ServiceWorkerRegistration* registration = |
1107 context_->GetLiveRegistration(registration_data.registration_id); | 1108 context_->GetLiveRegistration(registration_data.registration_id); |
1108 if (registration) { | 1109 if (registration) { |
1109 infos.push_back(registration->GetInfo()); | 1110 infos.push_back(registration->GetInfo()); |
1110 continue; | 1111 continue; |
1111 } | 1112 } |
1112 | 1113 |
1113 ServiceWorkerRegistrationInfo info; | 1114 ServiceWorkerRegistrationInfo info; |
1114 info.pattern = registration_data.scope; | 1115 info.pattern = registration_data.scope; |
| 1116 info.use_cache = registration_data.use_cache; |
1115 info.registration_id = registration_data.registration_id; | 1117 info.registration_id = registration_data.registration_id; |
1116 info.stored_version_size_bytes = | 1118 info.stored_version_size_bytes = |
1117 registration_data.resources_total_size_bytes; | 1119 registration_data.resources_total_size_bytes; |
1118 if (ServiceWorkerVersion* version = | 1120 if (ServiceWorkerVersion* version = |
1119 context_->GetLiveVersion(registration_data.version_id)) { | 1121 context_->GetLiveVersion(registration_data.version_id)) { |
1120 if (registration_data.is_active) | 1122 if (registration_data.is_active) |
1121 info.active_version = version->GetInfo(); | 1123 info.active_version = version->GetInfo(); |
1122 else | 1124 else |
1123 info.waiting_version = version->GetInfo(); | 1125 info.waiting_version = version->GetInfo(); |
1124 infos.push_back(info); | 1126 infos.push_back(info); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 | 1296 |
1295 scoped_refptr<ServiceWorkerRegistration> | 1297 scoped_refptr<ServiceWorkerRegistration> |
1296 ServiceWorkerStorage::GetOrCreateRegistration( | 1298 ServiceWorkerStorage::GetOrCreateRegistration( |
1297 const ServiceWorkerDatabase::RegistrationData& data, | 1299 const ServiceWorkerDatabase::RegistrationData& data, |
1298 const ResourceList& resources) { | 1300 const ResourceList& resources) { |
1299 scoped_refptr<ServiceWorkerRegistration> registration = | 1301 scoped_refptr<ServiceWorkerRegistration> registration = |
1300 context_->GetLiveRegistration(data.registration_id); | 1302 context_->GetLiveRegistration(data.registration_id); |
1301 if (registration) | 1303 if (registration) |
1302 return registration; | 1304 return registration; |
1303 | 1305 |
1304 registration = new ServiceWorkerRegistration( | 1306 registration = new ServiceWorkerRegistration(data.scope, data.use_cache, |
1305 data.scope, data.registration_id, context_); | 1307 data.registration_id, context_); |
1306 registration->set_resources_total_size_bytes(data.resources_total_size_bytes); | 1308 registration->set_resources_total_size_bytes(data.resources_total_size_bytes); |
1307 registration->set_last_update_check(data.last_update_check); | 1309 registration->set_last_update_check(data.last_update_check); |
1308 if (pending_deletions_.find(data.registration_id) != | 1310 if (pending_deletions_.find(data.registration_id) != |
1309 pending_deletions_.end()) { | 1311 pending_deletions_.end()) { |
1310 registration->set_is_deleted(true); | 1312 registration->set_is_deleted(true); |
1311 } | 1313 } |
1312 scoped_refptr<ServiceWorkerVersion> version = | 1314 scoped_refptr<ServiceWorkerVersion> version = |
1313 context_->GetLiveVersion(data.version_id); | 1315 context_->GetLiveVersion(data.version_id); |
1314 if (!version) { | 1316 if (!version) { |
1315 version = new ServiceWorkerVersion( | 1317 version = new ServiceWorkerVersion( |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1852 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
1851 return; | 1853 return; |
1852 } | 1854 } |
1853 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1855 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
1854 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( | 1856 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( |
1855 ServiceWorkerMetrics::DELETE_OK); | 1857 ServiceWorkerMetrics::DELETE_OK); |
1856 callback.Run(SERVICE_WORKER_OK); | 1858 callback.Run(SERVICE_WORKER_OK); |
1857 } | 1859 } |
1858 | 1860 |
1859 } // namespace content | 1861 } // namespace content |
OLD | NEW |