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

Side by Side Diff: chrome/browser/ui/search_engines/template_url_table_model.cc

Issue 843643002: Cleanup: Remove some redundant container clear() calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/search_engines/template_url_table_model.h" 5 #include "chrome/browser/ui/search_engines/template_url_table_model.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/task/cancelable_task_tracker.h" 9 #include "base/task/cancelable_task_tracker.h"
10 #include "chrome/browser/favicon/favicon_service.h" 10 #include "chrome/browser/favicon/favicon_service.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 favicon_service_(favicon_service) { 121 favicon_service_(favicon_service) {
122 DCHECK(template_url_service); 122 DCHECK(template_url_service);
123 template_url_service_->Load(); 123 template_url_service_->Load();
124 template_url_service_->AddObserver(this); 124 template_url_service_->AddObserver(this);
125 Reload(); 125 Reload();
126 } 126 }
127 127
128 TemplateURLTableModel::~TemplateURLTableModel() { 128 TemplateURLTableModel::~TemplateURLTableModel() {
129 template_url_service_->RemoveObserver(this); 129 template_url_service_->RemoveObserver(this);
130 STLDeleteElements(&entries_); 130 STLDeleteElements(&entries_);
131 entries_.clear();
132 } 131 }
133 132
134 void TemplateURLTableModel::Reload() { 133 void TemplateURLTableModel::Reload() {
135 STLDeleteElements(&entries_); 134 STLDeleteElements(&entries_);
136 entries_.clear();
137 135
138 TemplateURLService::TemplateURLVector urls = 136 TemplateURLService::TemplateURLVector urls =
139 template_url_service_->GetTemplateURLs(); 137 template_url_service_->GetTemplateURLs();
140 138
141 std::vector<ModelEntry*> default_entries, other_entries, extension_entries; 139 std::vector<ModelEntry*> default_entries, other_entries, extension_entries;
142 // Keywords that can be made the default first. 140 // Keywords that can be made the default first.
143 for (TemplateURLService::TemplateURLVector::iterator i = urls.begin(); 141 for (TemplateURLService::TemplateURLVector::iterator i = urls.begin();
144 i != urls.end(); ++i) { 142 i != urls.end(); ++i) {
145 TemplateURL* template_url = *i; 143 TemplateURL* template_url = *i;
146 // NOTE: we don't use ShowInDefaultList here to avoid items bouncing around 144 // NOTE: we don't use ShowInDefaultList here to avoid items bouncing around
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 return entry.Pass(); 383 return entry.Pass();
386 } 384 }
387 385
388 void TemplateURLTableModel::AddEntry(int index, scoped_ptr<ModelEntry> entry) { 386 void TemplateURLTableModel::AddEntry(int index, scoped_ptr<ModelEntry> entry) {
389 entries_.insert(entries_.begin() + index, entry.release()); 387 entries_.insert(entries_.begin() + index, entry.release());
390 if (index <= last_other_engine_index_) 388 if (index <= last_other_engine_index_)
391 ++last_other_engine_index_; 389 ++last_other_engine_index_;
392 if (observer_) 390 if (observer_)
393 observer_->OnItemsAdded(index, 1); 391 observer_->OnItemsAdded(index, 1);
394 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698