Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: chrome/browser/ui/webui/quota_internals_proxy.cc

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pass as cref, and fix style. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/webui/quota_internals_handler.h" 11 #include "chrome/browser/ui/webui/quota_internals_handler.h"
11 #include "chrome/browser/ui/webui/quota_internals_types.h" 12 #include "chrome/browser/ui/webui/quota_internals_types.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 14
14 namespace quota_internals { 15 namespace quota_internals {
15 16
16 QuotaInternalsProxy::QuotaInternalsProxy(QuotaInternalsHandler* handler) 17 QuotaInternalsProxy::QuotaInternalsProxy(QuotaInternalsHandler* handler)
17 : handler_(handler), 18 : handler_(handler),
18 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 19 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
19 } 20 }
20 21
21 QuotaInternalsProxy::~QuotaInternalsProxy() {} 22 QuotaInternalsProxy::~QuotaInternalsProxy() {}
22 23
23 #define RELAY_TO_HANDLER(func, arg_t) \ 24 #define RELAY_TO_HANDLER(func, arg_t) \
24 void QuotaInternalsProxy::func(arg_t arg) { \ 25 void QuotaInternalsProxy::func(arg_t arg) { \
25 if (!handler_) \ 26 if (!handler_) \
26 return; \ 27 return; \
27 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { \ 28 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { \
28 BrowserThread::PostTask( \ 29 BrowserThread::PostTask( \
(...skipping 20 matching lines...) Expand all
49 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 50 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
50 BrowserThread::PostTask( 51 BrowserThread::PostTask(
51 BrowserThread::IO, FROM_HERE, 52 BrowserThread::IO, FROM_HERE,
52 NewRunnableMethod(this, &QuotaInternalsProxy::RequestInfo, 53 NewRunnableMethod(this, &QuotaInternalsProxy::RequestInfo,
53 quota_manager)); 54 quota_manager));
54 return; 55 return;
55 } 56 }
56 57
57 quota_manager_ = quota_manager; 58 quota_manager_ = quota_manager;
58 quota_manager_->GetAvailableSpace( 59 quota_manager_->GetAvailableSpace(
59 callback_factory_.NewCallback( 60 base::Bind(&QuotaInternalsProxy::DidGetAvailableSpace,
60 &QuotaInternalsProxy::DidGetAvailableSpace)); 61 weak_factory_.GetWeakPtr()));
61 62
62 quota_manager_->GetTemporaryGlobalQuota( 63 quota_manager_->GetTemporaryGlobalQuota(
63 callback_factory_.NewCallback( 64 base::Bind(&QuotaInternalsProxy::DidGetGlobalQuota,
64 &QuotaInternalsProxy::DidGetGlobalQuota)); 65 weak_factory_.GetWeakPtr()));
65 66
66 quota_manager_->GetGlobalUsage( 67 quota_manager_->GetGlobalUsage(
67 quota::kStorageTypeTemporary, 68 quota::kStorageTypeTemporary,
68 callback_factory_.NewCallback( 69 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage,
69 &QuotaInternalsProxy::DidGetGlobalUsage)); 70 weak_factory_.GetWeakPtr()));
70 71
71 quota_manager_->GetGlobalUsage( 72 quota_manager_->GetGlobalUsage(
72 quota::kStorageTypePersistent, 73 quota::kStorageTypePersistent,
73 callback_factory_.NewCallback( 74 base::Bind(&QuotaInternalsProxy::DidGetGlobalUsage,
74 &QuotaInternalsProxy::DidGetGlobalUsage)); 75 weak_factory_.GetWeakPtr()));
75 76
76 quota_manager_->DumpQuotaTable( 77 quota_manager_->DumpQuotaTable(
77 callback_factory_.NewCallback( 78 base::Bind(&QuotaInternalsProxy::DidDumpQuotaTable,
78 &QuotaInternalsProxy::DidDumpQuotaTable)); 79 weak_factory_.GetWeakPtr()));
79 80
80 quota_manager_->DumpOriginInfoTable( 81 quota_manager_->DumpOriginInfoTable(
81 callback_factory_.NewCallback( 82 base::Bind(&QuotaInternalsProxy::DidDumpOriginInfoTable,
82 &QuotaInternalsProxy::DidDumpOriginInfoTable)); 83 weak_factory_.GetWeakPtr()));
83 84
84 std::map<std::string, std::string> stats; 85 std::map<std::string, std::string> stats;
85 quota_manager_->GetStatistics(&stats); 86 quota_manager_->GetStatistics(&stats);
86 ReportStatistics(stats); 87 ReportStatistics(stats);
87 } 88 }
88 89
89 void QuotaInternalsProxy::DidGetAvailableSpace(quota::QuotaStatusCode status, 90 void QuotaInternalsProxy::DidGetAvailableSpace(quota::QuotaStatusCode status,
90 int64 space) { 91 int64 space) {
91 if (status == quota::kQuotaStatusOk) 92 if (status == quota::kQuotaStatusOk)
92 ReportAvailableSpace(space); 93 ReportAvailableSpace(space);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 GetHostUsage(host, type); 175 GetHostUsage(host, type);
175 } 176 }
176 } 177 }
177 } 178 }
178 179
179 void QuotaInternalsProxy::GetHostUsage(const std::string& host, 180 void QuotaInternalsProxy::GetHostUsage(const std::string& host,
180 quota::StorageType type) { 181 quota::StorageType type) {
181 DCHECK(quota_manager_); 182 DCHECK(quota_manager_);
182 quota_manager_->GetHostUsage( 183 quota_manager_->GetHostUsage(
183 host, type, 184 host, type,
184 callback_factory_.NewCallback( 185 base::Bind(&QuotaInternalsProxy::DidGetHostUsage,
185 &QuotaInternalsProxy::DidGetHostUsage)); 186 weak_factory_.GetWeakPtr()));
186 } 187 }
187 188
188 void QuotaInternalsProxy::RequestPerOriginInfo(quota::StorageType type) { 189 void QuotaInternalsProxy::RequestPerOriginInfo(quota::StorageType type) {
189 DCHECK(quota_manager_); 190 DCHECK(quota_manager_);
190 191
191 std::set<GURL> origins; 192 std::set<GURL> origins;
192 quota_manager_->GetCachedOrigins(type, &origins); 193 quota_manager_->GetCachedOrigins(type, &origins);
193 194
194 std::vector<PerOriginStorageInfo> origin_info; 195 std::vector<PerOriginStorageInfo> origin_info;
195 origin_info.reserve(origins.size()); 196 origin_info.reserve(origins.size());
(...skipping 12 matching lines...) Expand all
208 PerHostStorageInfo info(host, type); 209 PerHostStorageInfo info(host, type);
209 host_info.push_back(info); 210 host_info.push_back(info);
210 VisitHost(host, type); 211 VisitHost(host, type);
211 } 212 }
212 } 213 }
213 ReportPerOriginInfo(origin_info); 214 ReportPerOriginInfo(origin_info);
214 ReportPerHostInfo(host_info); 215 ReportPerHostInfo(host_info);
215 } 216 }
216 217
217 } // namespace quota_internals 218 } // namespace quota_internals
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698