Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: content/browser/service_worker/service_worker_database.cc

Issue 1135743002: Check the size of ResourceRecords in ServiceWorkerDatabase::ReadRegistration() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 523
524 RegistrationData value; 524 RegistrationData value;
525 status = ReadRegistrationData(registration_id, origin, &value); 525 status = ReadRegistrationData(registration_id, origin, &value);
526 if (status != STATUS_OK) 526 if (status != STATUS_OK)
527 return status; 527 return status;
528 528
529 status = ReadResourceRecords(value.version_id, resources); 529 status = ReadResourceRecords(value.version_id, resources);
530 if (status != STATUS_OK) 530 if (status != STATUS_OK)
531 return status; 531 return status;
532 532
533 if (!resources->size())
nhiroki 2015/05/08 08:14:42 empty()?
nhiroki 2015/05/08 08:19:00 It would be better to add a comment about why this
horo 2015/05/08 08:22:31 Done.
534 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
535
533 *registration = value; 536 *registration = value;
534 return STATUS_OK; 537 return STATUS_OK;
535 } 538 }
536 539
537 ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistrationOrigin( 540 ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistrationOrigin(
538 int64 registration_id, 541 int64 registration_id,
539 GURL* origin) { 542 GURL* origin) {
540 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 543 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
541 DCHECK(origin); 544 DCHECK(origin);
542 545
(...skipping 23 matching lines...) Expand all
566 *origin = parsed; 569 *origin = parsed;
567 HandleReadResult(FROM_HERE, STATUS_OK); 570 HandleReadResult(FROM_HERE, STATUS_OK);
568 return STATUS_OK; 571 return STATUS_OK;
569 } 572 }
570 573
571 ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteRegistration( 574 ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteRegistration(
572 const RegistrationData& registration, 575 const RegistrationData& registration,
573 const std::vector<ResourceRecord>& resources, 576 const std::vector<ResourceRecord>& resources,
574 RegistrationData* old_registration, 577 RegistrationData* old_registration,
575 std::vector<int64>* newly_purgeable_resources) { 578 std::vector<int64>* newly_purgeable_resources) {
576 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 579 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
nhiroki 2015/05/08 08:14:42 How about adding DCHECK(!resources.empty()) here?
horo 2015/05/08 08:22:31 Done.
577 DCHECK(old_registration); 580 DCHECK(old_registration);
578 Status status = LazyOpen(true); 581 Status status = LazyOpen(true);
579 old_registration->version_id = kInvalidServiceWorkerVersionId; 582 old_registration->version_id = kInvalidServiceWorkerVersionId;
580 if (status != STATUS_OK) 583 if (status != STATUS_OK)
581 return status; 584 return status;
582 585
583 leveldb::WriteBatch batch; 586 leveldb::WriteBatch batch;
584 BumpNextRegistrationIdIfNeeded(registration.registration_id, &batch); 587 BumpNextRegistrationIdIfNeeded(registration.registration_id, &batch);
585 BumpNextVersionIdIfNeeded(registration.version_id, &batch); 588 BumpNextVersionIdIfNeeded(registration.version_id, &batch);
586 589
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 1450
1448 void ServiceWorkerDatabase::HandleWriteResult( 1451 void ServiceWorkerDatabase::HandleWriteResult(
1449 const tracked_objects::Location& from_here, 1452 const tracked_objects::Location& from_here,
1450 Status status) { 1453 Status status) {
1451 if (status != STATUS_OK) 1454 if (status != STATUS_OK)
1452 Disable(from_here, status); 1455 Disable(from_here, status);
1453 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1456 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1454 } 1457 }
1455 1458
1456 } // namespace content 1459 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698