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

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

Issue 7003039: ui/base/models: Add empty() accessor to TreeNode class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sky review Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/cookies_tree_model.h" 5 #include "chrome/browser/cookies_tree_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 NotifyObserverTreeNodeChanged(root); 701 NotifyObserverTreeNodeChanged(root);
702 NotifyObserverEndBatch(); 702 NotifyObserverEndBatch();
703 } 703 }
704 704
705 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) { 705 void CookiesTreeModel::DeleteCookieNode(CookieTreeNode* cookie_node) {
706 if (cookie_node == GetRoot()) 706 if (cookie_node == GetRoot())
707 return; 707 return;
708 cookie_node->DeleteStoredObjects(); 708 cookie_node->DeleteStoredObjects();
709 CookieTreeNode* parent_node = cookie_node->parent(); 709 CookieTreeNode* parent_node = cookie_node->parent();
710 delete Remove(parent_node, cookie_node); 710 delete Remove(parent_node, cookie_node);
711 if (parent_node->child_count() == 0) 711 if (parent_node->empty())
712 DeleteCookieNode(parent_node); 712 DeleteCookieNode(parent_node);
713 } 713 }
714 714
715 void CookiesTreeModel::UpdateSearchResults(const std::wstring& filter) { 715 void CookiesTreeModel::UpdateSearchResults(const std::wstring& filter) {
716 CookieTreeNode* root = GetRoot(); 716 CookieTreeNode* root = GetRoot();
717 int num_children = root->child_count(); 717 int num_children = root->child_count();
718 NotifyObserverBeginBatch(); 718 NotifyObserverBeginBatch();
719 for (int i = num_children - 1; i >= 0; --i) 719 for (int i = num_children - 1; i >= 0; --i)
720 delete Remove(root, root->GetChild(i)); 720 delete Remove(root, root->GetChild(i));
721 LoadCookiesWithFilter(filter); 721 LoadCookiesWithFilter(filter);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 953
954 void CookiesTreeModel::NotifyObserverEndBatch() { 954 void CookiesTreeModel::NotifyObserverEndBatch() {
955 // Only notify the observers if this is the outermost call to EndBatch() if 955 // Only notify the observers if this is the outermost call to EndBatch() if
956 // called in a nested manner. 956 // called in a nested manner.
957 if (--batch_update_ == 0) { 957 if (--batch_update_ == 0) {
958 FOR_EACH_OBSERVER(Observer, 958 FOR_EACH_OBSERVER(Observer,
959 cookies_observer_list_, 959 cookies_observer_list_,
960 TreeModelEndBatch(this)); 960 TreeModelEndBatch(this));
961 } 961 }
962 } 962 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.cc ('k') | chrome/browser/extensions/extension_bookmark_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698