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

Side by Side Diff: webkit/quota/quota_manager.cc

Issue 7039006: Implement GetUsageAndQuotaForEviction in QuotaManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Reflected the comments. Created 9 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 | Annotate | Revision Log
OLDNEW
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
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 temporary_global_quota_(-1),
528 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
528 } 529 }
529 530
530 QuotaManager::~QuotaManager() { 531 QuotaManager::~QuotaManager() {
531 DCHECK(io_thread_->BelongsToCurrentThread()); 532 DCHECK(io_thread_->BelongsToCurrentThread());
532 proxy_->manager_ = NULL; 533 proxy_->manager_ = NULL;
533 std::for_each(clients_.begin(), clients_.end(), 534 std::for_each(clients_.begin(), clients_.end(),
534 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); 535 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed));
535 if (database_.get()) 536 if (database_.get())
536 db_thread_->DeleteSoon(FROM_HERE, database_.release()); 537 db_thread_->DeleteSoon(FROM_HERE, database_.release());
537 } 538 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 task->Start(); 774 task->Start();
774 } 775 }
775 776
776 void QuotaManager::EvictOriginData( 777 void QuotaManager::EvictOriginData(
777 const GURL& origin, 778 const GURL& origin,
778 StorageType type, 779 StorageType type,
779 EvictOriginDataCallback* callback) { 780 EvictOriginDataCallback* callback) {
780 // TODO(dmikurube): Implement it. 781 // TODO(dmikurube): Implement it.
781 } 782 }
782 783
784 void QuotaManager::DidGetAvailableSpaceForEviction(
785 QuotaStatusCode status,
786 int64 available_space) {
787 eviction_context_.get_usage_and_quota_callback->Run(status,
788 eviction_context_.usage, eviction_context_.quota, available_space);
789 eviction_context_.get_usage_and_quota_callback.reset();
790 }
791
792 void QuotaManager::DidGetGlobalQuotaForEviction(
793 QuotaStatusCode status,
794 int64 quota) {
795 if (status != kQuotaStatusOk) {
796 eviction_context_.get_usage_and_quota_callback->Run(status,
797 eviction_context_.usage, quota, 0);
798 eviction_context_.get_usage_and_quota_callback.reset();
799 return;
800 }
801
802 eviction_context_.quota = quota;
803 GetAvailableSpace(callback_factory_.
804 NewCallback(&QuotaManager::DidGetAvailableSpaceForEviction));
805 }
806
807 void QuotaManager::DidGetGlobalUsageForEviction(int64 usage) {
808 eviction_context_.usage = usage;
809 GetTemporaryGlobalQuota(callback_factory_.
810 NewCallback(&QuotaManager::DidGetGlobalQuotaForEviction));
811 }
812
783 void QuotaManager::GetUsageAndQuotaForEviction( 813 void QuotaManager::GetUsageAndQuotaForEviction(
784 GetUsageAndQuotaForEvictionCallback* callback) { 814 GetUsageAndQuotaForEvictionCallback* callback) {
785 // TODO(dmikurube): Implement it. 815 DCHECK(io_thread_->BelongsToCurrentThread());
816
kinuko 2011/05/18 10:02:45 DCHECK(!get_usage_and_quota_callback.get()) here?
Dai Mikurube (NOT FULLTIME) 2011/05/18 11:35:25 Done.
817 eviction_context_.get_usage_and_quota_callback.reset(callback);
818 // TODO(dmikurube): Make kStorageTypeTemporary an argument?
819 GetGlobalUsage(kStorageTypeTemporary, callback_factory_.
820 NewCallback(&QuotaManager::DidGetGlobalUsageForEviction));
786 } 821 }
787 822
788 void QuotaManager::DeleteOnCorrectThread() const { 823 void QuotaManager::DeleteOnCorrectThread() const {
789 if (!io_thread_->BelongsToCurrentThread()) { 824 if (!io_thread_->BelongsToCurrentThread()) {
790 io_thread_->DeleteSoon(FROM_HERE, this); 825 io_thread_->DeleteSoon(FROM_HERE, this);
791 return; 826 return;
792 } 827 }
793 delete this; 828 delete this;
794 } 829 }
795 830
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 913
879 QuotaManagerProxy::QuotaManagerProxy( 914 QuotaManagerProxy::QuotaManagerProxy(
880 QuotaManager* manager, base::MessageLoopProxy* io_thread) 915 QuotaManager* manager, base::MessageLoopProxy* io_thread)
881 : manager_(manager), io_thread_(io_thread) { 916 : manager_(manager), io_thread_(io_thread) {
882 } 917 }
883 918
884 QuotaManagerProxy::~QuotaManagerProxy() { 919 QuotaManagerProxy::~QuotaManagerProxy() {
885 } 920 }
886 921
887 } // namespace quota 922 } // namespace quota
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698