Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/quota/quota_manager.h" | 5 #include "webkit/quota/quota_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 const FilePath& profile_path, | 517 const FilePath& profile_path, |
| 518 base::MessageLoopProxy* io_thread, | 518 base::MessageLoopProxy* io_thread, |
| 519 base::MessageLoopProxy* db_thread) | 519 base::MessageLoopProxy* db_thread) |
| 520 : is_incognito_(is_incognito), | 520 : is_incognito_(is_incognito), |
| 521 profile_path_(profile_path), | 521 profile_path_(profile_path), |
| 522 proxy_(new QuotaManagerProxy( | 522 proxy_(new QuotaManagerProxy( |
| 523 ALLOW_THIS_IN_INITIALIZER_LIST(this), io_thread)), | 523 ALLOW_THIS_IN_INITIALIZER_LIST(this), io_thread)), |
| 524 db_disabled_(false), | 524 db_disabled_(false), |
| 525 io_thread_(io_thread), | 525 io_thread_(io_thread), |
| 526 db_thread_(db_thread), | 526 db_thread_(db_thread), |
| 527 temporary_global_quota_(-1) { | 527 usage_for_eviction_(0), |
| 528 quota_for_eviction_(0), | |
|
kinuko
2011/05/18 06:26:55
Now I seriously started wondering if we could have
Dai Mikurube (NOT FULLTIME)
2011/05/18 06:37:20
I agree with that, but how about doing that later
| |
| 529 temporary_global_quota_(-1), | |
| 530 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | |
| 528 } | 531 } |
| 529 | 532 |
| 530 QuotaManager::~QuotaManager() { | 533 QuotaManager::~QuotaManager() { |
| 531 DCHECK(io_thread_->BelongsToCurrentThread()); | 534 DCHECK(io_thread_->BelongsToCurrentThread()); |
| 532 proxy_->manager_ = NULL; | 535 proxy_->manager_ = NULL; |
| 533 std::for_each(clients_.begin(), clients_.end(), | 536 std::for_each(clients_.begin(), clients_.end(), |
| 534 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); | 537 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); |
| 535 if (database_.get()) | 538 if (database_.get()) |
| 536 db_thread_->DeleteSoon(FROM_HERE, database_.release()); | 539 db_thread_->DeleteSoon(FROM_HERE, database_.release()); |
| 537 } | 540 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 task->Start(); | 776 task->Start(); |
| 774 } | 777 } |
| 775 | 778 |
| 776 void QuotaManager::EvictOriginData( | 779 void QuotaManager::EvictOriginData( |
| 777 const GURL& origin, | 780 const GURL& origin, |
| 778 StorageType type, | 781 StorageType type, |
| 779 EvictOriginDataCallback* callback) { | 782 EvictOriginDataCallback* callback) { |
| 780 // TODO(dmikurube): Implement it. | 783 // TODO(dmikurube): Implement it. |
| 781 } | 784 } |
| 782 | 785 |
| 786 void QuotaManager::OnGetAvailableSpaceForEviction( | |
| 787 QuotaStatusCode status, | |
| 788 int64 available_space) { | |
| 789 get_usage_and_quota_for_eviction_callback_->Run(status, | |
| 790 usage_for_eviction_, quota_for_eviction_, available_space); | |
| 791 get_usage_and_quota_for_eviction_callback_.reset(); | |
| 792 } | |
| 793 | |
| 794 void QuotaManager::OnGetGlobalQuotaForEviction( | |
| 795 QuotaStatusCode status, | |
| 796 int64 quota) { | |
| 797 if (status != kQuotaStatusOk) { | |
| 798 get_usage_and_quota_for_eviction_callback_->Run(status, | |
| 799 usage_for_eviction_, quota, 0); | |
| 800 get_usage_and_quota_for_eviction_callback_.reset(); | |
| 801 return; | |
| 802 } | |
| 803 | |
| 804 quota_for_eviction_ = quota; | |
| 805 GetAvailableSpace(callback_factory_. | |
| 806 NewCallback(&QuotaManager::OnGetAvailableSpaceForEviction)); | |
|
kinuko
2011/05/18 06:26:55
We could call all those async methods at once and
Dai Mikurube (NOT FULLTIME)
2011/05/18 06:37:20
Is that a serious requirement? Calling them async
| |
| 807 } | |
| 808 | |
| 809 void QuotaManager::OnGetGlobalUsageForEviction(int64 usage) { | |
| 810 usage_for_eviction_ = usage; | |
| 811 GetTemporaryGlobalQuota(callback_factory_. | |
| 812 NewCallback(&QuotaManager::OnGetGlobalQuotaForEviction)); | |
| 813 } | |
| 814 | |
| 783 void QuotaManager::GetUsageAndQuotaForEviction( | 815 void QuotaManager::GetUsageAndQuotaForEviction( |
| 784 GetUsageAndQuotaForEvictionCallback* callback) { | 816 GetUsageAndQuotaForEvictionCallback* callback) { |
| 785 // TODO(dmikurube): Implement it. | 817 DCHECK(io_thread_->BelongsToCurrentThread()); |
| 818 | |
| 819 get_usage_and_quota_for_eviction_callback_.reset(callback); | |
| 820 // TODO(dmikurube): Make kStorageTypeTemporary an argument? | |
|
kinuko
2011/05/18 06:26:55
I think we should either add or drop the type para
Dai Mikurube (NOT FULLTIME)
2011/05/18 06:37:20
I think we might want to do that as a refactoring
| |
| 821 GetGlobalUsage(kStorageTypeTemporary, callback_factory_. | |
| 822 NewCallback(&QuotaManager::OnGetGlobalUsageForEviction)); | |
| 786 } | 823 } |
| 787 | 824 |
| 788 void QuotaManager::DeleteOnCorrectThread() const { | 825 void QuotaManager::DeleteOnCorrectThread() const { |
| 789 if (!io_thread_->BelongsToCurrentThread()) { | 826 if (!io_thread_->BelongsToCurrentThread()) { |
| 790 io_thread_->DeleteSoon(FROM_HERE, this); | 827 io_thread_->DeleteSoon(FROM_HERE, this); |
| 791 return; | 828 return; |
| 792 } | 829 } |
| 793 delete this; | 830 delete this; |
| 794 } | 831 } |
| 795 | 832 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 | 915 |
| 879 QuotaManagerProxy::QuotaManagerProxy( | 916 QuotaManagerProxy::QuotaManagerProxy( |
| 880 QuotaManager* manager, base::MessageLoopProxy* io_thread) | 917 QuotaManager* manager, base::MessageLoopProxy* io_thread) |
| 881 : manager_(manager), io_thread_(io_thread) { | 918 : manager_(manager), io_thread_(io_thread) { |
| 882 } | 919 } |
| 883 | 920 |
| 884 QuotaManagerProxy::~QuotaManagerProxy() { | 921 QuotaManagerProxy::~QuotaManagerProxy() { |
| 885 } | 922 } |
| 886 | 923 |
| 887 } // namespace quota | 924 } // namespace quota |
| OLD | NEW |