| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/autocomplete/autocomplete_match.h" | 6 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
| 8 | 8 |
| 9 // AutocompleteMatch ---------------------------------------------------------- | 9 // AutocompleteMatch ---------------------------------------------------------- |
| 10 | 10 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 void AutocompleteMatch::ValidateClassifications( | 160 void AutocompleteMatch::ValidateClassifications( |
| 161 const string16& text, | 161 const string16& text, |
| 162 const ACMatchClassifications& classifications) const { | 162 const ACMatchClassifications& classifications) const { |
| 163 if (text.empty()) { | 163 if (text.empty()) { |
| 164 DCHECK(classifications.size() == 0); | 164 DCHECK(classifications.size() == 0); |
| 165 return; | 165 return; |
| 166 } | 166 } |
| 167 | 167 |
| 168 // The classifications should always cover the whole string. | 168 // The classifications should always cover the whole string. |
| 169 DCHECK(classifications.size() > 0) << "No classification for text"; | 169 DCHECK(!classifications.empty()) << "No classification for text"; |
| 170 DCHECK(classifications[0].offset == 0) << "Classification misses beginning"; | 170 DCHECK(classifications[0].offset == 0) << "Classification misses beginning"; |
| 171 if (classifications.size() == 1) | 171 if (classifications.size() == 1) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 // The classifications should always be sorted. | 174 // The classifications should always be sorted. |
| 175 size_t last_offset = classifications[0].offset; | 175 size_t last_offset = classifications[0].offset; |
| 176 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); | 176 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); |
| 177 i != classifications.end(); ++i) { | 177 i != classifications.end(); ++i) { |
| 178 DCHECK(i->offset > last_offset) << "Classification unsorted"; | 178 DCHECK(i->offset > last_offset) << "Classification unsorted"; |
| 179 DCHECK(i->offset < text.length()) << "Classification out of bounds"; | 179 DCHECK(i->offset < text.length()) << "Classification out of bounds"; |
| 180 last_offset = i->offset; | 180 last_offset = i->offset; |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 #endif | 183 #endif |
| OLD | NEW |