| OLD | NEW |
| 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 "chrome/browser/ui/webui/quota_internals_proxy.h" | 5 #include "chrome/browser/ui/webui/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" |
| 11 #include "chrome/browser/ui/webui/quota_internals_handler.h" | 11 #include "chrome/browser/ui/webui/quota_internals_handler.h" |
| 12 #include "chrome/browser/ui/webui/quota_internals_types.h" | 12 #include "chrome/browser/ui/webui/quota_internals_types.h" |
| 13 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
| 14 | 14 |
| 15 namespace quota_internals { | 15 namespace quota_internals { |
| 16 | 16 |
| 17 QuotaInternalsProxy::QuotaInternalsProxy(QuotaInternalsHandler* handler) | 17 QuotaInternalsProxy::QuotaInternalsProxy(QuotaInternalsHandler* handler) |
| 18 : handler_(handler), | 18 : handler_(handler), |
| 19 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 19 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 QuotaInternalsProxy::~QuotaInternalsProxy() {} | 22 QuotaInternalsProxy::~QuotaInternalsProxy() {} |
| 23 | 23 |
| 24 #define RELAY_TO_HANDLER(func, arg_t) \ | 24 #define RELAY_TO_HANDLER(func, arg_t) \ |
| 25 void QuotaInternalsProxy::func(arg_t arg) { \ | 25 void QuotaInternalsProxy::func(arg_t arg) { \ |
| 26 if (!handler_) \ | 26 if (!handler_) \ |
| 27 return; \ | 27 return; \ |
| 28 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { \ | 28 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { \ |
| 29 BrowserThread::PostTask( \ | 29 BrowserThread::PostTask( \ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 DCHECK(quota_manager); | 48 DCHECK(quota_manager); |
| 49 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 49 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 50 BrowserThread::PostTask( | 50 BrowserThread::PostTask( |
| 51 BrowserThread::IO, FROM_HERE, | 51 BrowserThread::IO, FROM_HERE, |
| 52 base::Bind(&QuotaInternalsProxy::RequestInfo, this, quota_manager)); | 52 base::Bind(&QuotaInternalsProxy::RequestInfo, this, quota_manager)); |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 | 55 |
| 56 quota_manager_ = quota_manager; | 56 quota_manager_ = quota_manager; |
| 57 quota_manager_->GetAvailableSpace( | 57 quota_manager_->GetAvailableSpace( |
| 58 callback_factory_.NewCallback( | 58 base::Bind(&QuotaInternalsProxy::DidGetAvailableSpace, |
| 59 &QuotaInternalsProxy::DidGetAvailableSpace)); | 59 weak_factory_.GetWeakPtr())); |
| 60 | 60 |
| 61 quota_manager_->GetTemporaryGlobalQuota( | 61 quota_manager_->GetTemporaryGlobalQuota( |
| 62 callback_factory_.NewCallback( | 62 base::Bind(&QuotaInternalsProxy::DidGetGlobalQuota, |
| 63 &QuotaInternalsProxy::DidGetGlobalQuota)); | 63 weak_factory_.GetWeakPtr())); |
| 64 | 64 |
| 65 quota_manager_->GetGlobalUsage( | 65 quota_manager_->GetGlobalUsage( |
| 66 quota::kStorageTypeTemporary, | 66 quota::kStorageTypeTemporary, |
| 67 callback_factory_.NewCallback( | 67 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage, |
| 68 &QuotaInternalsProxy::DidGetGlobalUsage)); | 68 weak_factory_.GetWeakPtr())); |
| 69 | 69 |
| 70 quota_manager_->GetGlobalUsage( | 70 quota_manager_->GetGlobalUsage( |
| 71 quota::kStorageTypePersistent, | 71 quota::kStorageTypePersistent, |
| 72 callback_factory_.NewCallback( | 72 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage, |
| 73 &QuotaInternalsProxy::DidGetGlobalUsage)); | 73 weak_factory_.GetWeakPtr())); |
| 74 | 74 |
| 75 quota_manager_->DumpQuotaTable( | 75 quota_manager_->DumpQuotaTable( |
| 76 callback_factory_.NewCallback( | 76 base::Bind(&QuotaInternalsProxy::DidDumpQuotaTable, |
| 77 &QuotaInternalsProxy::DidDumpQuotaTable)); | 77 weak_factory_.GetWeakPtr())); |
| 78 | 78 |
| 79 quota_manager_->DumpOriginInfoTable( | 79 quota_manager_->DumpOriginInfoTable( |
| 80 callback_factory_.NewCallback( | 80 base::Bind(&QuotaInternalsProxy::DidDumpOriginInfoTable, |
| 81 &QuotaInternalsProxy::DidDumpOriginInfoTable)); | 81 weak_factory_.GetWeakPtr())); |
| 82 | 82 |
| 83 std::map<std::string, std::string> stats; | 83 std::map<std::string, std::string> stats; |
| 84 quota_manager_->GetStatistics(&stats); | 84 quota_manager_->GetStatistics(&stats); |
| 85 ReportStatistics(stats); | 85 ReportStatistics(stats); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void QuotaInternalsProxy::DidGetAvailableSpace(quota::QuotaStatusCode status, | 88 void QuotaInternalsProxy::DidGetAvailableSpace(quota::QuotaStatusCode status, |
| 89 int64 space) { | 89 int64 space) { |
| 90 if (status == quota::kQuotaStatusOk) | 90 if (status == quota::kQuotaStatusOk) |
| 91 ReportAvailableSpace(space); | 91 ReportAvailableSpace(space); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 GetHostUsage(host, type); | 173 GetHostUsage(host, type); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 void QuotaInternalsProxy::GetHostUsage(const std::string& host, | 178 void QuotaInternalsProxy::GetHostUsage(const std::string& host, |
| 179 quota::StorageType type) { | 179 quota::StorageType type) { |
| 180 DCHECK(quota_manager_); | 180 DCHECK(quota_manager_); |
| 181 quota_manager_->GetHostUsage( | 181 quota_manager_->GetHostUsage( |
| 182 host, type, | 182 host, type, |
| 183 callback_factory_.NewCallback( | 183 base::Bind(&QuotaInternalsProxy::DidGetHostUsage, |
| 184 &QuotaInternalsProxy::DidGetHostUsage)); | 184 weak_factory_.GetWeakPtr())); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void QuotaInternalsProxy::RequestPerOriginInfo(quota::StorageType type) { | 187 void QuotaInternalsProxy::RequestPerOriginInfo(quota::StorageType type) { |
| 188 DCHECK(quota_manager_); | 188 DCHECK(quota_manager_); |
| 189 | 189 |
| 190 std::set<GURL> origins; | 190 std::set<GURL> origins; |
| 191 quota_manager_->GetCachedOrigins(type, &origins); | 191 quota_manager_->GetCachedOrigins(type, &origins); |
| 192 | 192 |
| 193 std::vector<PerOriginStorageInfo> origin_info; | 193 std::vector<PerOriginStorageInfo> origin_info; |
| 194 origin_info.reserve(origins.size()); | 194 origin_info.reserve(origins.size()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 207 PerHostStorageInfo info(host, type); | 207 PerHostStorageInfo info(host, type); |
| 208 host_info.push_back(info); | 208 host_info.push_back(info); |
| 209 VisitHost(host, type); | 209 VisitHost(host, type); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 ReportPerOriginInfo(origin_info); | 212 ReportPerOriginInfo(origin_info); |
| 213 ReportPerHostInfo(host_info); | 213 ReportPerHostInfo(host_info); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace quota_internals | 216 } // namespace quota_internals |
| OLD | NEW |