| 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 10 matching lines...) Expand all Loading... |
| 21 : handler_(handler), | 21 : handler_(handler), |
| 22 weak_factory_(this) { | 22 weak_factory_(this) { |
| 23 } | 23 } |
| 24 | 24 |
| 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::BindOnce(&QuotaInternalsProxy::RequestInfo, this, quota_manager)); |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 quota_manager_ = quota_manager; | 34 quota_manager_ = quota_manager; |
| 35 | 35 |
| 36 quota_manager_->GetQuotaSettings(base::Bind( | 36 quota_manager_->GetQuotaSettings(base::Bind( |
| 37 &QuotaInternalsProxy::DidGetSettings, weak_factory_.GetWeakPtr())); | 37 &QuotaInternalsProxy::DidGetSettings, weak_factory_.GetWeakPtr())); |
| 38 | 38 |
| 39 quota_manager_->GetStorageCapacity(base::Bind( | 39 quota_manager_->GetStorageCapacity(base::Bind( |
| 40 &QuotaInternalsProxy::DidGetCapacity, weak_factory_.GetWeakPtr())); | 40 &QuotaInternalsProxy::DidGetCapacity, weak_factory_.GetWeakPtr())); |
| 41 | 41 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 65 base::Bind(&QuotaInternalsProxy::DidDumpOriginInfoTable, | 65 base::Bind(&QuotaInternalsProxy::DidDumpOriginInfoTable, |
| 66 weak_factory_.GetWeakPtr())); | 66 weak_factory_.GetWeakPtr())); |
| 67 | 67 |
| 68 std::map<std::string, std::string> stats; | 68 std::map<std::string, std::string> stats; |
| 69 quota_manager_->GetStatistics(&stats); | 69 quota_manager_->GetStatistics(&stats); |
| 70 ReportStatistics(stats); | 70 ReportStatistics(stats); |
| 71 } | 71 } |
| 72 | 72 |
| 73 QuotaInternalsProxy::~QuotaInternalsProxy() {} | 73 QuotaInternalsProxy::~QuotaInternalsProxy() {} |
| 74 | 74 |
| 75 #define RELAY_TO_HANDLER(func, arg_t) \ | 75 #define RELAY_TO_HANDLER(func, arg_t) \ |
| 76 void QuotaInternalsProxy::func(arg_t arg) { \ | 76 void QuotaInternalsProxy::func(arg_t arg) { \ |
| 77 if (!handler_) \ | 77 if (!handler_) \ |
| 78 return; \ | 78 return; \ |
| 79 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { \ | 79 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { \ |
| 80 BrowserThread::PostTask( \ | 80 BrowserThread::PostTask( \ |
| 81 BrowserThread::UI, FROM_HERE, \ | 81 BrowserThread::UI, FROM_HERE, \ |
| 82 base::Bind(&QuotaInternalsProxy::func, this, arg)); \ | 82 base::BindOnce(&QuotaInternalsProxy::func, this, arg)); \ |
| 83 return; \ | 83 return; \ |
| 84 } \ | 84 } \ |
| 85 \ | 85 \ |
| 86 handler_->func(arg); \ | 86 handler_->func(arg); \ |
| 87 } | 87 } |
| 88 | 88 |
| 89 RELAY_TO_HANDLER(ReportAvailableSpace, int64_t) | 89 RELAY_TO_HANDLER(ReportAvailableSpace, int64_t) |
| 90 RELAY_TO_HANDLER(ReportGlobalInfo, const GlobalStorageInfo&) | 90 RELAY_TO_HANDLER(ReportGlobalInfo, const GlobalStorageInfo&) |
| 91 RELAY_TO_HANDLER(ReportPerHostInfo, const std::vector<PerHostStorageInfo>&) | 91 RELAY_TO_HANDLER(ReportPerHostInfo, const std::vector<PerHostStorageInfo>&) |
| 92 RELAY_TO_HANDLER(ReportPerOriginInfo, const std::vector<PerOriginStorageInfo>&) | 92 RELAY_TO_HANDLER(ReportPerOriginInfo, const std::vector<PerOriginStorageInfo>&) |
| 93 RELAY_TO_HANDLER(ReportStatistics, const Statistics&) | 93 RELAY_TO_HANDLER(ReportStatistics, const Statistics&) |
| 94 | 94 |
| 95 #undef RELAY_TO_HANDLER | 95 #undef RELAY_TO_HANDLER |
| 96 | 96 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 DCHECK(quota_manager_.get()); | 217 DCHECK(quota_manager_.get()); |
| 218 quota_manager_->GetHostUsage(host, | 218 quota_manager_->GetHostUsage(host, |
| 219 type, | 219 type, |
| 220 base::Bind(&QuotaInternalsProxy::DidGetHostUsage, | 220 base::Bind(&QuotaInternalsProxy::DidGetHostUsage, |
| 221 weak_factory_.GetWeakPtr(), | 221 weak_factory_.GetWeakPtr(), |
| 222 host, | 222 host, |
| 223 type)); | 223 type)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace quota_internals | 226 } // namespace quota_internals |
| OLD | NEW |