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

Side by Side Diff: chrome/browser/ui/tab_contents/tab_contents_iterator.cc

Issue 1644773003: Remove BrowserIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-desktop-1
Patch Set: . Created 4 years, 10 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/tab_contents/tab_contents_iterator.h" 5 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 11
12 TabContentsIterator::TabContentsIterator() 12 TabContentsIterator::TabContentsIterator()
13 : web_view_index_(-1), 13 : web_view_index_(-1),
14 cur_(NULL) { 14 cur_(NULL),
15 browser_iterator_(BrowserList::GetInstance()->begin()) {
15 // Load the first WebContents into |cur_|. 16 // Load the first WebContents into |cur_|.
16 Next(); 17 Next();
17 } 18 }
18 19
20 TabContentsIterator::~TabContentsIterator() {
21 }
22
19 void TabContentsIterator::Next() { 23 void TabContentsIterator::Next() {
20 // The current WebContents should be valid unless we are at the beginning. 24 // The current WebContents should be valid unless we are at the beginning.
21 DCHECK(cur_ || web_view_index_ == -1) << "Trying to advance past the end"; 25 DCHECK(cur_ || web_view_index_ == -1) << "Trying to advance past the end";
22 26
23 // Update |cur_| to the next WebContents in the list. 27 // Update |cur_| to the next WebContents in the list.
24 while (!browser_iterator_.done()) { 28 while (browser_iterator_ != BrowserList::GetInstance()->end()) {
25 if (++web_view_index_ >= browser_iterator_->tab_strip_model()->count()) { 29 if (++web_view_index_ >= (*browser_iterator_)->tab_strip_model()->count()) {
26 // Advance to the next Browser in the list. 30 // Advance to the next Browser in the list.
27 browser_iterator_.Next(); 31 ++browser_iterator_;
28 web_view_index_ = -1; 32 web_view_index_ = -1;
29 continue; 33 continue;
30 } 34 }
31 35
32 content::WebContents* next_tab = browser_iterator_->tab_strip_model() 36 content::WebContents* next_tab = (*browser_iterator_)->tab_strip_model()
33 ->GetWebContentsAt(web_view_index_); 37 ->GetWebContentsAt(web_view_index_);
34 if (next_tab) { 38 if (next_tab) {
35 cur_ = next_tab; 39 cur_ = next_tab;
36 return; 40 return;
37 } 41 }
38 } 42 }
39 // Reached the end. 43 // Reached the end.
40 cur_ = NULL; 44 cur_ = NULL;
41 } 45 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_contents/tab_contents_iterator.h ('k') | chrome/browser/ui/tabs/pinned_tab_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698