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

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

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 years, 4 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 | Annotate | Revision Log
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 <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 NOTREACHED() << "A existing group without a cache is unexpected"; 66 NOTREACHED() << "A existing group without a cache is unexpected";
67 success = database->DeleteGroup(group_id); 67 success = database->DeleteGroup(group_id);
68 } 68 }
69 return success; 69 return success;
70 } 70 }
71 71
72 // Destroys |database|. If there is appcache data to be deleted 72 // Destroys |database|. If there is appcache data to be deleted
73 // (|force_keep_session_state| is false), deletes session-only appcache data. 73 // (|force_keep_session_state| is false), deletes session-only appcache data.
74 void ClearSessionOnlyOrigins( 74 void ClearSessionOnlyOrigins(
75 AppCacheDatabase* database, 75 AppCacheDatabase* database,
76 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, 76 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy,
77 bool force_keep_session_state) { 77 bool force_keep_session_state) {
78 scoped_ptr<AppCacheDatabase> database_to_delete(database); 78 scoped_ptr<AppCacheDatabase> database_to_delete(database);
79 79
80 // If saving session state, only delete the database. 80 // If saving session state, only delete the database.
81 if (force_keep_session_state) 81 if (force_keep_session_state)
82 return; 82 return;
83 83
84 bool has_session_only_appcaches = 84 bool has_session_only_appcaches =
85 special_storage_policy && 85 special_storage_policy &&
86 special_storage_policy->HasSessionOnlyOrigins(); 86 special_storage_policy->HasSessionOnlyOrigins();
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 } 584 }
585 585
586 // StoreGroupAndCacheTask ------- 586 // StoreGroupAndCacheTask -------
587 587
588 class AppCacheStorageImpl::StoreGroupAndCacheTask : public StoreOrLoadTask { 588 class AppCacheStorageImpl::StoreGroupAndCacheTask : public StoreOrLoadTask {
589 public: 589 public:
590 StoreGroupAndCacheTask(AppCacheStorageImpl* storage, AppCacheGroup* group, 590 StoreGroupAndCacheTask(AppCacheStorageImpl* storage, AppCacheGroup* group,
591 AppCache* newest_cache); 591 AppCache* newest_cache);
592 592
593 void GetQuotaThenSchedule(); 593 void GetQuotaThenSchedule();
594 void OnQuotaCallback( 594 void OnQuotaCallback(storage::QuotaStatusCode status,
595 quota::QuotaStatusCode status, int64 usage, int64 quota); 595 int64 usage,
596 int64 quota);
596 597
597 // DatabaseTask: 598 // DatabaseTask:
598 virtual void Run() OVERRIDE; 599 virtual void Run() OVERRIDE;
599 virtual void RunCompleted() OVERRIDE; 600 virtual void RunCompleted() OVERRIDE;
600 virtual void CancelCompletion() OVERRIDE; 601 virtual void CancelCompletion() OVERRIDE;
601 602
602 protected: 603 protected:
603 virtual ~StoreGroupAndCacheTask() {} 604 virtual ~StoreGroupAndCacheTask() {}
604 605
605 private: 606 private:
(...skipping 16 matching lines...) Expand all
622 group_record_.origin = group_record_.manifest_url.GetOrigin(); 623 group_record_.origin = group_record_.manifest_url.GetOrigin();
623 newest_cache->ToDatabaseRecords( 624 newest_cache->ToDatabaseRecords(
624 group, 625 group,
625 &cache_record_, &entry_records_, 626 &cache_record_, &entry_records_,
626 &intercept_namespace_records_, 627 &intercept_namespace_records_,
627 &fallback_namespace_records_, 628 &fallback_namespace_records_,
628 &online_whitelist_records_); 629 &online_whitelist_records_);
629 } 630 }
630 631
631 void AppCacheStorageImpl::StoreGroupAndCacheTask::GetQuotaThenSchedule() { 632 void AppCacheStorageImpl::StoreGroupAndCacheTask::GetQuotaThenSchedule() {
632 quota::QuotaManager* quota_manager = NULL; 633 storage::QuotaManager* quota_manager = NULL;
633 if (storage_->service()->quota_manager_proxy()) { 634 if (storage_->service()->quota_manager_proxy()) {
634 quota_manager = 635 quota_manager =
635 storage_->service()->quota_manager_proxy()->quota_manager(); 636 storage_->service()->quota_manager_proxy()->quota_manager();
636 } 637 }
637 638
638 if (!quota_manager) { 639 if (!quota_manager) {
639 if (storage_->service()->special_storage_policy() && 640 if (storage_->service()->special_storage_policy() &&
640 storage_->service()->special_storage_policy()->IsStorageUnlimited( 641 storage_->service()->special_storage_policy()->IsStorageUnlimited(
641 group_record_.origin)) 642 group_record_.origin))
642 space_available_ = kint64max; 643 space_available_ = kint64max;
643 Schedule(); 644 Schedule();
644 return; 645 return;
645 } 646 }
646 647
647 // We have to ask the quota manager for the value. 648 // We have to ask the quota manager for the value.
648 storage_->pending_quota_queries_.insert(this); 649 storage_->pending_quota_queries_.insert(this);
649 quota_manager->GetUsageAndQuota( 650 quota_manager->GetUsageAndQuota(
650 group_record_.origin, quota::kStorageTypeTemporary, 651 group_record_.origin,
652 storage::kStorageTypeTemporary,
651 base::Bind(&StoreGroupAndCacheTask::OnQuotaCallback, this)); 653 base::Bind(&StoreGroupAndCacheTask::OnQuotaCallback, this));
652 } 654 }
653 655
654 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback( 656 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback(
655 quota::QuotaStatusCode status, int64 usage, int64 quota) { 657 storage::QuotaStatusCode status,
658 int64 usage,
659 int64 quota) {
656 if (storage_) { 660 if (storage_) {
657 if (status == quota::kQuotaStatusOk) 661 if (status == storage::kQuotaStatusOk)
658 space_available_ = std::max(static_cast<int64>(0), quota - usage); 662 space_available_ = std::max(static_cast<int64>(0), quota - usage);
659 else 663 else
660 space_available_ = 0; 664 space_available_ = 0;
661 storage_->pending_quota_queries_.erase(this); 665 storage_->pending_quota_queries_.erase(this);
662 Schedule(); 666 Schedule();
663 } 667 }
664 } 668 }
665 669
666 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { 670 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() {
667 DCHECK(!success_); 671 DCHECK(!success_);
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 base::Bind(&AppCacheStorageImpl::CallScheduleReinitialize, 1857 base::Bind(&AppCacheStorageImpl::CallScheduleReinitialize,
1854 weak_factory_.GetWeakPtr())); 1858 weak_factory_.GetWeakPtr()));
1855 } 1859 }
1856 1860
1857 void AppCacheStorageImpl::CallScheduleReinitialize() { 1861 void AppCacheStorageImpl::CallScheduleReinitialize() {
1858 service_->ScheduleReinitialize(); 1862 service_->ScheduleReinitialize();
1859 // note: 'this' may be deleted at this point. 1863 // note: 'this' may be deleted at this point.
1860 } 1864 }
1861 1865
1862 } // namespace content 1866 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage.cc ('k') | content/browser/appcache/appcache_storage_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698