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

Side by Side Diff: content/browser/appcache/appcache_storage_impl.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/appcache/appcache_storage_impl.h" 5 #include "content/browser/appcache/appcache_storage_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <limits>
9 #include <set> 10 #include <set>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
14 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/profiler/scoped_tracker.h" 18 #include "base/profiler/scoped_tracker.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
(...skipping 24 matching lines...) Expand all
43 static const int kDefaultQuota = 5 * 1024 * 1024; 44 static const int kDefaultQuota = 5 * 1024 * 1024;
44 45
45 static const int kMaxDiskCacheSize = 250 * 1024 * 1024; 46 static const int kMaxDiskCacheSize = 250 * 1024 * 1024;
46 static const int kMaxMemDiskCacheSize = 10 * 1024 * 1024; 47 static const int kMaxMemDiskCacheSize = 10 * 1024 * 1024;
47 static const base::FilePath::CharType kDiskCacheDirectoryName[] = 48 static const base::FilePath::CharType kDiskCacheDirectoryName[] =
48 FILE_PATH_LITERAL("Cache"); 49 FILE_PATH_LITERAL("Cache");
49 50
50 namespace { 51 namespace {
51 52
52 // Helpers for clearing data from the AppCacheDatabase. 53 // Helpers for clearing data from the AppCacheDatabase.
53 bool DeleteGroupAndRelatedRecords(AppCacheDatabase* database, 54 bool DeleteGroupAndRelatedRecords(
54 int64 group_id, 55 AppCacheDatabase* database,
55 std::vector<int64>* deletable_response_ids) { 56 int64_t group_id,
57 std::vector<int64_t>* deletable_response_ids) {
56 AppCacheDatabase::CacheRecord cache_record; 58 AppCacheDatabase::CacheRecord cache_record;
57 bool success = false; 59 bool success = false;
58 if (database->FindCacheForGroup(group_id, &cache_record)) { 60 if (database->FindCacheForGroup(group_id, &cache_record)) {
59 database->FindResponseIdsForCacheAsVector(cache_record.cache_id, 61 database->FindResponseIdsForCacheAsVector(cache_record.cache_id,
60 deletable_response_ids); 62 deletable_response_ids);
61 success = 63 success =
62 database->DeleteGroup(group_id) && 64 database->DeleteGroup(group_id) &&
63 database->DeleteCache(cache_record.cache_id) && 65 database->DeleteCache(cache_record.cache_id) &&
64 database->DeleteEntriesForCache(cache_record.cache_id) && 66 database->DeleteEntriesForCache(cache_record.cache_id) &&
65 database->DeleteNamespacesForCache(cache_record.cache_id) && 67 database->DeleteNamespacesForCache(cache_record.cache_id) &&
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 115
114 std::vector<AppCacheDatabase::GroupRecord> groups; 116 std::vector<AppCacheDatabase::GroupRecord> groups;
115 database->FindGroupsForOrigin(*origin, &groups); 117 database->FindGroupsForOrigin(*origin, &groups);
116 std::vector<AppCacheDatabase::GroupRecord>::const_iterator group; 118 std::vector<AppCacheDatabase::GroupRecord>::const_iterator group;
117 for (group = groups.begin(); group != groups.end(); ++group) { 119 for (group = groups.begin(); group != groups.end(); ++group) {
118 sql::Transaction transaction(connection); 120 sql::Transaction transaction(connection);
119 if (!transaction.Begin()) { 121 if (!transaction.Begin()) {
120 NOTREACHED() << "Failed to start transaction"; 122 NOTREACHED() << "Failed to start transaction";
121 return; 123 return;
122 } 124 }
123 std::vector<int64> deletable_response_ids; 125 std::vector<int64_t> deletable_response_ids;
124 bool success = DeleteGroupAndRelatedRecords(database, 126 bool success = DeleteGroupAndRelatedRecords(database,
125 group->group_id, 127 group->group_id,
126 &deletable_response_ids); 128 &deletable_response_ids);
127 success = success && transaction.Commit(); 129 success = success && transaction.Commit();
128 DCHECK(success); 130 DCHECK(success);
129 } // for each group 131 } // for each group
130 } // for each origin 132 } // for each origin
131 } 133 }
132 134
133 } // namespace 135 } // namespace
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // DatabaseTask: 276 // DatabaseTask:
275 void Run() override; 277 void Run() override;
276 void RunCompleted() override; 278 void RunCompleted() override;
277 279
278 protected: 280 protected:
279 ~InitTask() override {} 281 ~InitTask() override {}
280 282
281 private: 283 private:
282 base::FilePath db_file_path_; 284 base::FilePath db_file_path_;
283 base::FilePath disk_cache_directory_; 285 base::FilePath disk_cache_directory_;
284 int64 last_group_id_; 286 int64_t last_group_id_;
285 int64 last_cache_id_; 287 int64_t last_cache_id_;
286 int64 last_response_id_; 288 int64_t last_response_id_;
287 int64 last_deletable_response_rowid_; 289 int64_t last_deletable_response_rowid_;
288 std::map<GURL, int64> usage_map_; 290 std::map<GURL, int64_t> usage_map_;
289 }; 291 };
290 292
291 void AppCacheStorageImpl::InitTask::Run() { 293 void AppCacheStorageImpl::InitTask::Run() {
292 tracked_objects::ScopedTracker tracking_profile( 294 tracked_objects::ScopedTracker tracking_profile(
293 FROM_HERE_WITH_EXPLICIT_FUNCTION("AppCacheStorageImpl::InitTask")); 295 FROM_HERE_WITH_EXPLICIT_FUNCTION("AppCacheStorageImpl::InitTask"));
294 // If there is no sql database, ensure there is no disk cache either. 296 // If there is no sql database, ensure there is no disk cache either.
295 if (!db_file_path_.empty() && 297 if (!db_file_path_.empty() &&
296 !base::PathExists(db_file_path_) && 298 !base::PathExists(db_file_path_) &&
297 base::DirectoryExists(disk_cache_directory_)) { 299 base::DirectoryExists(disk_cache_directory_)) {
298 base::DeleteFile(disk_cache_directory_, true); 300 base::DeleteFile(disk_cache_directory_, true);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 398 }
397 399
398 // StoreOrLoadTask ------- 400 // StoreOrLoadTask -------
399 401
400 class AppCacheStorageImpl::StoreOrLoadTask : public DatabaseTask { 402 class AppCacheStorageImpl::StoreOrLoadTask : public DatabaseTask {
401 protected: 403 protected:
402 explicit StoreOrLoadTask(AppCacheStorageImpl* storage) 404 explicit StoreOrLoadTask(AppCacheStorageImpl* storage)
403 : DatabaseTask(storage) {} 405 : DatabaseTask(storage) {}
404 ~StoreOrLoadTask() override {} 406 ~StoreOrLoadTask() override {}
405 407
406 bool FindRelatedCacheRecords(int64 cache_id); 408 bool FindRelatedCacheRecords(int64_t cache_id);
407 void CreateCacheAndGroupFromRecords( 409 void CreateCacheAndGroupFromRecords(
408 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group); 410 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group);
409 411
410 AppCacheDatabase::GroupRecord group_record_; 412 AppCacheDatabase::GroupRecord group_record_;
411 AppCacheDatabase::CacheRecord cache_record_; 413 AppCacheDatabase::CacheRecord cache_record_;
412 std::vector<AppCacheDatabase::EntryRecord> entry_records_; 414 std::vector<AppCacheDatabase::EntryRecord> entry_records_;
413 std::vector<AppCacheDatabase::NamespaceRecord> 415 std::vector<AppCacheDatabase::NamespaceRecord>
414 intercept_namespace_records_; 416 intercept_namespace_records_;
415 std::vector<AppCacheDatabase::NamespaceRecord> 417 std::vector<AppCacheDatabase::NamespaceRecord>
416 fallback_namespace_records_; 418 fallback_namespace_records_;
417 std::vector<AppCacheDatabase::OnlineWhiteListRecord> 419 std::vector<AppCacheDatabase::OnlineWhiteListRecord>
418 online_whitelist_records_; 420 online_whitelist_records_;
419 }; 421 };
420 422
421 bool AppCacheStorageImpl::StoreOrLoadTask::FindRelatedCacheRecords( 423 bool AppCacheStorageImpl::StoreOrLoadTask::FindRelatedCacheRecords(
422 int64 cache_id) { 424 int64_t cache_id) {
423 return database_->FindEntriesForCache(cache_id, &entry_records_) && 425 return database_->FindEntriesForCache(cache_id, &entry_records_) &&
424 database_->FindNamespacesForCache( 426 database_->FindNamespacesForCache(
425 cache_id, &intercept_namespace_records_, 427 cache_id, &intercept_namespace_records_,
426 &fallback_namespace_records_) && 428 &fallback_namespace_records_) &&
427 database_->FindOnlineWhiteListForCache( 429 database_->FindOnlineWhiteListForCache(
428 cache_id, &online_whitelist_records_); 430 cache_id, &online_whitelist_records_);
429 } 431 }
430 432
431 void AppCacheStorageImpl::StoreOrLoadTask::CreateCacheAndGroupFromRecords( 433 void AppCacheStorageImpl::StoreOrLoadTask::CreateCacheAndGroupFromRecords(
432 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group) { 434 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 storage_->NotifyStorageAccessed(group_record_.origin); 500 storage_->NotifyStorageAccessed(group_record_.origin);
499 501
500 // TODO(michaeln): Maybe verify that the responses we expect to exist 502 // TODO(michaeln): Maybe verify that the responses we expect to exist
501 // do actually exist in the disk_cache (and if not then what?) 503 // do actually exist in the disk_cache (and if not then what?)
502 } 504 }
503 505
504 // CacheLoadTask ------- 506 // CacheLoadTask -------
505 507
506 class AppCacheStorageImpl::CacheLoadTask : public StoreOrLoadTask { 508 class AppCacheStorageImpl::CacheLoadTask : public StoreOrLoadTask {
507 public: 509 public:
508 CacheLoadTask(int64 cache_id, AppCacheStorageImpl* storage) 510 CacheLoadTask(int64_t cache_id, AppCacheStorageImpl* storage)
509 : StoreOrLoadTask(storage), cache_id_(cache_id), 511 : StoreOrLoadTask(storage), cache_id_(cache_id), success_(false) {}
510 success_(false) {}
511 512
512 // DatabaseTask: 513 // DatabaseTask:
513 void Run() override; 514 void Run() override;
514 void RunCompleted() override; 515 void RunCompleted() override;
515 516
516 protected: 517 protected:
517 ~CacheLoadTask() override {} 518 ~CacheLoadTask() override {}
518 519
519 private: 520 private:
520 int64 cache_id_; 521 int64_t cache_id_;
521 bool success_; 522 bool success_;
522 }; 523 };
523 524
524 void AppCacheStorageImpl::CacheLoadTask::Run() { 525 void AppCacheStorageImpl::CacheLoadTask::Run() {
525 tracked_objects::ScopedTracker tracking_profile( 526 tracked_objects::ScopedTracker tracking_profile(
526 FROM_HERE_WITH_EXPLICIT_FUNCTION("AppCacheStorageImpl::CacheLoadTask")); 527 FROM_HERE_WITH_EXPLICIT_FUNCTION("AppCacheStorageImpl::CacheLoadTask"));
527 success_ = 528 success_ =
528 database_->FindCache(cache_id_, &cache_record_) && 529 database_->FindCache(cache_id_, &cache_record_) &&
529 database_->FindGroup(cache_record_.group_id, &group_record_) && 530 database_->FindGroup(cache_record_.group_id, &group_record_) &&
530 FindRelatedCacheRecords(cache_id_); 531 FindRelatedCacheRecords(cache_id_);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 602
602 // StoreGroupAndCacheTask ------- 603 // StoreGroupAndCacheTask -------
603 604
604 class AppCacheStorageImpl::StoreGroupAndCacheTask : public StoreOrLoadTask { 605 class AppCacheStorageImpl::StoreGroupAndCacheTask : public StoreOrLoadTask {
605 public: 606 public:
606 StoreGroupAndCacheTask(AppCacheStorageImpl* storage, AppCacheGroup* group, 607 StoreGroupAndCacheTask(AppCacheStorageImpl* storage, AppCacheGroup* group,
607 AppCache* newest_cache); 608 AppCache* newest_cache);
608 609
609 void GetQuotaThenSchedule(); 610 void GetQuotaThenSchedule();
610 void OnQuotaCallback(storage::QuotaStatusCode status, 611 void OnQuotaCallback(storage::QuotaStatusCode status,
611 int64 usage, 612 int64_t usage,
612 int64 quota); 613 int64_t quota);
613 614
614 // DatabaseTask: 615 // DatabaseTask:
615 void Run() override; 616 void Run() override;
616 void RunCompleted() override; 617 void RunCompleted() override;
617 void CancelCompletion() override; 618 void CancelCompletion() override;
618 619
619 protected: 620 protected:
620 ~StoreGroupAndCacheTask() override {} 621 ~StoreGroupAndCacheTask() override {}
621 622
622 private: 623 private:
623 scoped_refptr<AppCacheGroup> group_; 624 scoped_refptr<AppCacheGroup> group_;
624 scoped_refptr<AppCache> cache_; 625 scoped_refptr<AppCache> cache_;
625 bool success_; 626 bool success_;
626 bool would_exceed_quota_; 627 bool would_exceed_quota_;
627 int64 space_available_; 628 int64_t space_available_;
628 int64 new_origin_usage_; 629 int64_t new_origin_usage_;
629 std::vector<int64> newly_deletable_response_ids_; 630 std::vector<int64_t> newly_deletable_response_ids_;
630 }; 631 };
631 632
632 AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask( 633 AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask(
633 AppCacheStorageImpl* storage, AppCacheGroup* group, AppCache* newest_cache) 634 AppCacheStorageImpl* storage, AppCacheGroup* group, AppCache* newest_cache)
634 : StoreOrLoadTask(storage), group_(group), cache_(newest_cache), 635 : StoreOrLoadTask(storage), group_(group), cache_(newest_cache),
635 success_(false), would_exceed_quota_(false), 636 success_(false), would_exceed_quota_(false),
636 space_available_(-1), new_origin_usage_(-1) { 637 space_available_(-1), new_origin_usage_(-1) {
637 group_record_.group_id = group->group_id(); 638 group_record_.group_id = group->group_id();
638 group_record_.manifest_url = group->manifest_url(); 639 group_record_.manifest_url = group->manifest_url();
639 group_record_.origin = group_record_.manifest_url.GetOrigin(); 640 group_record_.origin = group_record_.manifest_url.GetOrigin();
(...skipping 13 matching lines...) Expand all
653 storage::QuotaManager* quota_manager = NULL; 654 storage::QuotaManager* quota_manager = NULL;
654 if (storage_->service()->quota_manager_proxy()) { 655 if (storage_->service()->quota_manager_proxy()) {
655 quota_manager = 656 quota_manager =
656 storage_->service()->quota_manager_proxy()->quota_manager(); 657 storage_->service()->quota_manager_proxy()->quota_manager();
657 } 658 }
658 659
659 if (!quota_manager) { 660 if (!quota_manager) {
660 if (storage_->service()->special_storage_policy() && 661 if (storage_->service()->special_storage_policy() &&
661 storage_->service()->special_storage_policy()->IsStorageUnlimited( 662 storage_->service()->special_storage_policy()->IsStorageUnlimited(
662 group_record_.origin)) 663 group_record_.origin))
663 space_available_ = kint64max; 664 space_available_ = std::numeric_limits<int64_t>::max();
664 Schedule(); 665 Schedule();
665 return; 666 return;
666 } 667 }
667 668
668 // crbug.com/349708 669 // crbug.com/349708
669 TRACE_EVENT0( 670 TRACE_EVENT0(
670 "io", 671 "io",
671 "AppCacheStorageImpl::StoreGroupAndCacheTask::GetQuotaThenSchedule"); 672 "AppCacheStorageImpl::StoreGroupAndCacheTask::GetQuotaThenSchedule");
672 673
673 // We have to ask the quota manager for the value. 674 // We have to ask the quota manager for the value.
674 storage_->pending_quota_queries_.insert(this); 675 storage_->pending_quota_queries_.insert(this);
675 quota_manager->GetUsageAndQuota( 676 quota_manager->GetUsageAndQuota(
676 group_record_.origin, 677 group_record_.origin,
677 storage::kStorageTypeTemporary, 678 storage::kStorageTypeTemporary,
678 base::Bind(&StoreGroupAndCacheTask::OnQuotaCallback, this)); 679 base::Bind(&StoreGroupAndCacheTask::OnQuotaCallback, this));
679 } 680 }
680 681
681 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback( 682 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback(
682 storage::QuotaStatusCode status, 683 storage::QuotaStatusCode status,
683 int64 usage, 684 int64_t usage,
684 int64 quota) { 685 int64_t quota) {
685 if (storage_) { 686 if (storage_) {
686 if (status == storage::kQuotaStatusOk) 687 if (status == storage::kQuotaStatusOk)
687 space_available_ = std::max(static_cast<int64>(0), quota - usage); 688 space_available_ = std::max(static_cast<int64_t>(0), quota - usage);
688 else 689 else
689 space_available_ = 0; 690 space_available_ = 0;
690 storage_->pending_quota_queries_.erase(this); 691 storage_->pending_quota_queries_.erase(this);
691 Schedule(); 692 Schedule();
692 } 693 }
693 } 694 }
694 695
695 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { 696 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() {
696 DCHECK(!success_); 697 DCHECK(!success_);
697 sql::Connection* connection = database_->db_connection(); 698 sql::Connection* connection = database_->db_connection();
698 if (!connection) 699 if (!connection)
699 return; 700 return;
700 701
701 sql::Transaction transaction(connection); 702 sql::Transaction transaction(connection);
702 if (!transaction.Begin()) 703 if (!transaction.Begin())
703 return; 704 return;
704 705
705 int64 old_origin_usage = database_->GetOriginUsage(group_record_.origin); 706 int64_t old_origin_usage = database_->GetOriginUsage(group_record_.origin);
706 707
707 AppCacheDatabase::GroupRecord existing_group; 708 AppCacheDatabase::GroupRecord existing_group;
708 success_ = database_->FindGroup(group_record_.group_id, &existing_group); 709 success_ = database_->FindGroup(group_record_.group_id, &existing_group);
709 if (!success_) { 710 if (!success_) {
710 group_record_.creation_time = base::Time::Now(); 711 group_record_.creation_time = base::Time::Now();
711 group_record_.last_access_time = base::Time::Now(); 712 group_record_.last_access_time = base::Time::Now();
712 success_ = database_->InsertGroup(&group_record_); 713 success_ = database_->InsertGroup(&group_record_);
713 } else { 714 } else {
714 DCHECK(group_record_.group_id == existing_group.group_id); 715 DCHECK(group_record_.group_id == existing_group.group_id);
715 DCHECK(group_record_.manifest_url == existing_group.manifest_url); 716 DCHECK(group_record_.manifest_url == existing_group.manifest_url);
716 DCHECK(group_record_.origin == existing_group.origin); 717 DCHECK(group_record_.origin == existing_group.origin);
717 718
718 database_->UpdateLastAccessTime(group_record_.group_id, 719 database_->UpdateLastAccessTime(group_record_.group_id,
719 base::Time::Now()); 720 base::Time::Now());
720 721
721 database_->UpdateEvictionTimes( 722 database_->UpdateEvictionTimes(
722 group_record_.group_id, 723 group_record_.group_id,
723 group_record_.last_full_update_check_time, 724 group_record_.last_full_update_check_time,
724 group_record_.first_evictable_error_time); 725 group_record_.first_evictable_error_time);
725 726
726 AppCacheDatabase::CacheRecord cache; 727 AppCacheDatabase::CacheRecord cache;
727 if (database_->FindCacheForGroup(group_record_.group_id, &cache)) { 728 if (database_->FindCacheForGroup(group_record_.group_id, &cache)) {
728 // Get the set of response ids in the old cache. 729 // Get the set of response ids in the old cache.
729 std::set<int64> existing_response_ids; 730 std::set<int64_t> existing_response_ids;
730 database_->FindResponseIdsForCacheAsSet(cache.cache_id, 731 database_->FindResponseIdsForCacheAsSet(cache.cache_id,
731 &existing_response_ids); 732 &existing_response_ids);
732 733
733 // Remove those that remain in the new cache. 734 // Remove those that remain in the new cache.
734 std::vector<AppCacheDatabase::EntryRecord>::const_iterator entry_iter = 735 std::vector<AppCacheDatabase::EntryRecord>::const_iterator entry_iter =
735 entry_records_.begin(); 736 entry_records_.begin();
736 while (entry_iter != entry_records_.end()) { 737 while (entry_iter != entry_records_.end()) {
737 existing_response_ids.erase(entry_iter->response_id); 738 existing_response_ids.erase(entry_iter->response_id);
738 ++entry_iter; 739 ++entry_iter;
739 } 740 }
740 741
741 // The rest are deletable. 742 // The rest are deletable.
742 std::set<int64>::const_iterator id_iter = existing_response_ids.begin(); 743 std::set<int64_t>::const_iterator id_iter = existing_response_ids.begin();
743 while (id_iter != existing_response_ids.end()) { 744 while (id_iter != existing_response_ids.end()) {
744 newly_deletable_response_ids_.push_back(*id_iter); 745 newly_deletable_response_ids_.push_back(*id_iter);
745 ++id_iter; 746 ++id_iter;
746 } 747 }
747 748
748 success_ = 749 success_ =
749 database_->DeleteCache(cache.cache_id) && 750 database_->DeleteCache(cache.cache_id) &&
750 database_->DeleteEntriesForCache(cache.cache_id) && 751 database_->DeleteEntriesForCache(cache.cache_id) &&
751 database_->DeleteNamespacesForCache(cache.cache_id) && 752 database_->DeleteNamespacesForCache(cache.cache_id) &&
752 database_->DeleteOnlineWhiteListForCache(cache.cache_id) && 753 database_->DeleteOnlineWhiteListForCache(cache.cache_id) &&
(...skipping 29 matching lines...) Expand all
782 would_exceed_quota_ = true; 783 would_exceed_quota_ = true;
783 success_ = false; 784 success_ = false;
784 return; 785 return;
785 } 786 }
786 success_ = transaction.Commit(); 787 success_ = transaction.Commit();
787 return; 788 return;
788 } 789 }
789 790
790 // Check limits based on the space availbable given to us via the 791 // Check limits based on the space availbable given to us via the
791 // quota system. 792 // quota system.
792 int64 delta = new_origin_usage_ - old_origin_usage; 793 int64_t delta = new_origin_usage_ - old_origin_usage;
793 if (delta > space_available_) { 794 if (delta > space_available_) {
794 would_exceed_quota_ = true; 795 would_exceed_quota_ = true;
795 success_ = false; 796 success_ = false;
796 return; 797 return;
797 } 798 }
798 799
799 success_ = transaction.Commit(); 800 success_ = transaction.Commit();
800 } 801 }
801 802
802 void AppCacheStorageImpl::StoreGroupAndCacheTask::RunCompleted() { 803 void AppCacheStorageImpl::StoreGroupAndCacheTask::RunCompleted() {
(...skipping 30 matching lines...) Expand all
833 // FindMainResponseTask ------- 834 // FindMainResponseTask -------
834 835
835 // Helpers for FindMainResponseTask::Run() 836 // Helpers for FindMainResponseTask::Run()
836 namespace { 837 namespace {
837 class SortByCachePreference 838 class SortByCachePreference
838 : public std::binary_function< 839 : public std::binary_function<
839 AppCacheDatabase::EntryRecord, 840 AppCacheDatabase::EntryRecord,
840 AppCacheDatabase::EntryRecord, 841 AppCacheDatabase::EntryRecord,
841 bool> { 842 bool> {
842 public: 843 public:
843 SortByCachePreference(int64 preferred_id, const std::set<int64>& in_use_ids) 844 SortByCachePreference(int64_t preferred_id,
844 : preferred_id_(preferred_id), in_use_ids_(in_use_ids) { 845 const std::set<int64_t>& in_use_ids)
845 } 846 : preferred_id_(preferred_id), in_use_ids_(in_use_ids) {}
846 bool operator()( 847 bool operator()(
847 const AppCacheDatabase::EntryRecord& lhs, 848 const AppCacheDatabase::EntryRecord& lhs,
848 const AppCacheDatabase::EntryRecord& rhs) { 849 const AppCacheDatabase::EntryRecord& rhs) {
849 return compute_value(lhs) > compute_value(rhs); 850 return compute_value(lhs) > compute_value(rhs);
850 } 851 }
851 private: 852 private:
852 int compute_value(const AppCacheDatabase::EntryRecord& entry) { 853 int compute_value(const AppCacheDatabase::EntryRecord& entry) {
853 if (entry.cache_id == preferred_id_) 854 if (entry.cache_id == preferred_id_)
854 return 100; 855 return 100;
855 else if (in_use_ids_.find(entry.cache_id) != in_use_ids_.end()) 856 else if (in_use_ids_.find(entry.cache_id) != in_use_ids_.end())
856 return 50; 857 return 50;
857 return 0; 858 return 0;
858 } 859 }
859 int64 preferred_id_; 860 int64_t preferred_id_;
860 const std::set<int64>& in_use_ids_; 861 const std::set<int64_t>& in_use_ids_;
861 }; 862 };
862 863
863 bool SortByLength( 864 bool SortByLength(
864 const AppCacheDatabase::NamespaceRecord& lhs, 865 const AppCacheDatabase::NamespaceRecord& lhs,
865 const AppCacheDatabase::NamespaceRecord& rhs) { 866 const AppCacheDatabase::NamespaceRecord& rhs) {
866 return lhs.namespace_.namespace_url.spec().length() > 867 return lhs.namespace_.namespace_url.spec().length() >
867 rhs.namespace_.namespace_url.spec().length(); 868 rhs.namespace_.namespace_url.spec().length();
868 } 869 }
869 870
870 class NetworkNamespaceHelper { 871 class NetworkNamespaceHelper {
871 public: 872 public:
872 explicit NetworkNamespaceHelper(AppCacheDatabase* database) 873 explicit NetworkNamespaceHelper(AppCacheDatabase* database)
873 : database_(database) { 874 : database_(database) {
874 } 875 }
875 876
876 bool IsInNetworkNamespace(const GURL& url, int64 cache_id) { 877 bool IsInNetworkNamespace(const GURL& url, int64_t cache_id) {
877 typedef std::pair<WhiteListMap::iterator, bool> InsertResult; 878 typedef std::pair<WhiteListMap::iterator, bool> InsertResult;
878 InsertResult result = namespaces_map_.insert( 879 InsertResult result = namespaces_map_.insert(
879 WhiteListMap::value_type(cache_id, AppCacheNamespaceVector())); 880 WhiteListMap::value_type(cache_id, AppCacheNamespaceVector()));
880 if (result.second) 881 if (result.second)
881 GetOnlineWhiteListForCache(cache_id, &result.first->second); 882 GetOnlineWhiteListForCache(cache_id, &result.first->second);
882 return AppCache::FindNamespace(result.first->second, url) != NULL; 883 return AppCache::FindNamespace(result.first->second, url) != NULL;
883 } 884 }
884 885
885 private: 886 private:
886 void GetOnlineWhiteListForCache( 887 void GetOnlineWhiteListForCache(int64_t cache_id,
887 int64 cache_id, AppCacheNamespaceVector* namespaces) { 888 AppCacheNamespaceVector* namespaces) {
888 DCHECK(namespaces && namespaces->empty()); 889 DCHECK(namespaces && namespaces->empty());
889 typedef std::vector<AppCacheDatabase::OnlineWhiteListRecord> 890 typedef std::vector<AppCacheDatabase::OnlineWhiteListRecord>
890 WhiteListVector; 891 WhiteListVector;
891 WhiteListVector records; 892 WhiteListVector records;
892 if (!database_->FindOnlineWhiteListForCache(cache_id, &records)) 893 if (!database_->FindOnlineWhiteListForCache(cache_id, &records))
893 return; 894 return;
894 WhiteListVector::const_iterator iter = records.begin(); 895 WhiteListVector::const_iterator iter = records.begin();
895 while (iter != records.end()) { 896 while (iter != records.end()) {
896 namespaces->push_back( 897 namespaces->push_back(
897 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, iter->namespace_url, 898 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, iter->namespace_url,
898 GURL(), iter->is_pattern)); 899 GURL(), iter->is_pattern));
899 ++iter; 900 ++iter;
900 } 901 }
901 } 902 }
902 903
903 // Key is cache id 904 // Key is cache id
904 typedef std::map<int64, AppCacheNamespaceVector> WhiteListMap; 905 typedef std::map<int64_t, AppCacheNamespaceVector> WhiteListMap;
905 WhiteListMap namespaces_map_; 906 WhiteListMap namespaces_map_;
906 AppCacheDatabase* database_; 907 AppCacheDatabase* database_;
907 }; 908 };
908 909
909 } // namespace 910 } // namespace
910 911
911 class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask { 912 class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask {
912 public: 913 public:
913 FindMainResponseTask(AppCacheStorageImpl* storage, 914 FindMainResponseTask(AppCacheStorageImpl* storage,
914 const GURL& url, 915 const GURL& url,
(...skipping 19 matching lines...) Expand all
934 void Run() override; 935 void Run() override;
935 void RunCompleted() override; 936 void RunCompleted() override;
936 937
937 protected: 938 protected:
938 ~FindMainResponseTask() override {} 939 ~FindMainResponseTask() override {}
939 940
940 private: 941 private:
941 typedef std::vector<AppCacheDatabase::NamespaceRecord*> 942 typedef std::vector<AppCacheDatabase::NamespaceRecord*>
942 NamespaceRecordPtrVector; 943 NamespaceRecordPtrVector;
943 944
944 bool FindExactMatch(int64 preferred_id); 945 bool FindExactMatch(int64_t preferred_id);
945 bool FindNamespaceMatch(int64 preferred_id); 946 bool FindNamespaceMatch(int64_t preferred_id);
946 bool FindNamespaceHelper( 947 bool FindNamespaceHelper(int64_t preferred_cache_id,
947 int64 preferred_cache_id, 948 AppCacheDatabase::NamespaceRecordVector* namespaces,
948 AppCacheDatabase::NamespaceRecordVector* namespaces, 949 NetworkNamespaceHelper* network_namespace_helper);
949 NetworkNamespaceHelper* network_namespace_helper);
950 bool FindFirstValidNamespace(const NamespaceRecordPtrVector& namespaces); 950 bool FindFirstValidNamespace(const NamespaceRecordPtrVector& namespaces);
951 951
952 GURL url_; 952 GURL url_;
953 GURL preferred_manifest_url_; 953 GURL preferred_manifest_url_;
954 std::set<int64> cache_ids_in_use_; 954 std::set<int64_t> cache_ids_in_use_;
955 AppCacheEntry entry_; 955 AppCacheEntry entry_;
956 AppCacheEntry fallback_entry_; 956 AppCacheEntry fallback_entry_;
957 GURL namespace_entry_url_; 957 GURL namespace_entry_url_;
958 int64 cache_id_; 958 int64_t cache_id_;
959 int64 group_id_; 959 int64_t group_id_;
960 GURL manifest_url_; 960 GURL manifest_url_;
961 }; 961 };
962 962
963 void AppCacheStorageImpl::FindMainResponseTask::Run() { 963 void AppCacheStorageImpl::FindMainResponseTask::Run() {
964 tracked_objects::ScopedTracker tracking_profile( 964 tracked_objects::ScopedTracker tracking_profile(
965 FROM_HERE_WITH_EXPLICIT_FUNCTION( 965 FROM_HERE_WITH_EXPLICIT_FUNCTION(
966 "AppCacheStorageImpl::FindMainResponseTask")); 966 "AppCacheStorageImpl::FindMainResponseTask"));
967 // NOTE: The heuristics around choosing amoungst multiple candidates 967 // NOTE: The heuristics around choosing amoungst multiple candidates
968 // is underspecified, and just plain not fully understood. This needs 968 // is underspecified, and just plain not fully understood. This needs
969 // to be refined. 969 // to be refined.
970 970
971 // The 'preferred_manifest_url' is the url of the manifest associated 971 // The 'preferred_manifest_url' is the url of the manifest associated
972 // with the page that opened or embedded the page being loaded now. 972 // with the page that opened or embedded the page being loaded now.
973 // We have a strong preference to use resources from that cache. 973 // We have a strong preference to use resources from that cache.
974 // We also have a lesser bias to use resources from caches that are currently 974 // We also have a lesser bias to use resources from caches that are currently
975 // being used by other unrelated pages. 975 // being used by other unrelated pages.
976 // TODO(michaeln): come up with a 'preferred_manifest_url' in more cases 976 // TODO(michaeln): come up with a 'preferred_manifest_url' in more cases
977 // - when navigating a frame whose current contents are from an appcache 977 // - when navigating a frame whose current contents are from an appcache
978 // - when clicking an href in a frame that is appcached 978 // - when clicking an href in a frame that is appcached
979 int64 preferred_cache_id = kAppCacheNoCacheId; 979 int64_t preferred_cache_id = kAppCacheNoCacheId;
980 if (!preferred_manifest_url_.is_empty()) { 980 if (!preferred_manifest_url_.is_empty()) {
981 AppCacheDatabase::GroupRecord preferred_group; 981 AppCacheDatabase::GroupRecord preferred_group;
982 AppCacheDatabase::CacheRecord preferred_cache; 982 AppCacheDatabase::CacheRecord preferred_cache;
983 if (database_->FindGroupForManifestUrl( 983 if (database_->FindGroupForManifestUrl(
984 preferred_manifest_url_, &preferred_group) && 984 preferred_manifest_url_, &preferred_group) &&
985 database_->FindCacheForGroup( 985 database_->FindCacheForGroup(
986 preferred_group.group_id, &preferred_cache)) { 986 preferred_group.group_id, &preferred_cache)) {
987 preferred_cache_id = preferred_cache.cache_id; 987 preferred_cache_id = preferred_cache.cache_id;
988 } 988 }
989 } 989 }
990 990
991 if (FindExactMatch(preferred_cache_id) || 991 if (FindExactMatch(preferred_cache_id) ||
992 FindNamespaceMatch(preferred_cache_id)) { 992 FindNamespaceMatch(preferred_cache_id)) {
993 // We found something. 993 // We found something.
994 DCHECK(cache_id_ != kAppCacheNoCacheId && !manifest_url_.is_empty() && 994 DCHECK(cache_id_ != kAppCacheNoCacheId && !manifest_url_.is_empty() &&
995 group_id_ != 0); 995 group_id_ != 0);
996 return; 996 return;
997 } 997 }
998 998
999 // We didn't find anything. 999 // We didn't find anything.
1000 DCHECK(cache_id_ == kAppCacheNoCacheId && manifest_url_.is_empty() && 1000 DCHECK(cache_id_ == kAppCacheNoCacheId && manifest_url_.is_empty() &&
1001 group_id_ == 0); 1001 group_id_ == 0);
1002 } 1002 }
1003 1003
1004 bool AppCacheStorageImpl:: 1004 bool AppCacheStorageImpl::FindMainResponseTask::FindExactMatch(
1005 FindMainResponseTask::FindExactMatch(int64 preferred_cache_id) { 1005 int64_t preferred_cache_id) {
1006 std::vector<AppCacheDatabase::EntryRecord> entries; 1006 std::vector<AppCacheDatabase::EntryRecord> entries;
1007 if (database_->FindEntriesForUrl(url_, &entries) && !entries.empty()) { 1007 if (database_->FindEntriesForUrl(url_, &entries) && !entries.empty()) {
1008 // Sort them in order of preference, from the preferred_cache first, 1008 // Sort them in order of preference, from the preferred_cache first,
1009 // followed by hits from caches that are 'in use', then the rest. 1009 // followed by hits from caches that are 'in use', then the rest.
1010 std::sort(entries.begin(), entries.end(), 1010 std::sort(entries.begin(), entries.end(),
1011 SortByCachePreference(preferred_cache_id, cache_ids_in_use_)); 1011 SortByCachePreference(preferred_cache_id, cache_ids_in_use_));
1012 1012
1013 // Take the first with a valid, non-foreign entry. 1013 // Take the first with a valid, non-foreign entry.
1014 std::vector<AppCacheDatabase::EntryRecord>::iterator iter; 1014 std::vector<AppCacheDatabase::EntryRecord>::iterator iter;
1015 for (iter = entries.begin(); iter < entries.end(); ++iter) { 1015 for (iter = entries.begin(); iter < entries.end(); ++iter) {
1016 AppCacheDatabase::GroupRecord group_record; 1016 AppCacheDatabase::GroupRecord group_record;
1017 if ((iter->flags & AppCacheEntry::FOREIGN) || 1017 if ((iter->flags & AppCacheEntry::FOREIGN) ||
1018 !database_->FindGroupForCache(iter->cache_id, &group_record)) { 1018 !database_->FindGroupForCache(iter->cache_id, &group_record)) {
1019 continue; 1019 continue;
1020 } 1020 }
1021 manifest_url_ = group_record.manifest_url; 1021 manifest_url_ = group_record.manifest_url;
1022 group_id_ = group_record.group_id; 1022 group_id_ = group_record.group_id;
1023 entry_ = AppCacheEntry(iter->flags, iter->response_id); 1023 entry_ = AppCacheEntry(iter->flags, iter->response_id);
1024 cache_id_ = iter->cache_id; 1024 cache_id_ = iter->cache_id;
1025 return true; // We found an exact match. 1025 return true; // We found an exact match.
1026 } 1026 }
1027 } 1027 }
1028 return false; 1028 return false;
1029 } 1029 }
1030 1030
1031 bool AppCacheStorageImpl:: 1031 bool AppCacheStorageImpl::FindMainResponseTask::FindNamespaceMatch(
1032 FindMainResponseTask::FindNamespaceMatch(int64 preferred_cache_id) { 1032 int64_t preferred_cache_id) {
1033 AppCacheDatabase::NamespaceRecordVector all_intercepts; 1033 AppCacheDatabase::NamespaceRecordVector all_intercepts;
1034 AppCacheDatabase::NamespaceRecordVector all_fallbacks; 1034 AppCacheDatabase::NamespaceRecordVector all_fallbacks;
1035 if (!database_->FindNamespacesForOrigin( 1035 if (!database_->FindNamespacesForOrigin(
1036 url_.GetOrigin(), &all_intercepts, &all_fallbacks) 1036 url_.GetOrigin(), &all_intercepts, &all_fallbacks)
1037 || (all_intercepts.empty() && all_fallbacks.empty())) { 1037 || (all_intercepts.empty() && all_fallbacks.empty())) {
1038 return false; 1038 return false;
1039 } 1039 }
1040 1040
1041 NetworkNamespaceHelper network_namespace_helper(database_); 1041 NetworkNamespaceHelper network_namespace_helper(database_);
1042 if (FindNamespaceHelper(preferred_cache_id, 1042 if (FindNamespaceHelper(preferred_cache_id,
1043 &all_intercepts, 1043 &all_intercepts,
1044 &network_namespace_helper) || 1044 &network_namespace_helper) ||
1045 FindNamespaceHelper(preferred_cache_id, 1045 FindNamespaceHelper(preferred_cache_id,
1046 &all_fallbacks, 1046 &all_fallbacks,
1047 &network_namespace_helper)) { 1047 &network_namespace_helper)) {
1048 return true; 1048 return true;
1049 } 1049 }
1050 return false; 1050 return false;
1051 } 1051 }
1052 1052
1053 bool AppCacheStorageImpl:: 1053 bool AppCacheStorageImpl::FindMainResponseTask::FindNamespaceHelper(
1054 FindMainResponseTask::FindNamespaceHelper( 1054 int64_t preferred_cache_id,
1055 int64 preferred_cache_id,
1056 AppCacheDatabase::NamespaceRecordVector* namespaces, 1055 AppCacheDatabase::NamespaceRecordVector* namespaces,
1057 NetworkNamespaceHelper* network_namespace_helper) { 1056 NetworkNamespaceHelper* network_namespace_helper) {
1058 // Sort them by length, longer matches within the same cache/bucket take 1057 // Sort them by length, longer matches within the same cache/bucket take
1059 // precedence. 1058 // precedence.
1060 std::sort(namespaces->begin(), namespaces->end(), SortByLength); 1059 std::sort(namespaces->begin(), namespaces->end(), SortByLength);
1061 1060
1062 NamespaceRecordPtrVector preferred_namespaces; 1061 NamespaceRecordPtrVector preferred_namespaces;
1063 NamespaceRecordPtrVector inuse_namespaces; 1062 NamespaceRecordPtrVector inuse_namespaces;
1064 NamespaceRecordPtrVector other_namespaces; 1063 NamespaceRecordPtrVector other_namespaces;
1065 std::vector<AppCacheDatabase::NamespaceRecord>::iterator iter; 1064 std::vector<AppCacheDatabase::NamespaceRecord>::iterator iter;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() { 1122 void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() {
1124 storage_->CallOnMainResponseFound( 1123 storage_->CallOnMainResponseFound(
1125 &delegates_, url_, entry_, namespace_entry_url_, fallback_entry_, 1124 &delegates_, url_, entry_, namespace_entry_url_, fallback_entry_,
1126 cache_id_, group_id_, manifest_url_); 1125 cache_id_, group_id_, manifest_url_);
1127 } 1126 }
1128 1127
1129 // MarkEntryAsForeignTask ------- 1128 // MarkEntryAsForeignTask -------
1130 1129
1131 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask { 1130 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask {
1132 public: 1131 public:
1133 MarkEntryAsForeignTask( 1132 MarkEntryAsForeignTask(AppCacheStorageImpl* storage,
1134 AppCacheStorageImpl* storage, const GURL& url, int64 cache_id) 1133 const GURL& url,
1134 int64_t cache_id)
1135 : DatabaseTask(storage), cache_id_(cache_id), entry_url_(url) {} 1135 : DatabaseTask(storage), cache_id_(cache_id), entry_url_(url) {}
1136 1136
1137 // DatabaseTask: 1137 // DatabaseTask:
1138 void Run() override; 1138 void Run() override;
1139 void RunCompleted() override; 1139 void RunCompleted() override;
1140 1140
1141 protected: 1141 protected:
1142 ~MarkEntryAsForeignTask() override {} 1142 ~MarkEntryAsForeignTask() override {}
1143 1143
1144 private: 1144 private:
1145 int64 cache_id_; 1145 int64_t cache_id_;
1146 GURL entry_url_; 1146 GURL entry_url_;
1147 }; 1147 };
1148 1148
1149 void AppCacheStorageImpl::MarkEntryAsForeignTask::Run() { 1149 void AppCacheStorageImpl::MarkEntryAsForeignTask::Run() {
1150 database_->AddEntryFlags(entry_url_, cache_id_, AppCacheEntry::FOREIGN); 1150 database_->AddEntryFlags(entry_url_, cache_id_, AppCacheEntry::FOREIGN);
1151 } 1151 }
1152 1152
1153 void AppCacheStorageImpl::MarkEntryAsForeignTask::RunCompleted() { 1153 void AppCacheStorageImpl::MarkEntryAsForeignTask::RunCompleted() {
1154 DCHECK(storage_->pending_foreign_markings_.front().first == entry_url_ && 1154 DCHECK(storage_->pending_foreign_markings_.front().first == entry_url_ &&
1155 storage_->pending_foreign_markings_.front().second == cache_id_); 1155 storage_->pending_foreign_markings_.front().second == cache_id_);
(...skipping 11 matching lines...) Expand all
1167 // DatabaseTask: 1167 // DatabaseTask:
1168 void Run() override; 1168 void Run() override;
1169 void RunCompleted() override; 1169 void RunCompleted() override;
1170 void CancelCompletion() override; 1170 void CancelCompletion() override;
1171 1171
1172 protected: 1172 protected:
1173 ~MakeGroupObsoleteTask() override {} 1173 ~MakeGroupObsoleteTask() override {}
1174 1174
1175 private: 1175 private:
1176 scoped_refptr<AppCacheGroup> group_; 1176 scoped_refptr<AppCacheGroup> group_;
1177 int64 group_id_; 1177 int64_t group_id_;
1178 GURL origin_; 1178 GURL origin_;
1179 bool success_; 1179 bool success_;
1180 int response_code_; 1180 int response_code_;
1181 int64 new_origin_usage_; 1181 int64_t new_origin_usage_;
1182 std::vector<int64> newly_deletable_response_ids_; 1182 std::vector<int64_t> newly_deletable_response_ids_;
1183 }; 1183 };
1184 1184
1185 AppCacheStorageImpl::MakeGroupObsoleteTask::MakeGroupObsoleteTask( 1185 AppCacheStorageImpl::MakeGroupObsoleteTask::MakeGroupObsoleteTask(
1186 AppCacheStorageImpl* storage, 1186 AppCacheStorageImpl* storage,
1187 AppCacheGroup* group, 1187 AppCacheGroup* group,
1188 int response_code) 1188 int response_code)
1189 : DatabaseTask(storage), 1189 : DatabaseTask(storage),
1190 group_(group), 1190 group_(group),
1191 group_id_(group->group_id()), 1191 group_id_(group->group_id()),
1192 origin_(group->manifest_url().GetOrigin()), 1192 origin_(group->manifest_url().GetOrigin()),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 // Overriden to safely drop our reference to the group 1243 // Overriden to safely drop our reference to the group
1244 // which is not thread safe refcounted. 1244 // which is not thread safe refcounted.
1245 DatabaseTask::CancelCompletion(); 1245 DatabaseTask::CancelCompletion();
1246 group_ = NULL; 1246 group_ = NULL;
1247 } 1247 }
1248 1248
1249 // GetDeletableResponseIdsTask ------- 1249 // GetDeletableResponseIdsTask -------
1250 1250
1251 class AppCacheStorageImpl::GetDeletableResponseIdsTask : public DatabaseTask { 1251 class AppCacheStorageImpl::GetDeletableResponseIdsTask : public DatabaseTask {
1252 public: 1252 public:
1253 GetDeletableResponseIdsTask(AppCacheStorageImpl* storage, int64 max_rowid) 1253 GetDeletableResponseIdsTask(AppCacheStorageImpl* storage, int64_t max_rowid)
1254 : DatabaseTask(storage), max_rowid_(max_rowid) {} 1254 : DatabaseTask(storage), max_rowid_(max_rowid) {}
1255 1255
1256 // DatabaseTask: 1256 // DatabaseTask:
1257 void Run() override; 1257 void Run() override;
1258 void RunCompleted() override; 1258 void RunCompleted() override;
1259 1259
1260 protected: 1260 protected:
1261 ~GetDeletableResponseIdsTask() override {} 1261 ~GetDeletableResponseIdsTask() override {}
1262 1262
1263 private: 1263 private:
1264 int64 max_rowid_; 1264 int64_t max_rowid_;
1265 std::vector<int64> response_ids_; 1265 std::vector<int64_t> response_ids_;
1266 }; 1266 };
1267 1267
1268 void AppCacheStorageImpl::GetDeletableResponseIdsTask::Run() { 1268 void AppCacheStorageImpl::GetDeletableResponseIdsTask::Run() {
1269 const int kSqlLimit = 1000; 1269 const int kSqlLimit = 1000;
1270 database_->GetDeletableResponseIds(&response_ids_, max_rowid_, kSqlLimit); 1270 database_->GetDeletableResponseIds(&response_ids_, max_rowid_, kSqlLimit);
1271 // TODO(michaeln): retrieve group_ids too 1271 // TODO(michaeln): retrieve group_ids too
1272 } 1272 }
1273 1273
1274 void AppCacheStorageImpl::GetDeletableResponseIdsTask::RunCompleted() { 1274 void AppCacheStorageImpl::GetDeletableResponseIdsTask::RunCompleted() {
1275 if (!response_ids_.empty()) 1275 if (!response_ids_.empty())
1276 storage_->StartDeletingResponses(response_ids_); 1276 storage_->StartDeletingResponses(response_ids_);
1277 } 1277 }
1278 1278
1279 // InsertDeletableResponseIdsTask ------- 1279 // InsertDeletableResponseIdsTask -------
1280 1280
1281 class AppCacheStorageImpl::InsertDeletableResponseIdsTask 1281 class AppCacheStorageImpl::InsertDeletableResponseIdsTask
1282 : public DatabaseTask { 1282 : public DatabaseTask {
1283 public: 1283 public:
1284 explicit InsertDeletableResponseIdsTask(AppCacheStorageImpl* storage) 1284 explicit InsertDeletableResponseIdsTask(AppCacheStorageImpl* storage)
1285 : DatabaseTask(storage) {} 1285 : DatabaseTask(storage) {}
1286 1286
1287 // DatabaseTask: 1287 // DatabaseTask:
1288 void Run() override; 1288 void Run() override;
1289 1289
1290 std::vector<int64> response_ids_; 1290 std::vector<int64_t> response_ids_;
1291 1291
1292 protected: 1292 protected:
1293 ~InsertDeletableResponseIdsTask() override {} 1293 ~InsertDeletableResponseIdsTask() override {}
1294 }; 1294 };
1295 1295
1296 void AppCacheStorageImpl::InsertDeletableResponseIdsTask::Run() { 1296 void AppCacheStorageImpl::InsertDeletableResponseIdsTask::Run() {
1297 database_->InsertDeletableResponseIds(response_ids_); 1297 database_->InsertDeletableResponseIds(response_ids_);
1298 // TODO(michaeln): store group_ids too 1298 // TODO(michaeln): store group_ids too
1299 } 1299 }
1300 1300
1301 // DeleteDeletableResponseIdsTask ------- 1301 // DeleteDeletableResponseIdsTask -------
1302 1302
1303 class AppCacheStorageImpl::DeleteDeletableResponseIdsTask 1303 class AppCacheStorageImpl::DeleteDeletableResponseIdsTask
1304 : public DatabaseTask { 1304 : public DatabaseTask {
1305 public: 1305 public:
1306 explicit DeleteDeletableResponseIdsTask(AppCacheStorageImpl* storage) 1306 explicit DeleteDeletableResponseIdsTask(AppCacheStorageImpl* storage)
1307 : DatabaseTask(storage) {} 1307 : DatabaseTask(storage) {}
1308 1308
1309 // DatabaseTask: 1309 // DatabaseTask:
1310 void Run() override; 1310 void Run() override;
1311 1311
1312 std::vector<int64> response_ids_; 1312 std::vector<int64_t> response_ids_;
1313 1313
1314 protected: 1314 protected:
1315 ~DeleteDeletableResponseIdsTask() override {} 1315 ~DeleteDeletableResponseIdsTask() override {}
1316 }; 1316 };
1317 1317
1318 void AppCacheStorageImpl::DeleteDeletableResponseIdsTask::Run() { 1318 void AppCacheStorageImpl::DeleteDeletableResponseIdsTask::Run() {
1319 database_->DeleteDeletableResponseIds(response_ids_); 1319 database_->DeleteDeletableResponseIds(response_ids_);
1320 } 1320 }
1321 1321
1322 // LazyUpdateLastAccessTimeTask ------- 1322 // LazyUpdateLastAccessTimeTask -------
1323 1323
1324 class AppCacheStorageImpl::LazyUpdateLastAccessTimeTask 1324 class AppCacheStorageImpl::LazyUpdateLastAccessTimeTask
1325 : public DatabaseTask { 1325 : public DatabaseTask {
1326 public: 1326 public:
1327 LazyUpdateLastAccessTimeTask( 1327 LazyUpdateLastAccessTimeTask(
1328 AppCacheStorageImpl* storage, AppCacheGroup* group, base::Time time) 1328 AppCacheStorageImpl* storage, AppCacheGroup* group, base::Time time)
1329 : DatabaseTask(storage), group_id_(group->group_id()), 1329 : DatabaseTask(storage), group_id_(group->group_id()),
1330 last_access_time_(time) { 1330 last_access_time_(time) {
1331 storage->NotifyStorageAccessed(group->manifest_url().GetOrigin()); 1331 storage->NotifyStorageAccessed(group->manifest_url().GetOrigin());
1332 } 1332 }
1333 1333
1334 // DatabaseTask: 1334 // DatabaseTask:
1335 void Run() override; 1335 void Run() override;
1336 void RunCompleted() override; 1336 void RunCompleted() override;
1337 1337
1338 protected: 1338 protected:
1339 ~LazyUpdateLastAccessTimeTask() override {} 1339 ~LazyUpdateLastAccessTimeTask() override {}
1340 1340
1341 private: 1341 private:
1342 int64 group_id_; 1342 int64_t group_id_;
1343 base::Time last_access_time_; 1343 base::Time last_access_time_;
1344 }; 1344 };
1345 1345
1346 void AppCacheStorageImpl::LazyUpdateLastAccessTimeTask::Run() { 1346 void AppCacheStorageImpl::LazyUpdateLastAccessTimeTask::Run() {
1347 tracked_objects::ScopedTracker tracking_profile( 1347 tracked_objects::ScopedTracker tracking_profile(
1348 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1348 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1349 "AppCacheStorageImpl::LazyUpdateLastAccessTimeTask")); 1349 "AppCacheStorageImpl::LazyUpdateLastAccessTimeTask"));
1350 database_->LazyUpdateLastAccessTime(group_id_, last_access_time_); 1350 database_->LazyUpdateLastAccessTime(group_id_, last_access_time_);
1351 } 1351 }
1352 1352
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 first_evictable_error_time_(group->first_evictable_error_time()) { 1386 first_evictable_error_time_(group->first_evictable_error_time()) {
1387 } 1387 }
1388 1388
1389 // DatabaseTask: 1389 // DatabaseTask:
1390 void Run() override; 1390 void Run() override;
1391 1391
1392 protected: 1392 protected:
1393 ~UpdateEvictionTimesTask() override {} 1393 ~UpdateEvictionTimesTask() override {}
1394 1394
1395 private: 1395 private:
1396 int64 group_id_; 1396 int64_t group_id_;
1397 base::Time last_full_update_check_time_; 1397 base::Time last_full_update_check_time_;
1398 base::Time first_evictable_error_time_; 1398 base::Time first_evictable_error_time_;
1399 }; 1399 };
1400 1400
1401 void AppCacheStorageImpl::UpdateEvictionTimesTask::Run() { 1401 void AppCacheStorageImpl::UpdateEvictionTimesTask::Run() {
1402 tracked_objects::ScopedTracker tracking_profile( 1402 tracked_objects::ScopedTracker tracking_profile(
1403 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1403 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1404 "AppCacheStorageImpl::UpdateEvictionTimes")); 1404 "AppCacheStorageImpl::UpdateEvictionTimes"));
1405 database_->UpdateEvictionTimes(group_id_, 1405 database_->UpdateEvictionTimes(group_id_,
1406 last_full_update_check_time_, 1406 last_full_update_check_time_,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 task->Schedule(); 1474 task->Schedule();
1475 } 1475 }
1476 1476
1477 void AppCacheStorageImpl::GetAllInfo(Delegate* delegate) { 1477 void AppCacheStorageImpl::GetAllInfo(Delegate* delegate) {
1478 DCHECK(delegate); 1478 DCHECK(delegate);
1479 scoped_refptr<GetAllInfoTask> task(new GetAllInfoTask(this)); 1479 scoped_refptr<GetAllInfoTask> task(new GetAllInfoTask(this));
1480 task->AddDelegate(GetOrCreateDelegateReference(delegate)); 1480 task->AddDelegate(GetOrCreateDelegateReference(delegate));
1481 task->Schedule(); 1481 task->Schedule();
1482 } 1482 }
1483 1483
1484 void AppCacheStorageImpl::LoadCache(int64 id, Delegate* delegate) { 1484 void AppCacheStorageImpl::LoadCache(int64_t id, Delegate* delegate) {
1485 DCHECK(delegate); 1485 DCHECK(delegate);
1486 if (is_disabled_) { 1486 if (is_disabled_) {
1487 delegate->OnCacheLoaded(NULL, id); 1487 delegate->OnCacheLoaded(NULL, id);
1488 return; 1488 return;
1489 } 1489 }
1490 1490
1491 AppCache* cache = working_set_.GetCache(id); 1491 AppCache* cache = working_set_.GetCache(id);
1492 if (cache) { 1492 if (cache) {
1493 delegate->OnCacheLoaded(cache, id); 1493 delegate->OnCacheLoaded(cache, id);
1494 if (cache->owning_group()) { 1494 if (cache->owning_group()) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 &delegates, url, found_entry, 1660 &delegates, url, found_entry,
1661 GURL(), AppCacheEntry(), 1661 GURL(), AppCacheEntry(),
1662 cache.get() ? cache->cache_id() : kAppCacheNoCacheId, 1662 cache.get() ? cache->cache_id() : kAppCacheNoCacheId,
1663 group.get() ? group->group_id() : kAppCacheNoCacheId, 1663 group.get() ? group->group_id() : kAppCacheNoCacheId,
1664 group.get() ? group->manifest_url() : GURL()); 1664 group.get() ? group->manifest_url() : GURL());
1665 } 1665 }
1666 } 1666 }
1667 1667
1668 void AppCacheStorageImpl::CallOnMainResponseFound( 1668 void AppCacheStorageImpl::CallOnMainResponseFound(
1669 DelegateReferenceVector* delegates, 1669 DelegateReferenceVector* delegates,
1670 const GURL& url, const AppCacheEntry& entry, 1670 const GURL& url,
1671 const GURL& namespace_entry_url, const AppCacheEntry& fallback_entry, 1671 const AppCacheEntry& entry,
1672 int64 cache_id, int64 group_id, const GURL& manifest_url) { 1672 const GURL& namespace_entry_url,
1673 const AppCacheEntry& fallback_entry,
1674 int64_t cache_id,
1675 int64_t group_id,
1676 const GURL& manifest_url) {
1673 FOR_EACH_DELEGATE( 1677 FOR_EACH_DELEGATE(
1674 (*delegates), 1678 (*delegates),
1675 OnMainResponseFound(url, entry, 1679 OnMainResponseFound(url, entry,
1676 namespace_entry_url, fallback_entry, 1680 namespace_entry_url, fallback_entry,
1677 cache_id, group_id, manifest_url)); 1681 cache_id, group_id, manifest_url));
1678 } 1682 }
1679 1683
1680 void AppCacheStorageImpl::FindResponseForSubRequest( 1684 void AppCacheStorageImpl::FindResponseForSubRequest(
1681 AppCache* cache, const GURL& url, 1685 AppCache* cache, const GURL& url,
1682 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, 1686 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry,
(...skipping 11 matching lines...) Expand all
1694 } 1698 }
1695 1699
1696 GURL fallback_namespace_not_used; 1700 GURL fallback_namespace_not_used;
1697 GURL intercept_namespace_not_used; 1701 GURL intercept_namespace_not_used;
1698 cache->FindResponseForRequest( 1702 cache->FindResponseForRequest(
1699 url, found_entry, &intercept_namespace_not_used, 1703 url, found_entry, &intercept_namespace_not_used,
1700 found_fallback_entry, &fallback_namespace_not_used, 1704 found_fallback_entry, &fallback_namespace_not_used,
1701 found_network_namespace); 1705 found_network_namespace);
1702 } 1706 }
1703 1707
1704 void AppCacheStorageImpl::MarkEntryAsForeign( 1708 void AppCacheStorageImpl::MarkEntryAsForeign(const GURL& entry_url,
1705 const GURL& entry_url, int64 cache_id) { 1709 int64_t cache_id) {
1706 AppCache* cache = working_set_.GetCache(cache_id); 1710 AppCache* cache = working_set_.GetCache(cache_id);
1707 if (cache) { 1711 if (cache) {
1708 AppCacheEntry* entry = cache->GetEntry(entry_url); 1712 AppCacheEntry* entry = cache->GetEntry(entry_url);
1709 DCHECK(entry); 1713 DCHECK(entry);
1710 if (entry) 1714 if (entry)
1711 entry->add_types(AppCacheEntry::FOREIGN); 1715 entry->add_types(AppCacheEntry::FOREIGN);
1712 } 1716 }
1713 scoped_refptr<MarkEntryAsForeignTask> task( 1717 scoped_refptr<MarkEntryAsForeignTask> task(
1714 new MarkEntryAsForeignTask(this, entry_url, cache_id)); 1718 new MarkEntryAsForeignTask(this, entry_url, cache_id));
1715 task->Schedule(); 1719 task->Schedule();
(...skipping 10 matching lines...) Expand all
1726 task->Schedule(); 1730 task->Schedule();
1727 } 1731 }
1728 1732
1729 void AppCacheStorageImpl::StoreEvictionTimes(AppCacheGroup* group) { 1733 void AppCacheStorageImpl::StoreEvictionTimes(AppCacheGroup* group) {
1730 scoped_refptr<UpdateEvictionTimesTask> task( 1734 scoped_refptr<UpdateEvictionTimesTask> task(
1731 new UpdateEvictionTimesTask(this, group)); 1735 new UpdateEvictionTimesTask(this, group));
1732 task->Schedule(); 1736 task->Schedule();
1733 } 1737 }
1734 1738
1735 AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader( 1739 AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader(
1736 const GURL& manifest_url, int64 group_id, int64 response_id) { 1740 const GURL& manifest_url,
1741 int64_t group_id,
1742 int64_t response_id) {
1737 return new AppCacheResponseReader(response_id, group_id, disk_cache()); 1743 return new AppCacheResponseReader(response_id, group_id, disk_cache());
1738 } 1744 }
1739 1745
1740 AppCacheResponseWriter* AppCacheStorageImpl::CreateResponseWriter( 1746 AppCacheResponseWriter* AppCacheStorageImpl::CreateResponseWriter(
1741 const GURL& manifest_url, int64 group_id) { 1747 const GURL& manifest_url,
1748 int64_t group_id) {
1742 return new AppCacheResponseWriter(NewResponseId(), group_id, disk_cache()); 1749 return new AppCacheResponseWriter(NewResponseId(), group_id, disk_cache());
1743 } 1750 }
1744 1751
1745 AppCacheResponseMetadataWriter* 1752 AppCacheResponseMetadataWriter*
1746 AppCacheStorageImpl::CreateResponseMetadataWriter(int64 group_id, 1753 AppCacheStorageImpl::CreateResponseMetadataWriter(int64_t group_id,
1747 int64 response_id) { 1754 int64_t response_id) {
1748 return new AppCacheResponseMetadataWriter(response_id, group_id, 1755 return new AppCacheResponseMetadataWriter(response_id, group_id,
1749 disk_cache()); 1756 disk_cache());
1750 } 1757 }
1751 1758
1752 void AppCacheStorageImpl::DoomResponses( 1759 void AppCacheStorageImpl::DoomResponses(
1753 const GURL& manifest_url, const std::vector<int64>& response_ids) { 1760 const GURL& manifest_url,
1761 const std::vector<int64_t>& response_ids) {
1754 if (response_ids.empty()) 1762 if (response_ids.empty())
1755 return; 1763 return;
1756 1764
1757 // Start deleting them from the disk cache lazily. 1765 // Start deleting them from the disk cache lazily.
1758 StartDeletingResponses(response_ids); 1766 StartDeletingResponses(response_ids);
1759 1767
1760 // Also schedule a database task to record these ids in the 1768 // Also schedule a database task to record these ids in the
1761 // deletable responses table. 1769 // deletable responses table.
1762 // TODO(michaeln): There is a race here. If the browser crashes 1770 // TODO(michaeln): There is a race here. If the browser crashes
1763 // prior to committing these rows to the database and prior to us 1771 // prior to committing these rows to the database and prior to us
1764 // having deleted them from the disk cache, we'll never delete them. 1772 // having deleted them from the disk cache, we'll never delete them.
1765 scoped_refptr<InsertDeletableResponseIdsTask> task( 1773 scoped_refptr<InsertDeletableResponseIdsTask> task(
1766 new InsertDeletableResponseIdsTask(this)); 1774 new InsertDeletableResponseIdsTask(this));
1767 task->response_ids_ = response_ids; 1775 task->response_ids_ = response_ids;
1768 task->Schedule(); 1776 task->Schedule();
1769 } 1777 }
1770 1778
1771 void AppCacheStorageImpl::DeleteResponses( 1779 void AppCacheStorageImpl::DeleteResponses(
1772 const GURL& manifest_url, const std::vector<int64>& response_ids) { 1780 const GURL& manifest_url,
1781 const std::vector<int64_t>& response_ids) {
1773 if (response_ids.empty()) 1782 if (response_ids.empty())
1774 return; 1783 return;
1775 StartDeletingResponses(response_ids); 1784 StartDeletingResponses(response_ids);
1776 } 1785 }
1777 1786
1778 void AppCacheStorageImpl::DelayedStartDeletingUnusedResponses() { 1787 void AppCacheStorageImpl::DelayedStartDeletingUnusedResponses() {
1779 // Only if we haven't already begun. 1788 // Only if we haven't already begun.
1780 if (!did_start_deleting_responses_) { 1789 if (!did_start_deleting_responses_) {
1781 scoped_refptr<GetDeletableResponseIdsTask> task( 1790 scoped_refptr<GetDeletableResponseIdsTask> task(
1782 new GetDeletableResponseIdsTask(this, last_deletable_response_rowid_)); 1791 new GetDeletableResponseIdsTask(this, last_deletable_response_rowid_));
1783 task->Schedule(); 1792 task->Schedule();
1784 } 1793 }
1785 } 1794 }
1786 1795
1787 void AppCacheStorageImpl::StartDeletingResponses( 1796 void AppCacheStorageImpl::StartDeletingResponses(
1788 const std::vector<int64>& response_ids) { 1797 const std::vector<int64_t>& response_ids) {
1789 DCHECK(!response_ids.empty()); 1798 DCHECK(!response_ids.empty());
1790 did_start_deleting_responses_ = true; 1799 did_start_deleting_responses_ = true;
1791 deletable_response_ids_.insert( 1800 deletable_response_ids_.insert(
1792 deletable_response_ids_.end(), 1801 deletable_response_ids_.end(),
1793 response_ids.begin(), response_ids.end()); 1802 response_ids.begin(), response_ids.end());
1794 if (!is_response_deletion_scheduled_) 1803 if (!is_response_deletion_scheduled_)
1795 ScheduleDeleteOneResponse(); 1804 ScheduleDeleteOneResponse();
1796 } 1805 }
1797 1806
1798 void AppCacheStorageImpl::ScheduleDeleteOneResponse() { 1807 void AppCacheStorageImpl::ScheduleDeleteOneResponse() {
(...skipping 12 matching lines...) Expand all
1811 1820
1812 if (!disk_cache()) { 1821 if (!disk_cache()) {
1813 DCHECK(is_disabled_); 1822 DCHECK(is_disabled_);
1814 deletable_response_ids_.clear(); 1823 deletable_response_ids_.clear();
1815 deleted_response_ids_.clear(); 1824 deleted_response_ids_.clear();
1816 is_response_deletion_scheduled_ = false; 1825 is_response_deletion_scheduled_ = false;
1817 return; 1826 return;
1818 } 1827 }
1819 1828
1820 // TODO(michaeln): add group_id to DoomEntry args 1829 // TODO(michaeln): add group_id to DoomEntry args
1821 int64 id = deletable_response_ids_.front(); 1830 int64_t id = deletable_response_ids_.front();
1822 int rv = disk_cache_->DoomEntry( 1831 int rv = disk_cache_->DoomEntry(
1823 id, base::Bind(&AppCacheStorageImpl::OnDeletedOneResponse, 1832 id, base::Bind(&AppCacheStorageImpl::OnDeletedOneResponse,
1824 base::Unretained(this))); 1833 base::Unretained(this)));
1825 if (rv != net::ERR_IO_PENDING) 1834 if (rv != net::ERR_IO_PENDING)
1826 OnDeletedOneResponse(rv); 1835 OnDeletedOneResponse(rv);
1827 } 1836 }
1828 1837
1829 void AppCacheStorageImpl::OnDeletedOneResponse(int rv) { 1838 void AppCacheStorageImpl::OnDeletedOneResponse(int rv) {
1830 is_response_deletion_scheduled_ = false; 1839 is_response_deletion_scheduled_ = false;
1831 if (is_disabled_) 1840 if (is_disabled_)
1832 return; 1841 return;
1833 1842
1834 int64 id = deletable_response_ids_.front(); 1843 int64_t id = deletable_response_ids_.front();
1835 deletable_response_ids_.pop_front(); 1844 deletable_response_ids_.pop_front();
1836 if (rv != net::ERR_ABORTED) 1845 if (rv != net::ERR_ABORTED)
1837 deleted_response_ids_.push_back(id); 1846 deleted_response_ids_.push_back(id);
1838 1847
1839 const size_t kBatchSize = 50U; 1848 const size_t kBatchSize = 50U;
1840 if (deleted_response_ids_.size() >= kBatchSize || 1849 if (deleted_response_ids_.size() >= kBatchSize ||
1841 deletable_response_ids_.empty()) { 1850 deletable_response_ids_.empty()) {
1842 scoped_refptr<DeleteDeletableResponseIdsTask> task( 1851 scoped_refptr<DeleteDeletableResponseIdsTask> task(
1843 new DeleteDeletableResponseIdsTask(this)); 1852 new DeleteDeletableResponseIdsTask(this));
1844 task->response_ids_.swap(deleted_response_ids_); 1853 task->response_ids_.swap(deleted_response_ids_);
1845 task->Schedule(); 1854 task->Schedule();
1846 } 1855 }
1847 1856
1848 if (deletable_response_ids_.empty()) { 1857 if (deletable_response_ids_.empty()) {
1849 scoped_refptr<GetDeletableResponseIdsTask> task( 1858 scoped_refptr<GetDeletableResponseIdsTask> task(
1850 new GetDeletableResponseIdsTask(this, last_deletable_response_rowid_)); 1859 new GetDeletableResponseIdsTask(this, last_deletable_response_rowid_));
1851 task->Schedule(); 1860 task->Schedule();
1852 return; 1861 return;
1853 } 1862 }
1854 1863
1855 ScheduleDeleteOneResponse(); 1864 ScheduleDeleteOneResponse();
1856 } 1865 }
1857 1866
1858 AppCacheStorageImpl::CacheLoadTask* 1867 AppCacheStorageImpl::CacheLoadTask*
1859 AppCacheStorageImpl::GetPendingCacheLoadTask(int64 cache_id) { 1868 AppCacheStorageImpl::GetPendingCacheLoadTask(int64_t cache_id) {
1860 PendingCacheLoads::iterator found = pending_cache_loads_.find(cache_id); 1869 PendingCacheLoads::iterator found = pending_cache_loads_.find(cache_id);
1861 if (found != pending_cache_loads_.end()) 1870 if (found != pending_cache_loads_.end())
1862 return found->second; 1871 return found->second;
1863 return NULL; 1872 return NULL;
1864 } 1873 }
1865 1874
1866 AppCacheStorageImpl::GroupLoadTask* 1875 AppCacheStorageImpl::GroupLoadTask*
1867 AppCacheStorageImpl::GetPendingGroupLoadTask(const GURL& manifest_url) { 1876 AppCacheStorageImpl::GetPendingGroupLoadTask(const GURL& manifest_url) {
1868 PendingGroupLoads::iterator found = pending_group_loads_.find(manifest_url); 1877 PendingGroupLoads::iterator found = pending_group_loads_.find(manifest_url);
1869 if (found != pending_group_loads_.end()) 1878 if (found != pending_group_loads_.end())
1870 return found->second; 1879 return found->second;
1871 return NULL; 1880 return NULL;
1872 } 1881 }
1873 1882
1874 void AppCacheStorageImpl::GetPendingForeignMarkingsForCache( 1883 void AppCacheStorageImpl::GetPendingForeignMarkingsForCache(
1875 int64 cache_id, std::vector<GURL>* urls) { 1884 int64_t cache_id,
1885 std::vector<GURL>* urls) {
1876 PendingForeignMarkings::iterator iter = pending_foreign_markings_.begin(); 1886 PendingForeignMarkings::iterator iter = pending_foreign_markings_.begin();
1877 while (iter != pending_foreign_markings_.end()) { 1887 while (iter != pending_foreign_markings_.end()) {
1878 if (iter->second == cache_id) 1888 if (iter->second == cache_id)
1879 urls->push_back(iter->first); 1889 urls->push_back(iter->first);
1880 ++iter; 1890 ++iter;
1881 } 1891 }
1882 } 1892 }
1883 1893
1884 void AppCacheStorageImpl::ScheduleSimpleTask(const base::Closure& task) { 1894 void AppCacheStorageImpl::ScheduleSimpleTask(const base::Closure& task) {
1885 pending_simple_tasks_.push_back(task); 1895 pending_simple_tasks_.push_back(task);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 1989
1980 void AppCacheStorageImpl::OnLazyCommitTimer() { 1990 void AppCacheStorageImpl::OnLazyCommitTimer() {
1981 lazy_commit_timer_.Stop(); 1991 lazy_commit_timer_.Stop();
1982 if (is_disabled()) 1992 if (is_disabled())
1983 return; 1993 return;
1984 scoped_refptr<DatabaseTask> task(new CommitLastAccessTimesTask(this)); 1994 scoped_refptr<DatabaseTask> task(new CommitLastAccessTimesTask(this));
1985 task->Schedule(); 1995 task->Schedule();
1986 } 1996 }
1987 1997
1988 } // namespace content 1998 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.h ('k') | content/browser/appcache/appcache_storage_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698