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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 data.scope = registration->pattern(); | 458 data.scope = registration->pattern(); |
459 data.script = version->script_url(); | 459 data.script = version->script_url(); |
460 data.has_fetch_handler = true; | 460 data.has_fetch_handler = true; |
461 data.version_id = version->version_id(); | 461 data.version_id = version->version_id(); |
462 data.last_update_check = registration->last_update_check(); | 462 data.last_update_check = registration->last_update_check(); |
463 data.is_active = (version == registration->active_version()); | 463 data.is_active = (version == registration->active_version()); |
464 | 464 |
465 ResourceList resources; | 465 ResourceList resources; |
466 version->script_cache_map()->GetResources(&resources); | 466 version->script_cache_map()->GetResources(&resources); |
467 | 467 |
| 468 uint64 resources_total_size_bytes = 0; |
| 469 for (const auto& resource : resources) { |
| 470 resources_total_size_bytes += resource.size_bytes; |
| 471 } |
| 472 data.resources_total_size_bytes = resources_total_size_bytes; |
| 473 |
468 if (!has_checked_for_stale_resources_) | 474 if (!has_checked_for_stale_resources_) |
469 DeleteStaleResources(); | 475 DeleteStaleResources(); |
470 | 476 |
471 database_task_manager_->GetTaskRunner()->PostTask( | 477 database_task_manager_->GetTaskRunner()->PostTask( |
472 FROM_HERE, | 478 FROM_HERE, |
473 base::Bind(&WriteRegistrationInDB, | 479 base::Bind(&WriteRegistrationInDB, |
474 database_.get(), | 480 database_.get(), |
475 base::MessageLoopProxy::current(), | 481 base::MessageLoopProxy::current(), |
476 data, resources, | 482 data, resources, |
477 base::Bind(&ServiceWorkerStorage::DidStoreRegistration, | 483 base::Bind(&ServiceWorkerStorage::DidStoreRegistration, |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 // Give up the corruption recovery until the browser restarts. | 1485 // Give up the corruption recovery until the browser restarts. |
1480 LOG(ERROR) << "Failed to delete the diskcache."; | 1486 LOG(ERROR) << "Failed to delete the diskcache."; |
1481 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1487 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
1482 return; | 1488 return; |
1483 } | 1489 } |
1484 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1490 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
1485 callback.Run(SERVICE_WORKER_OK); | 1491 callback.Run(SERVICE_WORKER_OK); |
1486 } | 1492 } |
1487 | 1493 |
1488 } // namespace content | 1494 } // namespace content |
OLD | NEW |