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.update_via_cache = registration->update_via_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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 | 1174 |
1174 ServiceWorkerRegistration* registration = | 1175 ServiceWorkerRegistration* registration = |
1175 context_->GetLiveRegistration(registration_data.registration_id); | 1176 context_->GetLiveRegistration(registration_data.registration_id); |
1176 if (registration) { | 1177 if (registration) { |
1177 infos.push_back(registration->GetInfo()); | 1178 infos.push_back(registration->GetInfo()); |
1178 continue; | 1179 continue; |
1179 } | 1180 } |
1180 | 1181 |
1181 ServiceWorkerRegistrationInfo info; | 1182 ServiceWorkerRegistrationInfo info; |
1182 info.pattern = registration_data.scope; | 1183 info.pattern = registration_data.scope; |
| 1184 info.update_via_cache = registration_data.update_via_cache; |
1183 info.registration_id = registration_data.registration_id; | 1185 info.registration_id = registration_data.registration_id; |
1184 info.stored_version_size_bytes = | 1186 info.stored_version_size_bytes = |
1185 registration_data.resources_total_size_bytes; | 1187 registration_data.resources_total_size_bytes; |
1186 if (ServiceWorkerVersion* version = | 1188 if (ServiceWorkerVersion* version = |
1187 context_->GetLiveVersion(registration_data.version_id)) { | 1189 context_->GetLiveVersion(registration_data.version_id)) { |
1188 if (registration_data.is_active) | 1190 if (registration_data.is_active) |
1189 info.active_version = version->GetInfo(); | 1191 info.active_version = version->GetInfo(); |
1190 else | 1192 else |
1191 info.waiting_version = version->GetInfo(); | 1193 info.waiting_version = version->GetInfo(); |
1192 infos.push_back(info); | 1194 infos.push_back(info); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 scoped_refptr<ServiceWorkerRegistration> | 1365 scoped_refptr<ServiceWorkerRegistration> |
1364 ServiceWorkerStorage::GetOrCreateRegistration( | 1366 ServiceWorkerStorage::GetOrCreateRegistration( |
1365 const ServiceWorkerDatabase::RegistrationData& data, | 1367 const ServiceWorkerDatabase::RegistrationData& data, |
1366 const ResourceList& resources) { | 1368 const ResourceList& resources) { |
1367 scoped_refptr<ServiceWorkerRegistration> registration = | 1369 scoped_refptr<ServiceWorkerRegistration> registration = |
1368 context_->GetLiveRegistration(data.registration_id); | 1370 context_->GetLiveRegistration(data.registration_id); |
1369 if (registration) | 1371 if (registration) |
1370 return registration; | 1372 return registration; |
1371 | 1373 |
1372 registration = new ServiceWorkerRegistration( | 1374 registration = new ServiceWorkerRegistration( |
1373 ServiceWorkerRegistrationOptions(data.scope), data.registration_id, | 1375 ServiceWorkerRegistrationOptions(data.scope, data.update_via_cache), |
1374 context_); | 1376 data.registration_id, context_); |
1375 registration->set_resources_total_size_bytes(data.resources_total_size_bytes); | 1377 registration->set_resources_total_size_bytes(data.resources_total_size_bytes); |
1376 registration->set_last_update_check(data.last_update_check); | 1378 registration->set_last_update_check(data.last_update_check); |
1377 if (pending_deletions_.find(data.registration_id) != | 1379 if (pending_deletions_.find(data.registration_id) != |
1378 pending_deletions_.end()) { | 1380 pending_deletions_.end()) { |
1379 registration->set_is_deleted(true); | 1381 registration->set_is_deleted(true); |
1380 } | 1382 } |
1381 scoped_refptr<ServiceWorkerVersion> version = | 1383 scoped_refptr<ServiceWorkerVersion> version = |
1382 context_->GetLiveVersion(data.version_id); | 1384 context_->GetLiveVersion(data.version_id); |
1383 if (!version) { | 1385 if (!version) { |
1384 version = new ServiceWorkerVersion( | 1386 version = new ServiceWorkerVersion( |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1947 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
1946 return; | 1948 return; |
1947 } | 1949 } |
1948 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1950 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
1949 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( | 1951 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( |
1950 ServiceWorkerMetrics::DELETE_OK); | 1952 ServiceWorkerMetrics::DELETE_OK); |
1951 callback.Run(SERVICE_WORKER_OK); | 1953 callback.Run(SERVICE_WORKER_OK); |
1952 } | 1954 } |
1953 | 1955 |
1954 } // namespace content | 1956 } // namespace content |
OLD | NEW |