Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1165)

Side by Side Diff: ui/app_list/app_list_item_list.cc

Issue 487853003: Add additional CHECKs to AppListModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/app_list/app_list_item_list_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/app_list/app_list_item_list.h" 5 #include "ui/app_list/app_list_item_list.h"
6 6
7 #include "ui/app_list/app_list_item.h" 7 #include "ui/app_list/app_list_item.h"
8 8
9 namespace app_list { 9 namespace app_list {
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 observers_, 159 observers_,
160 OnListItemAdded(index, item)); 160 OnListItemAdded(index, item));
161 return item; 161 return item;
162 } 162 }
163 163
164 void AppListItemList::DeleteItem(const std::string& id) { 164 void AppListItemList::DeleteItem(const std::string& id) {
165 scoped_ptr<AppListItem> item = RemoveItem(id); 165 scoped_ptr<AppListItem> item = RemoveItem(id);
166 // |item| will be deleted on destruction. 166 // |item| will be deleted on destruction.
167 } 167 }
168 168
169 scoped_ptr<AppListItem> AppListItemList::RemoveItem( 169 scoped_ptr<AppListItem> AppListItemList::RemoveItem(const std::string& id) {
170 const std::string& id) {
171 size_t index; 170 size_t index;
172 if (FindItemIndex(id, &index)) 171 if (!FindItemIndex(id, &index))
173 return RemoveItemAt(index); 172 LOG(FATAL) << "RemoveItem: Not found: " << id;
174 173 return RemoveItemAt(index);
175 return scoped_ptr<AppListItem>();
176 } 174 }
177 175
178 scoped_ptr<AppListItem> AppListItemList::RemoveItemAt(size_t index) { 176 scoped_ptr<AppListItem> AppListItemList::RemoveItemAt(size_t index) {
179 DCHECK_LT(index, item_count()); 177 CHECK_LT(index, item_count());
180 AppListItem* item = app_list_items_[index]; 178 AppListItem* item = app_list_items_[index];
181 app_list_items_.weak_erase(app_list_items_.begin() + index); 179 app_list_items_.weak_erase(app_list_items_.begin() + index);
182 FOR_EACH_OBSERVER(AppListItemListObserver, 180 FOR_EACH_OBSERVER(AppListItemListObserver,
183 observers_, 181 observers_,
184 OnListItemRemoved(index, item)); 182 OnListItemRemoved(index, item));
185 return make_scoped_ptr<AppListItem>(item); 183 return make_scoped_ptr<AppListItem>(item);
186 } 184 }
187 185
188 void AppListItemList::DeleteItemAt(size_t index) { 186 void AppListItemList::DeleteItemAt(size_t index) {
189 scoped_ptr<AppListItem> item = RemoveItemAt(index); 187 scoped_ptr<AppListItem> item = RemoveItemAt(index);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 else 236 else
239 cur->set_position(prev->position().CreateAfter()); 237 cur->set_position(prev->position().CreateAfter());
240 prev = cur; 238 prev = cur;
241 } 239 }
242 FOR_EACH_OBSERVER(AppListItemListObserver, 240 FOR_EACH_OBSERVER(AppListItemListObserver,
243 observers_, 241 observers_,
244 OnListItemMoved(index, index, app_list_items_[index])); 242 OnListItemMoved(index, index, app_list_items_[index]));
245 } 243 }
246 244
247 } // namespace app_list 245 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | ui/app_list/app_list_item_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698