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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_file_system_helper.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_file_system_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 continue; // Non-websafe state is not considered browsing data. 131 continue; // Non-websafe state is not considered browsing data.
132 132
133 // We can call these synchronous methods as we've already verified that 133 // We can call these synchronous methods as we've already verified that
134 // we're running on the FILE thread. 134 // we're running on the FILE thread.
135 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread( 135 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(
136 filesystem_context_, current, 136 filesystem_context_, current,
137 fileapi::kFileSystemTypePersistent); 137 fileapi::kFileSystemTypePersistent);
138 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread( 138 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(
139 filesystem_context_, current, 139 filesystem_context_, current,
140 fileapi::kFileSystemTypeTemporary); 140 fileapi::kFileSystemTypeTemporary);
141 int64 syncable_usage = quota_util->GetOriginUsageOnFileThread(
142 filesystem_context_, current,
143 fileapi::kFileSystemTypeSyncable);
141 file_system_info_.push_back( 144 file_system_info_.push_back(
142 FileSystemInfo( 145 FileSystemInfo(
143 current, 146 current,
144 origin_enumerator->HasFileSystemType( 147 origin_enumerator->HasFileSystemType(
145 fileapi::kFileSystemTypePersistent), 148 fileapi::kFileSystemTypePersistent),
146 origin_enumerator->HasFileSystemType( 149 origin_enumerator->HasFileSystemType(
147 fileapi::kFileSystemTypeTemporary), 150 fileapi::kFileSystemTypeTemporary),
151 origin_enumerator->HasFileSystemType(
152 fileapi::kFileSystemTypeSyncable),
148 persistent_usage, 153 persistent_usage,
149 temporary_usage)); 154 temporary_usage,
155 syncable_usage));
150 } 156 }
151 157
152 BrowserThread::PostTask( 158 BrowserThread::PostTask(
153 BrowserThread::UI, FROM_HERE, 159 BrowserThread::UI, FROM_HERE,
154 base::Bind(&BrowsingDataFileSystemHelperImpl::NotifyOnUIThread, this)); 160 base::Bind(&BrowsingDataFileSystemHelperImpl::NotifyOnUIThread, this));
155 } 161 }
156 162
157 void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() { 163 void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() {
158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
159 DCHECK(is_fetching_); 165 DCHECK(is_fetching_);
160 completion_callback_.Run(file_system_info_); 166 completion_callback_.Run(file_system_info_);
161 completion_callback_.Reset(); 167 completion_callback_.Reset();
162 is_fetching_ = false; 168 is_fetching_ = false;
163 } 169 }
164 170
165 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread( 171 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread(
166 const GURL& origin) { 172 const GURL& origin) {
167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
168 filesystem_context_->DeleteDataForOriginOnFileThread(origin); 174 filesystem_context_->DeleteDataForOriginOnFileThread(origin);
169 } 175 }
170 176
171 } // namespace 177 } // namespace
172 178
173 BrowsingDataFileSystemHelper::FileSystemInfo::FileSystemInfo( 179 BrowsingDataFileSystemHelper::FileSystemInfo::FileSystemInfo(
174 const GURL& origin, 180 const GURL& origin,
175 bool has_persistent, 181 bool has_persistent,
176 bool has_temporary, 182 bool has_temporary,
183 bool has_syncable,
177 int64 usage_persistent, 184 int64 usage_persistent,
178 int64 usage_temporary) 185 int64 usage_temporary,
186 int64 usage_syncable)
179 : origin(origin), 187 : origin(origin),
180 has_persistent(has_persistent), 188 has_persistent(has_persistent),
181 has_temporary(has_temporary), 189 has_temporary(has_temporary),
190 has_syncable(has_syncable),
182 usage_persistent(usage_persistent), 191 usage_persistent(usage_persistent),
183 usage_temporary(usage_temporary) { 192 usage_temporary(usage_temporary),
193 usage_syncable(usage_syncable){
184 } 194 }
185 195
186 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {} 196 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {}
187 197
188 // static 198 // static
189 BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create( 199 BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create(
190 fileapi::FileSystemContext* filesystem_context) { 200 fileapi::FileSystemContext* filesystem_context) {
191 return new BrowsingDataFileSystemHelperImpl(filesystem_context); 201 return new BrowsingDataFileSystemHelperImpl(filesystem_context);
192 } 202 }
193 203
(...skipping 28 matching lines...) Expand all
222 // we should think about reworking the implementation. 232 // we should think about reworking the implementation.
223 bool duplicate_origin = false; 233 bool duplicate_origin = false;
224 for (std::list<FileSystemInfo>::iterator 234 for (std::list<FileSystemInfo>::iterator
225 file_system = file_system_info_.begin(); 235 file_system = file_system_info_.begin();
226 file_system != file_system_info_.end(); 236 file_system != file_system_info_.end();
227 ++file_system) { 237 ++file_system) {
228 if (file_system->origin == origin) { 238 if (file_system->origin == origin) {
229 if (type == fileapi::kFileSystemTypePersistent) { 239 if (type == fileapi::kFileSystemTypePersistent) {
230 file_system->has_persistent = true; 240 file_system->has_persistent = true;
231 file_system->usage_persistent = size; 241 file_system->usage_persistent = size;
232 } else { 242 } else if (type == fileapi::kFileSystemTypeTemporary) {
233 file_system->has_temporary = true; 243 file_system->has_temporary = true;
234 file_system->usage_temporary = size; 244 file_system->usage_temporary = size;
245 } else {
246 file_system->has_syncable = true;
247 file_system->usage_syncable = size;
235 } 248 }
236 duplicate_origin = true; 249 duplicate_origin = true;
237 break; 250 break;
238 } 251 }
239 } 252 }
240 if (duplicate_origin) 253 if (duplicate_origin)
241 return; 254 return;
242 255
243 if (!BrowsingDataHelper::HasWebScheme(origin)) 256 if (!BrowsingDataHelper::HasWebScheme(origin))
244 return; // Non-websafe state is not considered browsing data. 257 return; // Non-websafe state is not considered browsing data.
245 258
246 file_system_info_.push_back(FileSystemInfo( 259 file_system_info_.push_back(FileSystemInfo(
247 origin, 260 origin,
248 (type == fileapi::kFileSystemTypePersistent), 261 (type == fileapi::kFileSystemTypePersistent),
249 (type == fileapi::kFileSystemTypeTemporary), 262 (type == fileapi::kFileSystemTypeTemporary),
263 (type == fileapi::kFileSystemTypeSyncable),
250 (type == fileapi::kFileSystemTypePersistent) ? size : 0, 264 (type == fileapi::kFileSystemTypePersistent) ? size : 0,
251 (type == fileapi::kFileSystemTypeTemporary) ? size : 0)); 265 (type == fileapi::kFileSystemTypeTemporary) ? size : 0,
266 (type == fileapi::kFileSystemTypeSyncable) ? size : 0));
252 } 267 }
253 268
254 void CannedBrowsingDataFileSystemHelper::Reset() { 269 void CannedBrowsingDataFileSystemHelper::Reset() {
255 file_system_info_.clear(); 270 file_system_info_.clear();
256 } 271 }
257 272
258 bool CannedBrowsingDataFileSystemHelper::empty() const { 273 bool CannedBrowsingDataFileSystemHelper::empty() const {
259 return file_system_info_.empty(); 274 return file_system_info_.empty();
260 } 275 }
261 276
(...skipping 15 matching lines...) Expand all
277 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); 292 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this));
278 } 293 }
279 294
280 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { 295 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() {
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
282 DCHECK(is_fetching_); 297 DCHECK(is_fetching_);
283 completion_callback_.Run(file_system_info_); 298 completion_callback_.Run(file_system_info_);
284 completion_callback_.Reset(); 299 completion_callback_.Reset();
285 is_fetching_ = false; 300 is_fetching_ = false;
286 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698