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