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

Unified Diff: chrome/browser/browsing_data_database_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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data_database_helper.cc
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc
index c4d89beeec65b3ab975898a50a9f6f20252453d5..f28d56f866ff52efac4fa42372a515dc07247652 100644
--- a/chrome/browser/browsing_data_database_helper.cc
+++ b/chrome/browser/browsing_data_database_helper.cc
@@ -22,10 +22,6 @@ using content::BrowserContext;
using content::BrowserThread;
using WebKit::WebSecurityOrigin;
-BrowsingDataDatabaseHelper::DatabaseInfo::DatabaseInfo()
- : size(0) {
-}
-
BrowsingDataDatabaseHelper::DatabaseInfo::DatabaseInfo(
const std::string& host,
const std::string& database_name,
@@ -135,8 +131,6 @@ void BrowsingDataDatabaseHelper::DeleteDatabaseOnFileThread(
net::CompletionCallback());
}
-CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::PendingDatabaseInfo() {}
-
CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::PendingDatabaseInfo(
const GURL& origin,
const std::string& name,
@@ -148,6 +142,13 @@ CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::PendingDatabaseInfo(
CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::~PendingDatabaseInfo() {}
+bool CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::operator<(
+ const PendingDatabaseInfo& other) const {
+ if (origin == other.origin)
+ return name < other.name;
+ return origin < other.origin;
+}
+
CannedBrowsingDataDatabaseHelper::CannedBrowsingDataDatabaseHelper(
Profile* profile)
: BrowsingDataDatabaseHelper(profile),
@@ -161,7 +162,6 @@ CannedBrowsingDataDatabaseHelper* CannedBrowsingDataDatabaseHelper::Clone() {
base::AutoLock auto_lock(lock_);
clone->pending_database_info_ = pending_database_info_;
- clone->database_info_ = database_info_;
return clone;
}
@@ -169,28 +169,34 @@ void CannedBrowsingDataDatabaseHelper::AddDatabase(
const GURL& origin,
const std::string& name,
const std::string& description) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::AutoLock auto_lock(lock_);
if (BrowsingDataHelper::HasValidScheme(origin)) {
- pending_database_info_.push_back(PendingDatabaseInfo(
+ pending_database_info_.insert(PendingDatabaseInfo(
origin, name, description));
}
}
void CannedBrowsingDataDatabaseHelper::Reset() {
base::AutoLock auto_lock(lock_);
- database_info_.clear();
pending_database_info_.clear();
}
bool CannedBrowsingDataDatabaseHelper::empty() const {
base::AutoLock auto_lock(lock_);
- return database_info_.empty() && pending_database_info_.empty();
+ return pending_database_info_.empty();
}
size_t CannedBrowsingDataDatabaseHelper::GetDatabaseCount() const {
+ base::AutoLock auto_lock(lock_);
return pending_database_info_.size();
}
+const std::set<CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo>&
+CannedBrowsingDataDatabaseHelper::GetPendingDatabaseInfo() {
+ return pending_database_info_;
+}
+
void CannedBrowsingDataDatabaseHelper::StartFetching(
const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -209,7 +215,8 @@ CannedBrowsingDataDatabaseHelper::~CannedBrowsingDataDatabaseHelper() {}
void CannedBrowsingDataDatabaseHelper::ConvertInfoInWebKitThread() {
base::AutoLock auto_lock(lock_);
- for (std::list<PendingDatabaseInfo>::const_iterator
+ database_info_.clear();
+ for (std::set<PendingDatabaseInfo>::const_iterator
info = pending_database_info_.begin();
info != pending_database_info_.end(); ++info) {
WebSecurityOrigin web_security_origin =
@@ -218,18 +225,6 @@ void CannedBrowsingDataDatabaseHelper::ConvertInfoInWebKitThread() {
std::string origin_identifier =
web_security_origin.databaseIdentifier().utf8();
- bool duplicate = false;
- for (std::list<DatabaseInfo>::iterator database = database_info_.begin();
- database != database_info_.end(); ++database) {
- if (database->origin_identifier == origin_identifier &&
- database->database_name == info->name) {
- duplicate = true;
- break;
- }
- }
- if (duplicate)
- continue;
-
database_info_.push_back(DatabaseInfo(
web_security_origin.host().utf8(),
info->name,
@@ -239,7 +234,6 @@ void CannedBrowsingDataDatabaseHelper::ConvertInfoInWebKitThread() {
0,
base::Time()));
}
- pending_database_info_.clear();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
« no previous file with comments | « chrome/browser/browsing_data_database_helper.h ('k') | chrome/browser/browsing_data_database_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698