Index: ui/views/view_model.h |
diff --git a/ui/views/view_model.h b/ui/views/view_model.h |
index 6a68fb10f84ee18f51fec327b0a7cb2e128f7726..2493878b1df8b06114f957e81c4e6a81e3644e8c 100644 |
--- a/ui/views/view_model.h |
+++ b/ui/views/view_model.h |
@@ -9,6 +9,7 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/logging.h" |
#include "ui/gfx/rect.h" |
#include "ui/views/views_export.h" |
@@ -46,14 +47,17 @@ class VIEWS_EXPORT ViewModel { |
// Returns the view at the specified index. |
View* view_at(int index) const { |
+ check_index(index); |
return entries_[index].view; |
} |
void set_ideal_bounds(int index, const gfx::Rect& bounds) { |
+ check_index(index); |
entries_[index].ideal_bounds = bounds; |
} |
const gfx::Rect& ideal_bounds(int index) const { |
+ check_index(index); |
return entries_[index].ideal_bounds; |
} |
@@ -70,6 +74,15 @@ class VIEWS_EXPORT ViewModel { |
}; |
typedef std::vector<Entry> Entries; |
+#if !defined(NDEBUG) |
+ void check_index(int index) const { |
+ DCHECK_LT(index, static_cast<int>(entries_.size())); |
+ DCHECK_GE(index, 0); |
+ } |
+#else |
+ void check_index(int index) const {} |
+#endif |
+ |
Entries entries_; |
DISALLOW_COPY_AND_ASSIGN(ViewModel); |