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

Unified Diff: chrome/browser/browsing_data/cookies_tree_model.cc

Issue 863503002: Delete cookies for site when deleting locally stored data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'ed Created 5 years, 11 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/cookies_tree_model.cc
diff --git a/chrome/browser/browsing_data/cookies_tree_model.cc b/chrome/browser/browsing_data/cookies_tree_model.cc
index 8deb087ada30b5d027e63159f07750d21d53f6fe..9c36bb498a9079a3e9ca99db585da38f49680b4b 100644
--- a/chrome/browser/browsing_data/cookies_tree_model.cc
+++ b/chrome/browser/browsing_data/cookies_tree_model.cc
@@ -910,12 +910,17 @@ CookieTreeNode::DetailedInfo CookieTreeFlashLSONode::GetDetailedInfo() const {
CookiesTreeModel::ScopedBatchUpdateNotifier::ScopedBatchUpdateNotifier(
CookiesTreeModel* model, CookieTreeNode* node)
: model_(model), node_(node), batch_in_progress_(false) {
+ model_->RecordBatchSeen();
}
CookiesTreeModel::ScopedBatchUpdateNotifier::~ScopedBatchUpdateNotifier() {
if (batch_in_progress_) {
model_->NotifyObserverTreeNodeChanged(node_);
model_->NotifyObserverEndBatch();
+ } else {
+ // If no batch started, and this is the last batch, give the model a chance
+ // to send out a final notification.
+ model_->MaybeNotifyBatchesEnded();
}
}
@@ -938,7 +943,10 @@ CookiesTreeModel::CookiesTreeModel(
special_storage_policy_(special_storage_policy),
#endif
group_by_cookie_source_(group_by_cookie_source),
- batch_update_(0) {
+ batches_expected_(0),
+ batches_seen_(0),
+ batches_started_(0),
+ batches_ended_(0) {
data_container_->Init(this);
}
@@ -1017,6 +1025,7 @@ void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) {
void CookiesTreeModel::UpdateSearchResults(const base::string16& filter) {
CookieTreeNode* root = GetRoot();
+ SetBatchExpectation(1, true);
ScopedBatchUpdateNotifier notifier(this, root);
int num_children = root->child_count();
notifier.StartBatchUpdate();
@@ -1425,9 +1434,24 @@ void CookiesTreeModel::PopulateFlashLSOInfoWithFilter(
}
}
+void CookiesTreeModel::SetBatchExpectation(int batches_expected, bool reset) {
+ batches_expected_ = batches_expected;
+ if (reset) {
+ batches_seen_ = 0;
+ batches_started_ = 0;
+ batches_ended_ = 0;
+ } else {
+ MaybeNotifyBatchesEnded();
+ }
+}
+
+void CookiesTreeModel::RecordBatchSeen() {
+ batches_seen_++;
+}
+
void CookiesTreeModel::NotifyObserverBeginBatch() {
// Only notify the model once if we're batching in a nested manner.
- if (batch_update_++ == 0) {
+ if (batches_started_++ == 0) {
FOR_EACH_OBSERVER(Observer,
cookies_observer_list_,
TreeModelBeginBatch(this));
@@ -1435,9 +1459,15 @@ void CookiesTreeModel::NotifyObserverBeginBatch() {
}
void CookiesTreeModel::NotifyObserverEndBatch() {
+ batches_ended_++;
+ MaybeNotifyBatchesEnded();
+}
+
+void CookiesTreeModel::MaybeNotifyBatchesEnded() {
// Only notify the observers if this is the outermost call to EndBatch() if
// called in a nested manner.
- if (--batch_update_ == 0) {
+ if (batches_ended_ == batches_started_ &&
+ batches_seen_ == batches_expected_) {
FOR_EACH_OBSERVER(Observer,
cookies_observer_list_,
TreeModelEndBatch(this));
« no previous file with comments | « chrome/browser/browsing_data/cookies_tree_model.h ('k') | chrome/browser/browsing_data/local_data_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698