| OLD | NEW |
| 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/cookies_tree_model.h" | 5 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 } | 1594 } |
| 1595 } | 1595 } |
| 1596 | 1596 |
| 1597 void CookiesTreeModel::RecordBatchSeen() { | 1597 void CookiesTreeModel::RecordBatchSeen() { |
| 1598 batches_seen_++; | 1598 batches_seen_++; |
| 1599 } | 1599 } |
| 1600 | 1600 |
| 1601 void CookiesTreeModel::NotifyObserverBeginBatch() { | 1601 void CookiesTreeModel::NotifyObserverBeginBatch() { |
| 1602 // Only notify the model once if we're batching in a nested manner. | 1602 // Only notify the model once if we're batching in a nested manner. |
| 1603 if (batches_started_++ == 0) { | 1603 if (batches_started_++ == 0) { |
| 1604 FOR_EACH_OBSERVER(Observer, | 1604 for (Observer& observer : cookies_observer_list_) |
| 1605 cookies_observer_list_, | 1605 observer.TreeModelBeginBatch(this); |
| 1606 TreeModelBeginBatch(this)); | |
| 1607 } | 1606 } |
| 1608 } | 1607 } |
| 1609 | 1608 |
| 1610 void CookiesTreeModel::NotifyObserverEndBatch() { | 1609 void CookiesTreeModel::NotifyObserverEndBatch() { |
| 1611 batches_ended_++; | 1610 batches_ended_++; |
| 1612 MaybeNotifyBatchesEnded(); | 1611 MaybeNotifyBatchesEnded(); |
| 1613 } | 1612 } |
| 1614 | 1613 |
| 1615 void CookiesTreeModel::MaybeNotifyBatchesEnded() { | 1614 void CookiesTreeModel::MaybeNotifyBatchesEnded() { |
| 1616 // Only notify the observers if this is the outermost call to EndBatch() if | 1615 // Only notify the observers if this is the outermost call to EndBatch() if |
| 1617 // called in a nested manner. | 1616 // called in a nested manner. |
| 1618 if (batches_ended_ == batches_started_ && | 1617 if (batches_ended_ == batches_started_ && |
| 1619 batches_seen_ == batches_expected_) { | 1618 batches_seen_ == batches_expected_) { |
| 1620 FOR_EACH_OBSERVER(Observer, | 1619 for (Observer& observer : cookies_observer_list_) |
| 1621 cookies_observer_list_, | 1620 observer.TreeModelEndBatch(this); |
| 1622 TreeModelEndBatch(this)); | |
| 1623 SetBatchExpectation(0, true); | 1621 SetBatchExpectation(0, true); |
| 1624 } | 1622 } |
| 1625 } | 1623 } |
| OLD | NEW |