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