| 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 Status status = LazyOpen(true); | 515 Status status = LazyOpen(true); |
| 516 old_registration->version_id = kInvalidServiceWorkerVersionId; | 516 old_registration->version_id = kInvalidServiceWorkerVersionId; |
| 517 if (status != STATUS_OK) | 517 if (status != STATUS_OK) |
| 518 return status; | 518 return status; |
| 519 | 519 |
| 520 leveldb::WriteBatch batch; | 520 leveldb::WriteBatch batch; |
| 521 BumpNextRegistrationIdIfNeeded(registration.registration_id, &batch); | 521 BumpNextRegistrationIdIfNeeded(registration.registration_id, &batch); |
| 522 BumpNextVersionIdIfNeeded(registration.version_id, &batch); | 522 BumpNextVersionIdIfNeeded(registration.version_id, &batch); |
| 523 | 523 |
| 524 PutUniqueOriginToBatch(registration.scope.GetOrigin(), &batch); | 524 PutUniqueOriginToBatch(registration.scope.GetOrigin(), &batch); |
| 525 #if DCHECK_IS_ON | 525 #if !DCHECK_IS_OFF |
| 526 int64_t total_size_bytes = 0; | 526 int64_t total_size_bytes = 0; |
| 527 for (const auto& resource : resources) { | 527 for (const auto& resource : resources) { |
| 528 total_size_bytes += resource.size_bytes; | 528 total_size_bytes += resource.size_bytes; |
| 529 } | 529 } |
| 530 DCHECK_EQ(total_size_bytes, registration.resources_total_size_bytes) | 530 DCHECK_EQ(total_size_bytes, registration.resources_total_size_bytes) |
| 531 << "The total size in the registration must match the cumulative " | 531 << "The total size in the registration must match the cumulative " |
| 532 << "sizes of the resources."; | 532 << "sizes of the resources."; |
| 533 #endif | 533 #endif |
| 534 PutRegistrationDataToBatch(registration, &batch); | 534 PutRegistrationDataToBatch(registration, &batch); |
| 535 | 535 |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 | 1256 |
| 1257 void ServiceWorkerDatabase::HandleWriteResult( | 1257 void ServiceWorkerDatabase::HandleWriteResult( |
| 1258 const tracked_objects::Location& from_here, | 1258 const tracked_objects::Location& from_here, |
| 1259 Status status) { | 1259 Status status) { |
| 1260 if (status != STATUS_OK) | 1260 if (status != STATUS_OK) |
| 1261 Disable(from_here, status); | 1261 Disable(from_here, status); |
| 1262 ServiceWorkerMetrics::CountWriteDatabaseResult(status); | 1262 ServiceWorkerMetrics::CountWriteDatabaseResult(status); |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 } // namespace content | 1265 } // namespace content |
| OLD | NEW |