OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_database.h" | 5 #include "content/browser/service_worker/service_worker_database.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 Status status = LazyOpen(true); | 531 Status status = LazyOpen(true); |
532 old_registration->version_id = kInvalidServiceWorkerVersionId; | 532 old_registration->version_id = kInvalidServiceWorkerVersionId; |
533 if (status != STATUS_OK) | 533 if (status != STATUS_OK) |
534 return status; | 534 return status; |
535 | 535 |
536 leveldb::WriteBatch batch; | 536 leveldb::WriteBatch batch; |
537 BumpNextRegistrationIdIfNeeded(registration.registration_id, &batch); | 537 BumpNextRegistrationIdIfNeeded(registration.registration_id, &batch); |
538 BumpNextVersionIdIfNeeded(registration.version_id, &batch); | 538 BumpNextVersionIdIfNeeded(registration.version_id, &batch); |
539 | 539 |
540 PutUniqueOriginToBatch(registration.scope.GetOrigin(), &batch); | 540 PutUniqueOriginToBatch(registration.scope.GetOrigin(), &batch); |
541 #if DCHECK_IS_ON | 541 #if DCHECK_IS_ON() |
542 int64_t total_size_bytes = 0; | 542 int64_t total_size_bytes = 0; |
543 for (const auto& resource : resources) { | 543 for (const auto& resource : resources) { |
544 total_size_bytes += resource.size_bytes; | 544 total_size_bytes += resource.size_bytes; |
545 } | 545 } |
546 DCHECK_EQ(total_size_bytes, registration.resources_total_size_bytes) | 546 DCHECK_EQ(total_size_bytes, registration.resources_total_size_bytes) |
547 << "The total size in the registration must match the cumulative " | 547 << "The total size in the registration must match the cumulative " |
548 << "sizes of the resources."; | 548 << "sizes of the resources."; |
549 #endif | 549 #endif |
550 PutRegistrationDataToBatch(registration, &batch); | 550 PutRegistrationDataToBatch(registration, &batch); |
551 | 551 |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 | 1329 |
1330 void ServiceWorkerDatabase::HandleWriteResult( | 1330 void ServiceWorkerDatabase::HandleWriteResult( |
1331 const tracked_objects::Location& from_here, | 1331 const tracked_objects::Location& from_here, |
1332 Status status) { | 1332 Status status) { |
1333 if (status != STATUS_OK) | 1333 if (status != STATUS_OK) |
1334 Disable(from_here, status); | 1334 Disable(from_here, status); |
1335 ServiceWorkerMetrics::CountWriteDatabaseResult(status); | 1335 ServiceWorkerMetrics::CountWriteDatabaseResult(status); |
1336 } | 1336 } |
1337 | 1337 |
1338 } // namespace content | 1338 } // namespace content |
OLD | NEW |