| OLD | NEW |
| 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 "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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 return avail_space * kTemporaryQuotaRatioToAvail; | 347 return avail_space * kTemporaryQuotaRatioToAvail; |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Subclasses must call following methods to create a new 'waitable' | 350 // Subclasses must call following methods to create a new 'waitable' |
| 351 // callback, which decrements waiting_callbacks when it is called. | 351 // callback, which decrements waiting_callbacks when it is called. |
| 352 GlobalUsageCallback NewWaitableGlobalUsageCallback() { | 352 GlobalUsageCallback NewWaitableGlobalUsageCallback() { |
| 353 ++waiting_callbacks_; | 353 ++waiting_callbacks_; |
| 354 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetGlobalUsage, | 354 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetGlobalUsage, |
| 355 weak_factory_.GetWeakPtr()); | 355 weak_factory_.GetWeakPtr()); |
| 356 } | 356 } |
| 357 HostUsageCallback NewWaitableHostUsageCallback() { | 357 UsageCallback NewWaitableHostUsageCallback() { |
| 358 ++waiting_callbacks_; | 358 ++waiting_callbacks_; |
| 359 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetHostUsage, | 359 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetHostUsage, |
| 360 weak_factory_.GetWeakPtr()); | 360 weak_factory_.GetWeakPtr(), host(), type()); |
| 361 } | 361 } |
| 362 HostQuotaCallback NewWaitableHostQuotaCallback() { | 362 HostQuotaCallback NewWaitableHostQuotaCallback() { |
| 363 ++waiting_callbacks_; | 363 ++waiting_callbacks_; |
| 364 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetHostQuota, | 364 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetHostQuota, |
| 365 weak_factory_.GetWeakPtr()); | 365 weak_factory_.GetWeakPtr()); |
| 366 } | 366 } |
| 367 AvailableSpaceCallback NewWaitableAvailableSpaceCallback() { | 367 AvailableSpaceCallback NewWaitableAvailableSpaceCallback() { |
| 368 ++waiting_callbacks_; | 368 ++waiting_callbacks_; |
| 369 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetAvailableSpace, | 369 return base::Bind(&UsageAndQuotaDispatcherTask::DidGetAvailableSpace, |
| 370 weak_factory_.GetWeakPtr()); | 370 weak_factory_.GetWeakPtr()); |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 void QuotaManager::GetGlobalUsage(StorageType type, | 1074 void QuotaManager::GetGlobalUsage(StorageType type, |
| 1075 const GlobalUsageCallback& callback) { | 1075 const GlobalUsageCallback& callback) { |
| 1076 LazyInitialize(); | 1076 LazyInitialize(); |
| 1077 GetUsageTracker(type)->GetGlobalUsage(callback); | 1077 GetUsageTracker(type)->GetGlobalUsage(callback); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 void QuotaManager::GetHostUsage(const std::string& host, | 1080 void QuotaManager::GetHostUsage(const std::string& host, |
| 1081 StorageType type, | 1081 StorageType type, |
| 1082 const HostUsageCallback& callback) { | 1082 const UsageCallback& callback) { |
| 1083 LazyInitialize(); | 1083 LazyInitialize(); |
| 1084 GetUsageTracker(type)->GetHostUsage(host, callback); | 1084 GetUsageTracker(type)->GetHostUsage(host, callback); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 void QuotaManager::GetStatistics( | 1087 void QuotaManager::GetStatistics( |
| 1088 std::map<std::string, std::string>* statistics) { | 1088 std::map<std::string, std::string>* statistics) { |
| 1089 DCHECK(statistics); | 1089 DCHECK(statistics); |
| 1090 if (temporary_storage_evictor_.get()) { | 1090 if (temporary_storage_evictor_.get()) { |
| 1091 std::map<std::string, int64> stats; | 1091 std::map<std::string, int64> stats; |
| 1092 temporary_storage_evictor_->GetStatistics(&stats); | 1092 temporary_storage_evictor_->GetStatistics(&stats); |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 | 1697 |
| 1698 QuotaManagerProxy::QuotaManagerProxy( | 1698 QuotaManagerProxy::QuotaManagerProxy( |
| 1699 QuotaManager* manager, base::SingleThreadTaskRunner* io_thread) | 1699 QuotaManager* manager, base::SingleThreadTaskRunner* io_thread) |
| 1700 : manager_(manager), io_thread_(io_thread) { | 1700 : manager_(manager), io_thread_(io_thread) { |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 QuotaManagerProxy::~QuotaManagerProxy() { | 1703 QuotaManagerProxy::~QuotaManagerProxy() { |
| 1704 } | 1704 } |
| 1705 | 1705 |
| 1706 } // namespace quota | 1706 } // namespace quota |
| OLD | NEW |