OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_MODEL_SNAPSHOT_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_MODEL_SNAPSHOT_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 #include <vector> |
| 10 |
| 11 #import "base/ios/weak_nsobject.h" |
| 12 |
| 13 @class TabModel; |
| 14 @class Tab; |
| 15 |
| 16 // Contains an approximate snapshot of the tab model passed to the initializer. |
| 17 // Used to feed the cells to UICollectionViews, and to compute the changes |
| 18 // required to update UICollectionViews. |
| 19 // The changes are computed based on a list of hashes of the tabs. |
| 20 // One resulting limitation is that there is no differenciation between a tab |
| 21 // that is partially updated (because the snapshot changed), and a completely |
| 22 // new tab replacing an older tab. This limitation has little impact because |
| 23 // very few navigations occur when the tab switcher is shown. |
| 24 class TabModelSnapshot { |
| 25 public: |
| 26 // Default constructor. |tabModel| can be nil. |
| 27 explicit TabModelSnapshot(TabModel* tabModel); |
| 28 ~TabModelSnapshot(); |
| 29 // Returns the list of hashes for every tabs contained in the TabModel during |
| 30 // the initialization. |
| 31 std::vector<size_t> const& hashes() const; |
| 32 // Returns a list of weak pointers to the tabs. |
| 33 std::vector<base::WeakNSObject<Tab>> const& tabs() const; |
| 34 // Returns a hash of the properties of a tab that are visible in the tab |
| 35 // switcher's UI. |
| 36 static size_t hashOfTheVisiblePropertiesOfATab(Tab* tab); |
| 37 |
| 38 private: |
| 39 std::vector<base::WeakNSObject<Tab>> _tabs; |
| 40 std::vector<size_t> _hashes; |
| 41 }; |
| 42 |
| 43 #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_MODEL_SNAPSHOT_H_ |
OLD | NEW |