Chromium Code Reviews| Index: chrome/browser/policy/policy_bundle.cc |
| diff --git a/chrome/browser/policy/policy_bundle.cc b/chrome/browser/policy/policy_bundle.cc |
| index ed852cd79a6d6b0e383f46104821b436102d0b80..a1027f983efa6dd515545442157533c2f1145fcd 100644 |
| --- a/chrome/browser/policy/policy_bundle.cc |
| +++ b/chrome/browser/policy/policy_bundle.cc |
| @@ -86,6 +86,32 @@ void PolicyBundle::MergeFrom(const PolicyBundle& other) { |
| } |
| } |
| +bool PolicyBundle::Equals(const PolicyBundle& other) const { |
| + // Equals() has the peculiarity that an entry with an empty PolicyMap equals |
| + // an non-existant entry. This handles usage of non-const Get() that doesn't |
| + // insert any policies. |
| + const_iterator it_this = begin(); |
| + const_iterator it_other = other.begin(); |
| + |
| + for (;;) { |
|
Mattias Nissler (ping if slow)
2012/05/15 17:07:24
not sure what the style rule for this is, but whil
Joao da Silva
2012/05/16 10:25:44
I find this style cute:
#define ever ;;
for (eve
|
| + // Skip empty PolicyMaps. |
| + while (it_this != end() && it_this->second->empty()) |
| + ++it_this; |
| + while (it_other != other.end() && it_other->second->empty()) |
| + ++it_other; |
| + if (it_this != end() && it_other != other.end()) { |
|
Mattias Nissler (ping if slow)
2012/05/15 17:07:24
It's probably easier to read this if you were to p
Joao da Silva
2012/05/16 10:25:44
Done. I think you meant that the test for the brea
|
| + if (it_this->first != it_other->first || |
| + !it_this->second->Equals(*it_other->second)) |
| + return false; |
| + ++it_this; |
| + ++it_other; |
| + } else { |
| + break; |
| + } |
| + } |
| + return it_this == end() && it_other == other.end(); |
| +} |
| + |
| PolicyBundle::const_iterator PolicyBundle::begin() const { |
| return policy_bundle_.begin(); |
| } |