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

Side by Side Diff: chrome/browser/browsing_data_file_system_helper.cc

Issue 10092013: Display third party cookies and site data counts in the WebsiteSettings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Fix CannedBrowsingDataDatabaseHelperTest.*" Created 8 years, 7 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_file_system_helper.h" 5 #include "chrome/browser/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Deletes all file systems associated with |origin|. This must be called on 49 // Deletes all file systems associated with |origin|. This must be called on
50 // the FILE thread. 50 // the FILE thread.
51 void DeleteFileSystemOriginInFileThread(const GURL& origin); 51 void DeleteFileSystemOriginInFileThread(const GURL& origin);
52 52
53 // We don't own the Profile object. Clients are responsible for destroying the 53 // We don't own the Profile object. Clients are responsible for destroying the
54 // object when it's no longer used. 54 // object when it's no longer used.
55 Profile* profile_; 55 Profile* profile_;
56 56
57 // Holds the current list of file systems returned to the client after 57 // Holds the current list of file systems returned to the client after
58 // StartFetching is called. This only mutates in the FILE thread. 58 // StartFetching is called. Access to |file_system_info_| is triggered
59 // indirectly via the UI thread and guarded by |is_fetching_|. This means
60 // |file_system_info_| is only accessed while |is_fetching_| is true. The
61 // flag |is_fetching_| is only accessed on the UI thread. In the context of
62 // this class |file_system_info_| only mutates on the FILE thread.
59 std::list<FileSystemInfo> file_system_info_; 63 std::list<FileSystemInfo> file_system_info_;
60 64
61 // Holds the callback passed in at the beginning of the StartFetching workflow 65 // Holds the callback passed in at the beginning of the StartFetching workflow
62 // so that it can be triggered via NotifyOnUIThread. This only mutates on the 66 // so that it can be triggered via NotifyOnUIThread. This only mutates on the
63 // UI thread. 67 // UI thread.
64 base::Callback<void(const std::list<FileSystemInfo>&)> completion_callback_; 68 base::Callback<void(const std::list<FileSystemInfo>&)> completion_callback_;
65 69
66 // Indicates whether or not we're currently fetching information: set to true 70 // Indicates whether or not we're currently fetching information: set to true
67 // when StartFetching is called on the UI thread, and reset to false when 71 // when StartFetching is called on the UI thread, and reset to false when
68 // NotifyOnUIThread triggers the success callback. 72 // NotifyOnUIThread triggers the success callback.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 182
179 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {} 183 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {}
180 184
181 // static 185 // static
182 BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create( 186 BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create(
183 Profile* profile) { 187 Profile* profile) {
184 return new BrowsingDataFileSystemHelperImpl(profile); 188 return new BrowsingDataFileSystemHelperImpl(profile);
185 } 189 }
186 190
187 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper( 191 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper(
188 Profile* /* profile */) 192 Profile* profile)
189 : is_fetching_(false) { 193 : is_fetching_(false) {
190 } 194 }
191 195
192 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper() 196 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper()
193 : is_fetching_(false) { 197 : is_fetching_(false) {
194 } 198 }
195 199
196 CannedBrowsingDataFileSystemHelper::~CannedBrowsingDataFileSystemHelper() {} 200 CannedBrowsingDataFileSystemHelper::~CannedBrowsingDataFileSystemHelper() {}
197 201
198 CannedBrowsingDataFileSystemHelper* 202 CannedBrowsingDataFileSystemHelper*
199 CannedBrowsingDataFileSystemHelper::Clone() { 203 CannedBrowsingDataFileSystemHelper::Clone() {
200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
201 CannedBrowsingDataFileSystemHelper* clone = 205 CannedBrowsingDataFileSystemHelper* clone =
202 new CannedBrowsingDataFileSystemHelper(); 206 new CannedBrowsingDataFileSystemHelper();
203 // This list only mutates on the UI thread, so it's safe to work with it here 207 // This list only mutates on the UI thread, so it's safe to work with it here
204 // (given the DCHECK above). 208 // (given the DCHECK above).
205 clone->file_system_info_ = file_system_info_; 209 clone->file_system_info_ = file_system_info_;
206 return clone; 210 return clone;
207 } 211 }
208 212
209 void CannedBrowsingDataFileSystemHelper::AddFileSystem( 213 void CannedBrowsingDataFileSystemHelper::AddFileSystem(
210 const GURL& origin, const fileapi::FileSystemType type, const int64 size) { 214 const GURL& origin, const fileapi::FileSystemType type, const int64 size) {
211 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
212 // This canned implementation of AddFileSystem uses an O(n^2) algorithm; which 216 // This canned implementation of AddFileSystem uses an O(n^2) algorithm; which
213 // is fine, as it isn't meant for use in a high-volume context. If it turns 217 // is fine, as it isn't meant for use in a high-volume context. If it turns
214 // out that we want to start using this in a context with many, many origins, 218 // out that we want to start using this in a context with many, many origins,
215 // we should think about reworking the implementation. 219 // we should think about reworking the implementation.
216 bool duplicate_origin = false; 220 bool duplicate_origin = false;
217 for (std::list<FileSystemInfo>::iterator 221 for (std::list<FileSystemInfo>::iterator
218 file_system = file_system_info_.begin(); 222 file_system = file_system_info_.begin();
219 file_system != file_system_info_.end(); 223 file_system != file_system_info_.end();
220 ++file_system) { 224 ++file_system) {
221 if (file_system->origin == origin) { 225 if (file_system->origin == origin) {
(...skipping 24 matching lines...) Expand all
246 250
247 void CannedBrowsingDataFileSystemHelper::Reset() { 251 void CannedBrowsingDataFileSystemHelper::Reset() {
248 file_system_info_.clear(); 252 file_system_info_.clear();
249 } 253 }
250 254
251 bool CannedBrowsingDataFileSystemHelper::empty() const { 255 bool CannedBrowsingDataFileSystemHelper::empty() const {
252 return file_system_info_.empty(); 256 return file_system_info_.empty();
253 } 257 }
254 258
255 size_t CannedBrowsingDataFileSystemHelper::GetFileSystemCount() const { 259 size_t CannedBrowsingDataFileSystemHelper::GetFileSystemCount() const {
260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
256 return file_system_info_.size(); 261 return file_system_info_.size();
257 } 262 }
258 263
259 void CannedBrowsingDataFileSystemHelper::StartFetching( 264 void CannedBrowsingDataFileSystemHelper::StartFetching(
260 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { 265 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) {
261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
262 DCHECK(!is_fetching_); 267 DCHECK(!is_fetching_);
263 DCHECK_EQ(false, callback.is_null()); 268 DCHECK_EQ(false, callback.is_null());
264 is_fetching_ = true; 269 is_fetching_ = true;
265 completion_callback_ = callback; 270 completion_callback_ = callback;
266 271
267 BrowserThread::PostTask( 272 BrowserThread::PostTask(
268 BrowserThread::UI, FROM_HERE, 273 BrowserThread::UI, FROM_HERE,
269 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); 274 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this));
270 } 275 }
271 276
272 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { 277 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() {
273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
274 DCHECK(is_fetching_); 279 DCHECK(is_fetching_);
275 completion_callback_.Run(file_system_info_); 280 completion_callback_.Run(file_system_info_);
276 completion_callback_.Reset(); 281 completion_callback_.Reset();
277 is_fetching_ = false; 282 is_fetching_ = false;
278 } 283 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_file_system_helper.h ('k') | chrome/browser/browsing_data_indexed_db_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698