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 <deque> | 7 #include <deque> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 const FilePath& profile_path, | 508 const FilePath& profile_path, |
| 509 base::MessageLoopProxy* io_thread, | 509 base::MessageLoopProxy* io_thread, |
| 510 base::MessageLoopProxy* db_thread) | 510 base::MessageLoopProxy* db_thread) |
| 511 : is_incognito_(is_incognito), | 511 : is_incognito_(is_incognito), |
| 512 profile_path_(profile_path), | 512 profile_path_(profile_path), |
| 513 proxy_(new QuotaManagerProxy( | 513 proxy_(new QuotaManagerProxy( |
| 514 ALLOW_THIS_IN_INITIALIZER_LIST(this), io_thread)), | 514 ALLOW_THIS_IN_INITIALIZER_LIST(this), io_thread)), |
| 515 db_disabled_(false), | 515 db_disabled_(false), |
| 516 io_thread_(io_thread), | 516 io_thread_(io_thread), |
| 517 db_thread_(db_thread), | 517 db_thread_(db_thread), |
| 518 num_deletion_requested_clients_(0), | |
| 519 num_deleted_clients_(0), | |
| 518 temporary_global_quota_(-1) { | 520 temporary_global_quota_(-1) { |
| 519 } | 521 } |
| 520 | 522 |
| 521 QuotaManager::~QuotaManager() { | 523 QuotaManager::~QuotaManager() { |
| 522 DCHECK(io_thread_->BelongsToCurrentThread()); | 524 DCHECK(io_thread_->BelongsToCurrentThread()); |
| 523 proxy_->manager_ = NULL; | 525 proxy_->manager_ = NULL; |
| 524 std::for_each(clients_.begin(), clients_.end(), | 526 std::for_each(clients_.begin(), clients_.end(), |
| 525 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); | 527 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); |
| 526 if (database_.get()) | 528 if (database_.get()) |
| 527 db_thread_->DeleteSoon(FROM_HERE, database_.release()); | 529 db_thread_->DeleteSoon(FROM_HERE, database_.release()); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 if (db_disabled_) { | 730 if (db_disabled_) { |
| 729 callback->Run(GURL()); | 731 callback->Run(GURL()); |
| 730 delete callback; | 732 delete callback; |
| 731 return; | 733 return; |
| 732 } | 734 } |
| 733 scoped_refptr<GetLRUOriginTask> task(new GetLRUOriginTask( | 735 scoped_refptr<GetLRUOriginTask> task(new GetLRUOriginTask( |
| 734 this, database_.get(), db_thread_, type, origins_in_use_, callback)); | 736 this, database_.get(), db_thread_, type, origins_in_use_, callback)); |
| 735 task->Start(); | 737 task->Start(); |
| 736 } | 738 } |
| 737 | 739 |
| 740 void QuotaManager::OnOriginDataEvicted( | |
| 741 QuotaStatusCode status, | |
| 742 EvictOriginDataCallback* callback) { | |
|
kinuko
2011/05/17 09:48:55
This method won't take the callback parameter for
Dai Mikurube (NOT FULLTIME)
2011/05/18 04:34:48
Done.
| |
| 743 LOG(ERROR) << "QM::OnOriginDataDeleted"; | |
| 744 DCHECK(io_thread_->BelongsToCurrentThread()); | |
| 745 | |
| 746 if (status != kQuotaStatusOk) { | |
| 747 // TODO(dmikurube): Handle error. | |
| 748 } | |
| 749 | |
| 750 ++num_deleted_clients_; | |
| 751 DCHECK(num_deleted_clients_ <= num_deletion_requested_clients_); | |
| 752 if (num_deleted_clients_ == num_deletion_requested_clients_) { | |
| 753 num_deletion_requested_clients_ = 0; | |
| 754 num_deleted_clients_ = 0; | |
| 755 | |
| 756 // TODO(dmikurube): Get usage, quota and physical space and then callback. | |
|
kinuko
2011/05/17 09:48:55
This comment is obsoleted?
Dai Mikurube (NOT FULLTIME)
2011/05/18 04:34:48
Done.
| |
| 757 callback->Run(kQuotaStatusOk); | |
| 758 delete callback; | |
| 759 } | |
| 760 } | |
| 761 | |
| 738 void QuotaManager::EvictOriginData( | 762 void QuotaManager::EvictOriginData( |
| 739 const GURL& origin, | 763 const GURL& origin, |
| 740 StorageType type, | 764 StorageType type, |
| 741 EvictOriginDataCallback* callback) { | 765 EvictOriginDataCallback* callback) { |
| 742 // TODO(dmikurube): Implement it. | 766 LOG(ERROR) << "QM::DeleteOriginData"; |
| 767 DCHECK(io_thread_->BelongsToCurrentThread()); | |
| 768 LazyInitialize(); | |
|
kinuko
2011/05/17 09:48:55
Eviction must run after temporary storage initiali
Dai Mikurube (NOT FULLTIME)
2011/05/18 04:34:48
Done.
| |
| 769 | |
| 770 int num_clients = clients_.size(); | |
| 771 | |
| 772 if (origin.is_empty() || num_clients == 0 || num_deleted_clients_ > 0) { | |
|
kinuko
2011/05/17 09:48:55
As michael pointed out please DCHECK on num_delete
Dai Mikurube (NOT FULLTIME)
2011/05/18 04:34:48
Done.
I don't understand the second paragraph...
| |
| 773 callback->Run(kQuotaStatusOk); | |
| 774 delete callback; | |
| 775 return; | |
| 776 } | |
| 777 | |
| 778 num_deletion_requested_clients_ = num_clients; | |
| 779 num_deleted_clients_ = 0; | |
| 780 | |
| 781 for (QuotaClientList::iterator p = clients_.begin(); | |
| 782 p != clients_.end(); | |
| 783 ++p) { | |
| 784 /* | |
| 785 p->DeleteOriginData(origin, kStorageTypeTemporary, NewRunnableMethod( | |
| 786 this, &QuotaManager::OnOriginDataDeleted)); | |
| 787 */ | |
| 788 OnOriginDataEvicted(kQuotaStatusOk, callback); // test. | |
| 789 } | |
| 743 } | 790 } |
| 744 | 791 |
| 745 void QuotaManager::GetUsageAndQuotaForEviction( | 792 void QuotaManager::GetUsageAndQuotaForEviction( |
| 746 GetUsageAndQuotaForEvictionCallback* callback) { | 793 GetUsageAndQuotaForEvictionCallback* callback) { |
| 747 // TODO(dmikurube): Implement it. | 794 // TODO(dmikurube): Implement it. |
| 748 } | 795 } |
| 749 | 796 |
| 750 void QuotaManager::DeleteOnCorrectThread() const { | 797 void QuotaManager::DeleteOnCorrectThread() const { |
| 751 if (!io_thread_->BelongsToCurrentThread()) { | 798 if (!io_thread_->BelongsToCurrentThread()) { |
| 752 io_thread_->DeleteSoon(FROM_HERE, this); | 799 io_thread_->DeleteSoon(FROM_HERE, this); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 | 887 |
| 841 QuotaManagerProxy::QuotaManagerProxy( | 888 QuotaManagerProxy::QuotaManagerProxy( |
| 842 QuotaManager* manager, base::MessageLoopProxy* io_thread) | 889 QuotaManager* manager, base::MessageLoopProxy* io_thread) |
| 843 : manager_(manager), io_thread_(io_thread) { | 890 : manager_(manager), io_thread_(io_thread) { |
| 844 } | 891 } |
| 845 | 892 |
| 846 QuotaManagerProxy::~QuotaManagerProxy() { | 893 QuotaManagerProxy::~QuotaManagerProxy() { |
| 847 } | 894 } |
| 848 | 895 |
| 849 } // namespace quota | 896 } // namespace quota |
| OLD | NEW |