summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 13:35:01 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 13:35:01 +0000
commit96338c731b6f282450b425149f3df6c605f8f1ec (patch)
tree684f7de68e8cbbd4504c3b585ef88f2c85d8682e /ui/base
parentf5123edcdac008585dabc2bfa4f006f1aa948243 (diff)
downloadchromium_src-96338c731b6f282450b425149f3df6c605f8f1ec.zip
chromium_src-96338c731b6f282450b425149f3df6c605f8f1ec.tar.gz
chromium_src-96338c731b6f282450b425149f3df6c605f8f1ec.tar.bz2
ui: Do not expose the underline type (vector) used in ListModel.
And while I'm here rename item_at to GetItemAt. I think this is more consistent with AddAt, DeleteAt, etc. TEST=ui_unittests --gtest_filter=ListModel* R=xiyuan@chromium.org TBR=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/10386118 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/models/list_model.h13
-rw-r--r--ui/base/models/list_model_unittest.cc12
2 files changed, 11 insertions, 14 deletions
diff --git a/ui/base/models/list_model.h b/ui/base/models/list_model.h
index 3634ed1..9352fa5 100644
--- a/ui/base/models/list_model.h
+++ b/ui/base/models/list_model.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,8 +8,8 @@
#include "base/basictypes.h"
#include "base/logging.h"
-#include "base/observer_list.h"
#include "base/memory/scoped_vector.h"
+#include "base/observer_list.h"
#include "ui/base/models/list_model_observer.h"
namespace ui {
@@ -20,8 +20,6 @@ namespace ui {
template <class ItemType>
class ListModel {
public:
- typedef std::vector<ItemType*> Items;
-
ListModel() {}
virtual ~ListModel() {}
@@ -93,15 +91,14 @@ class ListModel {
}
int item_count() const { return static_cast<int>(items_.size()); }
- const Items& items() const { return items_.get(); }
- const ItemType* item_at(int index) const {
+ const ItemType* GetItemAt(int index) const {
DCHECK(index >= 0 && index < item_count());
return items_[index];
}
- ItemType* item_at(int index) {
+ ItemType* GetItemAt(int index) {
return const_cast<ItemType*>(
- const_cast<const ListModel<ItemType>*>(this)->item_at(index));
+ const_cast<const ListModel<ItemType>*>(this)->GetItemAt(index));
}
private:
diff --git a/ui/base/models/list_model_unittest.cc b/ui/base/models/list_model_unittest.cc
index 1718431..2dcaf4d 100644
--- a/ui/base/models/list_model_unittest.cc
+++ b/ui/base/models/list_model_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -82,9 +82,9 @@ TEST_F(ListModelTest, Add) {
EXPECT_EQ(3, model.item_count());
// First one should be FooItem(2), followed by FooItem(0) and FooItem(1)
- EXPECT_EQ(2, model.item_at(0)->id());
- EXPECT_EQ(0, model.item_at(1)->id());
- EXPECT_EQ(1, model.item_at(2)->id());
+ EXPECT_EQ(2, model.GetItemAt(0)->id());
+ EXPECT_EQ(0, model.GetItemAt(1)->id());
+ EXPECT_EQ(1, model.GetItemAt(2)->id());
}
TEST_F(ListModelTest, Remove) {
@@ -102,8 +102,8 @@ TEST_F(ListModelTest, Remove) {
ExpectCountsEqual(0, 1, 0);
EXPECT_EQ(2, model.item_count());
- EXPECT_EQ(0, model.item_at(0)->id());
- EXPECT_EQ(2, model.item_at(1)->id());
+ EXPECT_EQ(0, model.GetItemAt(0)->id());
+ EXPECT_EQ(2, model.GetItemAt(1)->id());
// Remove all items from model and delete them.
model.DeleteAll();