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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_quota_helper_impl.cc

Issue 13357004: Clear browsing data clears data for type kStorageTypeTemporary but not for kStorageTypeSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 7 years, 8 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) 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/browsing_data/browsing_data_quota_helper_impl.h" 5 #include "chrome/browser/browsing_data/browsing_data_quota_helper_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 void BrowsingDataQuotaHelperImpl::GotOrigins( 87 void BrowsingDataQuotaHelperImpl::GotOrigins(
88 const std::set<GURL>& origins, quota::StorageType type) { 88 const std::set<GURL>& origins, quota::StorageType type) {
89 for (std::set<GURL>::const_iterator itr = origins.begin(); 89 for (std::set<GURL>::const_iterator itr = origins.begin();
90 itr != origins.end(); 90 itr != origins.end();
91 ++itr) 91 ++itr)
92 if (BrowsingDataHelper::HasWebScheme(*itr)) 92 if (BrowsingDataHelper::HasWebScheme(*itr))
93 pending_hosts_.insert(std::make_pair(itr->host(), type)); 93 pending_hosts_.insert(std::make_pair(itr->host(), type));
94 94
95 DCHECK(type == quota::kStorageTypeTemporary || 95 DCHECK(type == quota::kStorageTypeTemporary ||
96 type == quota::kStorageTypePersistent); 96 type == quota::kStorageTypePersistent ||
97 type == quota::kStorageTypeSyncable);
97 98
99 // Calling GetOriginsModifiedSince() for all types by chaining callbacks.
98 if (type == quota::kStorageTypeTemporary) { 100 if (type == quota::kStorageTypeTemporary) {
99 quota_manager_->GetOriginsModifiedSince( 101 quota_manager_->GetOriginsModifiedSince(
100 quota::kStorageTypePersistent, 102 quota::kStorageTypePersistent,
101 base::Time(), 103 base::Time(),
102 base::Bind(&BrowsingDataQuotaHelperImpl::GotOrigins, 104 base::Bind(&BrowsingDataQuotaHelperImpl::GotOrigins,
103 weak_factory_.GetWeakPtr())); 105 weak_factory_.GetWeakPtr()));
106 } else if (type == quota::kStorageTypePersistent) {
107 quota_manager_->GetOriginsModifiedSince(
108 quota::kStorageTypeSyncable,
109 base::Time(),
110 base::Bind(&BrowsingDataQuotaHelperImpl::GotOrigins,
111 weak_factory_.GetWeakPtr()));
104 } else { 112 } else {
105 // type == quota::kStorageTypePersistent 113 DCHECK(type == quota::kStorageTypeSyncable);
106 ProcessPendingHosts(); 114 ProcessPendingHosts();
107 } 115 }
108 } 116 }
109 117
110 void BrowsingDataQuotaHelperImpl::ProcessPendingHosts() { 118 void BrowsingDataQuotaHelperImpl::ProcessPendingHosts() {
111 if (pending_hosts_.empty()) { 119 if (pending_hosts_.empty()) {
112 OnComplete(); 120 OnComplete();
113 return; 121 return;
114 } 122 }
115 123
(...skipping 16 matching lines...) Expand all
132 void BrowsingDataQuotaHelperImpl::GotHostUsage(const std::string& host, 140 void BrowsingDataQuotaHelperImpl::GotHostUsage(const std::string& host,
133 quota::StorageType type, 141 quota::StorageType type,
134 int64 usage) { 142 int64 usage) {
135 switch (type) { 143 switch (type) {
136 case quota::kStorageTypeTemporary: 144 case quota::kStorageTypeTemporary:
137 quota_info_[host].temporary_usage = usage; 145 quota_info_[host].temporary_usage = usage;
138 break; 146 break;
139 case quota::kStorageTypePersistent: 147 case quota::kStorageTypePersistent:
140 quota_info_[host].persistent_usage = usage; 148 quota_info_[host].persistent_usage = usage;
141 break; 149 break;
150 case quota::kStorageTypeSyncable:
151 quota_info_[host].syncable_usage = usage;
152 break;
142 default: 153 default:
143 NOTREACHED(); 154 NOTREACHED();
144 } 155 }
145 ProcessPendingHosts(); 156 ProcessPendingHosts();
146 } 157 }
147 158
148 void BrowsingDataQuotaHelperImpl::OnComplete() { 159 void BrowsingDataQuotaHelperImpl::OnComplete() {
149 if (!ui_thread_->BelongsToCurrentThread()) { 160 if (!ui_thread_->BelongsToCurrentThread()) {
150 ui_thread_->PostTask( 161 ui_thread_->PostTask(
151 FROM_HERE, 162 FROM_HERE,
152 base::Bind(&BrowsingDataQuotaHelperImpl::OnComplete, this)); 163 base::Bind(&BrowsingDataQuotaHelperImpl::OnComplete, this));
153 return; 164 return;
154 } 165 }
155 166
156 is_fetching_ = false; 167 is_fetching_ = false;
157 168
158 QuotaInfoArray result; 169 QuotaInfoArray result;
159 170
160 for (std::map<std::string, QuotaInfo>::iterator itr = quota_info_.begin(); 171 for (std::map<std::string, QuotaInfo>::iterator itr = quota_info_.begin();
161 itr != quota_info_.end(); 172 itr != quota_info_.end();
162 ++itr) { 173 ++itr) {
163 QuotaInfo* info = &itr->second; 174 QuotaInfo* info = &itr->second;
164 // Skip unused entries 175 // Skip unused entries
165 if (info->temporary_usage <= 0 && 176 if (info->temporary_usage <= 0 &&
166 info->persistent_usage <= 0) 177 info->persistent_usage <= 0 &&
178 info->syncable_usage <= 0)
167 continue; 179 continue;
168 180
169 info->host = itr->first; 181 info->host = itr->first;
170 result.push_back(*info); 182 result.push_back(*info);
171 } 183 }
172 184
173 callback_.Run(result); 185 callback_.Run(result);
174 callback_.Reset(); 186 callback_.Reset();
175 } 187 }
176 188
177 void BrowsingDataQuotaHelperImpl::DidRevokeHostQuota( 189 void BrowsingDataQuotaHelperImpl::DidRevokeHostQuota(
178 quota::QuotaStatusCode status_unused, 190 quota::QuotaStatusCode status_unused,
179 int64 quota_unused) { 191 int64 quota_unused) {
180 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698