Chromium Code Reviews| 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 data.scope = registration->pattern(); | 532 data.scope = registration->pattern(); |
| 533 data.script = version->script_url(); | 533 data.script = version->script_url(); |
| 534 data.has_fetch_handler = true; | 534 data.has_fetch_handler = true; |
| 535 data.version_id = version->version_id(); | 535 data.version_id = version->version_id(); |
| 536 data.last_update_check = registration->last_update_check(); | 536 data.last_update_check = registration->last_update_check(); |
| 537 data.is_active = (version == registration->active_version()); | 537 data.is_active = (version == registration->active_version()); |
| 538 | 538 |
| 539 ResourceList resources; | 539 ResourceList resources; |
| 540 version->script_cache_map()->GetResources(&resources); | 540 version->script_cache_map()->GetResources(&resources); |
| 541 | 541 |
| 542 if (resources.empty()) { | |
|
michaeln
2015/05/14 03:27:59
thnx!
| |
| 543 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); | |
| 544 return; | |
| 545 } | |
| 546 | |
| 542 uint64 resources_total_size_bytes = 0; | 547 uint64 resources_total_size_bytes = 0; |
| 543 for (const auto& resource : resources) { | 548 for (const auto& resource : resources) { |
| 544 resources_total_size_bytes += resource.size_bytes; | 549 resources_total_size_bytes += resource.size_bytes; |
| 545 } | 550 } |
| 546 data.resources_total_size_bytes = resources_total_size_bytes; | 551 data.resources_total_size_bytes = resources_total_size_bytes; |
| 547 | 552 |
| 548 if (!has_checked_for_stale_resources_) | 553 if (!has_checked_for_stale_resources_) |
| 549 DeleteStaleResources(); | 554 DeleteStaleResources(); |
| 550 | 555 |
| 551 database_task_manager_->GetTaskRunner()->PostTask( | 556 database_task_manager_->GetTaskRunner()->PostTask( |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1087 | 1092 |
| 1088 ScheduleDeleteAndStartOver(); | 1093 ScheduleDeleteAndStartOver(); |
| 1089 callback.Run(DatabaseStatusToStatusCode(status), | 1094 callback.Run(DatabaseStatusToStatusCode(status), |
| 1090 scoped_refptr<ServiceWorkerRegistration>()); | 1095 scoped_refptr<ServiceWorkerRegistration>()); |
| 1091 } | 1096 } |
| 1092 | 1097 |
| 1093 void ServiceWorkerStorage::ReturnFoundRegistration( | 1098 void ServiceWorkerStorage::ReturnFoundRegistration( |
| 1094 const FindRegistrationCallback& callback, | 1099 const FindRegistrationCallback& callback, |
| 1095 const ServiceWorkerDatabase::RegistrationData& data, | 1100 const ServiceWorkerDatabase::RegistrationData& data, |
| 1096 const ResourceList& resources) { | 1101 const ResourceList& resources) { |
| 1102 if (resources.empty()) { | |
|
michaeln
2015/05/14 03:27:59
Is this code reachable with your changes to servic
horo
2015/05/14 03:46:50
Ah, yes.
It should be DCHECK(!resources.empty());
| |
| 1103 ScheduleDeleteAndStartOver(); | |
| 1104 callback.Run(SERVICE_WORKER_ERROR_FAILED, | |
| 1105 scoped_refptr<ServiceWorkerRegistration>()); | |
| 1106 return; | |
| 1107 } | |
| 1097 scoped_refptr<ServiceWorkerRegistration> registration = | 1108 scoped_refptr<ServiceWorkerRegistration> registration = |
| 1098 GetOrCreateRegistration(data, resources); | 1109 GetOrCreateRegistration(data, resources); |
| 1099 CompleteFindNow(registration, SERVICE_WORKER_OK, callback); | 1110 CompleteFindNow(registration, SERVICE_WORKER_OK, callback); |
| 1100 } | 1111 } |
| 1101 | 1112 |
| 1102 void ServiceWorkerStorage::DidGetRegistrations( | 1113 void ServiceWorkerStorage::DidGetRegistrations( |
| 1103 const GetRegistrationsInfosCallback& callback, | 1114 const GetRegistrationsInfosCallback& callback, |
| 1104 RegistrationList* registrations, | 1115 RegistrationList* registrations, |
| 1105 const GURL& origin_filter, | 1116 const GURL& origin_filter, |
| 1106 ServiceWorkerDatabase::Status status) { | 1117 ServiceWorkerDatabase::Status status) { |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1807 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1818 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
| 1808 return; | 1819 return; |
| 1809 } | 1820 } |
| 1810 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1821 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
| 1811 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( | 1822 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( |
| 1812 ServiceWorkerMetrics::DELETE_OK); | 1823 ServiceWorkerMetrics::DELETE_OK); |
| 1813 callback.Run(SERVICE_WORKER_OK); | 1824 callback.Run(SERVICE_WORKER_OK); |
| 1814 } | 1825 } |
| 1815 | 1826 |
| 1816 } // namespace content | 1827 } // namespace content |
| OLD | NEW |