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

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

Issue 10542010: TabContentsWrapper -> TabContents, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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/printing/background_printing_manager.h" 10 #include "chrome/browser/printing/background_printing_manager.h"
11 11
12 namespace { 12 namespace {
13 13
14 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { 14 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() {
15 return g_browser_process->background_printing_manager(); 15 return g_browser_process->background_printing_manager();
16 } 16 }
17 17
18 } // namespace 18 } // namespace
19 19
20 TabContentsIterator::TabContentsIterator() 20 TabContentsIterator::TabContentsIterator()
21 : browser_iterator_(BrowserList::begin()), 21 : browser_iterator_(BrowserList::begin()),
22 web_view_index_(-1), 22 web_view_index_(-1),
23 bg_printing_iterator_(GetBackgroundPrintingManager()->begin()), 23 bg_printing_iterator_(GetBackgroundPrintingManager()->begin()),
24 cur_(NULL) { 24 cur_(NULL) {
25 Advance(); 25 Advance();
26 } 26 }
27 27
28 void TabContentsIterator::Advance() { 28 void TabContentsIterator::Advance() {
29 // The current WebContents should be valid unless we are at the beginning. 29 // The current TabContents should be valid unless we are at the beginning.
30 DCHECK(cur_ || (web_view_index_ == -1 && 30 DCHECK(cur_ || (web_view_index_ == -1 &&
31 browser_iterator_ == BrowserList::begin())) 31 browser_iterator_ == BrowserList::begin()))
32 << "Trying to advance past the end"; 32 << "Trying to advance past the end";
33 33
34 // Update cur_ to the next WebContents in the list. 34 // Update cur_ to the next TabContents in the list.
35 while (browser_iterator_ != BrowserList::end()) { 35 while (browser_iterator_ != BrowserList::end()) {
36 if (++web_view_index_ >= (*browser_iterator_)->tab_count()) { 36 if (++web_view_index_ >= (*browser_iterator_)->tab_count()) {
37 // Advance to the next Browser in the list. 37 // Advance to the next Browser in the list.
38 ++browser_iterator_; 38 ++browser_iterator_;
39 web_view_index_ = -1; 39 web_view_index_ = -1;
40 continue; 40 continue;
41 } 41 }
42 42
43 TabContentsWrapper* next_tab = 43 TabContents* next_tab =
44 (*browser_iterator_)->GetTabContentsWrapperAt(web_view_index_); 44 (*browser_iterator_)->GetTabContentsWrapperAt(web_view_index_);
45 if (next_tab) { 45 if (next_tab) {
46 cur_ = next_tab; 46 cur_ = next_tab;
47 return; 47 return;
48 } 48 }
49 } 49 }
50 // If no more WebContents from Browsers, check the BackgroundPrintingManager. 50 // If no more TabContents from Browsers, check the BackgroundPrintingManager.
51 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { 51 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) {
52 cur_ = *bg_printing_iterator_; 52 cur_ = *bg_printing_iterator_;
53 CHECK(cur_); 53 CHECK(cur_);
54 ++bg_printing_iterator_; 54 ++bg_printing_iterator_;
55 return; 55 return;
56 } 56 }
57 // Reached the end - no more WebContents. 57 // Reached the end - no more TabContents.
58 cur_ = NULL; 58 cur_ = NULL;
59 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698