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

Side by Side Diff: chrome/browser/ui/browser_iterator.h

Issue 1637943003: Remove HostDesktopType from BrowserList::GetInstance() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen-wrapper-land
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) 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 #ifndef CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ 5 #ifndef CHROME_BROWSER_UI_BROWSER_ITERATOR_H_
6 #define CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ 6 #define CHROME_BROWSER_UI_BROWSER_ITERATOR_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/browser/ui/browser_list.h" 9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/host_desktop.h" 10 #include "chrome/browser/ui/host_desktop.h"
11 11
12 class Browser; 12 class Browser;
13 13
14 namespace chrome { 14 namespace chrome {
15 15
16 // TODO(scottmg): Remove this file entirely. http://crbug.com/558054.
17
16 // Iterates over all existing browsers (potentially across multiple desktops). 18 // Iterates over all existing browsers (potentially across multiple desktops).
17 // Note: to iterate only over the browsers of a specific desktop, use the 19 // Note: to iterate only over the browsers of a specific desktop, use the
18 // const_iterator of a given BrowserList instead. 20 // const_iterator of a given BrowserList instead.
19 // 21 //
20 // Example: 22 // Example:
21 // for (BrowserIterator iterator; !iterator.done(); iterator.Next()) { 23 // for (BrowserIterator iterator; !iterator.done(); iterator.Next()) {
22 // Browser* cur = *iterator; 24 // Browser* cur = *iterator;
23 // -or- 25 // -or-
24 // iterator->OperationOnBrowser(); 26 // iterator->OperationOnBrowser();
25 // ... 27 // ...
26 // } 28 // }
27 class BrowserIterator { 29 class BrowserIterator {
28 public: 30 public:
29 BrowserIterator(); 31 BrowserIterator();
30 ~BrowserIterator(); 32 ~BrowserIterator();
31 33
32 // Returns true if this iterator is past the last Browser. 34 // Returns true if this iterator is past the last Browser.
33 bool done() const { 35 bool done() const {
34 // |current_iterator_| is never at the end of a list unless it is done (it 36 // |iterator_| is never at the end of a list unless it is done (it
35 // immediately moves to the next browser list upon hitting the end of the 37 // immediately moves to the next browser list upon hitting the end of the
36 // current list unless there are no remaining empty browser lists). 38 // current list unless there are no remaining empty browser lists).
37 return current_iterator_ == current_browser_list_->end(); 39 return iterator_ == browser_list_->end();
38 } 40 }
39 41
40 // Returns the current Browser, valid as long as !done(). 42 // Returns the current Browser, valid as long as !done().
41 Browser* operator->() const { 43 Browser* operator->() const { return *iterator_; }
42 return *current_iterator_; 44 Browser* operator*() const { return *iterator_; }
43 }
44 Browser* operator*() const {
45 return *current_iterator_;
46 }
47 45
48 // Advances |current_iterator_| to the next browser. 46 // Advances |iterator_| to the next browser.
49 void Next(); 47 void Next();
50 48
51 private: 49 private:
52 // If |current_iterator_| is at |current_browser_list_->end()|, advance to the 50 // The BrowserList being iterated over.
53 // next non-empty browser list. After a call to this method: either 51 BrowserList* browser_list_;
54 // |current_iterator_| is valid or done().
55 void NextBrowserListIfAtEnd();
56 52
57 // The BrowserList currently being iterated over. Instances of this class do 53 // The underlying iterator over browsers in |browser_list_|.
58 // not own this pointer. 54 BrowserList::const_iterator iterator_;
59 BrowserList* current_browser_list_;
60
61 // The underlying iterator over browsers in |current_browser_list_|.
62 BrowserList::const_iterator current_iterator_;
63
64 // The next HostDesktopType to iterate over when |current_iterator_| reaches
65 // |current_browser_list_->end()|.
66 HostDesktopType next_desktop_type_;
67 55
68 DISALLOW_COPY_AND_ASSIGN(BrowserIterator); 56 DISALLOW_COPY_AND_ASSIGN(BrowserIterator);
69 }; 57 };
70 58
71 } // namespace chrome 59 } // namespace chrome
72 60
73 #endif // CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ 61 #endif // CHROME_BROWSER_UI_BROWSER_ITERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698