| 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 "chrome/browser/ui/webui/quota_internals/quota_internals_proxy.h" | 5 #include "chrome/browser/ui/webui/quota_internals/quota_internals_proxy.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 void QuotaInternalsProxy::RequestInfo( | 25 void QuotaInternalsProxy::RequestInfo( |
| 26 scoped_refptr<storage::QuotaManager> quota_manager) { | 26 scoped_refptr<storage::QuotaManager> quota_manager) { |
| 27 DCHECK(quota_manager.get()); | 27 DCHECK(quota_manager.get()); |
| 28 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 28 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 29 BrowserThread::PostTask( | 29 BrowserThread::PostTask( |
| 30 BrowserThread::IO, FROM_HERE, | 30 BrowserThread::IO, FROM_HERE, |
| 31 base::Bind(&QuotaInternalsProxy::RequestInfo, this, quota_manager)); | 31 base::Bind(&QuotaInternalsProxy::RequestInfo, this, quota_manager)); |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 quota_manager_ = quota_manager; | 34 quota_manager_ = quota_manager; |
| 35 { |
| 36 // crbug.com/349708 |
| 37 TRACE_EVENT0("io", "QuotaInternalsProxy::RequestInfo"); |
| 35 | 38 |
| 36 quota_manager_->GetQuotaSettings(base::Bind( | 39 quota_manager_->GetAvailableSpace( |
| 37 &QuotaInternalsProxy::DidGetSettings, weak_factory_.GetWeakPtr())); | 40 base::Bind(&QuotaInternalsProxy::DidGetAvailableSpace, |
| 41 weak_factory_.GetWeakPtr())); |
| 42 } |
| 38 | 43 |
| 39 quota_manager_->GetStorageCapacity(base::Bind( | 44 quota_manager_->GetTemporaryGlobalQuota( |
| 40 &QuotaInternalsProxy::DidGetCapacity, weak_factory_.GetWeakPtr())); | 45 base::Bind(&QuotaInternalsProxy::DidGetGlobalQuota, |
| 46 weak_factory_.GetWeakPtr(), |
| 47 storage::kStorageTypeTemporary)); |
| 41 | 48 |
| 42 quota_manager_->GetGlobalUsage( | 49 quota_manager_->GetGlobalUsage( |
| 43 storage::kStorageTypeTemporary, | 50 storage::kStorageTypeTemporary, |
| 44 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage, | 51 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage, |
| 45 weak_factory_.GetWeakPtr(), | 52 weak_factory_.GetWeakPtr(), |
| 46 storage::kStorageTypeTemporary)); | 53 storage::kStorageTypeTemporary)); |
| 47 | 54 |
| 48 quota_manager_->GetGlobalUsage( | 55 quota_manager_->GetGlobalUsage( |
| 49 storage::kStorageTypePersistent, | 56 storage::kStorageTypePersistent, |
| 50 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage, | 57 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 94 } |
| 88 | 95 |
| 89 RELAY_TO_HANDLER(ReportAvailableSpace, int64_t) | 96 RELAY_TO_HANDLER(ReportAvailableSpace, int64_t) |
| 90 RELAY_TO_HANDLER(ReportGlobalInfo, const GlobalStorageInfo&) | 97 RELAY_TO_HANDLER(ReportGlobalInfo, const GlobalStorageInfo&) |
| 91 RELAY_TO_HANDLER(ReportPerHostInfo, const std::vector<PerHostStorageInfo>&) | 98 RELAY_TO_HANDLER(ReportPerHostInfo, const std::vector<PerHostStorageInfo>&) |
| 92 RELAY_TO_HANDLER(ReportPerOriginInfo, const std::vector<PerOriginStorageInfo>&) | 99 RELAY_TO_HANDLER(ReportPerOriginInfo, const std::vector<PerOriginStorageInfo>&) |
| 93 RELAY_TO_HANDLER(ReportStatistics, const Statistics&) | 100 RELAY_TO_HANDLER(ReportStatistics, const Statistics&) |
| 94 | 101 |
| 95 #undef RELAY_TO_HANDLER | 102 #undef RELAY_TO_HANDLER |
| 96 | 103 |
| 97 void QuotaInternalsProxy::DidGetSettings( | 104 void QuotaInternalsProxy::DidGetAvailableSpace(storage::QuotaStatusCode status, |
| 98 const storage::QuotaSettings& settings) { | 105 int64_t space) { |
| 99 // TODO(michaeln): also report the other config fields | 106 // crbug.com/349708 |
| 100 GlobalStorageInfo info(storage::kStorageTypeTemporary); | 107 TRACE_EVENT0("io", "QuotaInternalsProxy::DidGetAvailableSpace"); |
| 101 info.set_quota(settings.pool_size); | 108 |
| 102 ReportGlobalInfo(info); | 109 if (status == storage::kQuotaStatusOk) |
| 110 ReportAvailableSpace(space); |
| 103 } | 111 } |
| 104 | 112 |
| 105 void QuotaInternalsProxy::DidGetCapacity(int64_t total_space, | 113 void QuotaInternalsProxy::DidGetGlobalQuota(storage::StorageType type, |
| 106 int64_t available_space) { | 114 storage::QuotaStatusCode status, |
| 107 // TODO(michaeln): also report total_space | 115 int64_t quota) { |
| 108 ReportAvailableSpace(available_space); | 116 if (status == storage::kQuotaStatusOk) { |
| 117 GlobalStorageInfo info(type); |
| 118 info.set_quota(quota); |
| 119 ReportGlobalInfo(info); |
| 120 } |
| 109 } | 121 } |
| 110 | 122 |
| 111 void QuotaInternalsProxy::DidGetGlobalUsage(storage::StorageType type, | 123 void QuotaInternalsProxy::DidGetGlobalUsage(storage::StorageType type, |
| 112 int64_t usage, | 124 int64_t usage, |
| 113 int64_t unlimited_usage) { | 125 int64_t unlimited_usage) { |
| 114 GlobalStorageInfo info(type); | 126 GlobalStorageInfo info(type); |
| 115 info.set_usage(usage); | 127 info.set_usage(usage); |
| 116 info.set_unlimited_usage(unlimited_usage); | 128 info.set_unlimited_usage(unlimited_usage); |
| 117 | 129 |
| 118 ReportGlobalInfo(info); | 130 ReportGlobalInfo(info); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 DCHECK(quota_manager_.get()); | 229 DCHECK(quota_manager_.get()); |
| 218 quota_manager_->GetHostUsage(host, | 230 quota_manager_->GetHostUsage(host, |
| 219 type, | 231 type, |
| 220 base::Bind(&QuotaInternalsProxy::DidGetHostUsage, | 232 base::Bind(&QuotaInternalsProxy::DidGetHostUsage, |
| 221 weak_factory_.GetWeakPtr(), | 233 weak_factory_.GetWeakPtr(), |
| 222 host, | 234 host, |
| 223 type)); | 235 type)); |
| 224 } | 236 } |
| 225 | 237 |
| 226 } // namespace quota_internals | 238 } // namespace quota_internals |
| OLD | NEW |