OLD | NEW |
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 #ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ |
6 #define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ | 6 #define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as | 192 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as |
193 // the WebContents could be deleted if the user closed the tab. | 193 // the WebContents could be deleted if the user closed the tab. |
194 static int64_t IdFromWebContents(content::WebContents* web_contents); | 194 static int64_t IdFromWebContents(content::WebContents* web_contents); |
195 | 195 |
196 // Return whether tabs are being loaded during session restore. | 196 // Return whether tabs are being loaded during session restore. |
197 bool IsSessionRestoreLoadingTabs() const { | 197 bool IsSessionRestoreLoadingTabs() const { |
198 return is_session_restore_loading_tabs_; | 198 return is_session_restore_loading_tabs_; |
199 } | 199 } |
200 | 200 |
| 201 bool HasSessionRestoreInitialForegroundTabChanged() const { |
| 202 return initial_session_restore_foreground_tab_changed_; |
| 203 } |
| 204 |
201 private: | 205 private: |
202 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, PurgeBackgroundRenderer); | 206 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, PurgeBackgroundRenderer); |
203 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ActivateTabResetPurgeState); | 207 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ActivateTabResetPurgeState); |
204 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ShouldPurgeAtDefaultTime); | 208 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ShouldPurgeAtDefaultTime); |
205 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DefaultTimeToPurgeInCorrectRange); | 209 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DefaultTimeToPurgeInCorrectRange); |
206 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); | 210 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); |
207 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); | 211 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); |
208 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); | 212 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); |
209 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); | 213 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); |
210 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); | 214 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 std::vector<BrowserInfo> test_browser_info_list_; | 492 std::vector<BrowserInfo> test_browser_info_list_; |
489 | 493 |
490 // List of observers that will receive notifications on state changes. | 494 // List of observers that will receive notifications on state changes. |
491 base::ObserverList<TabManagerObserver> observers_; | 495 base::ObserverList<TabManagerObserver> observers_; |
492 | 496 |
493 bool is_session_restore_loading_tabs_; | 497 bool is_session_restore_loading_tabs_; |
494 | 498 |
495 class TabManagerSessionRestoreObserver; | 499 class TabManagerSessionRestoreObserver; |
496 std::unique_ptr<TabManagerSessionRestoreObserver> session_restore_observer_; | 500 std::unique_ptr<TabManagerSessionRestoreObserver> session_restore_observer_; |
497 | 501 |
| 502 // True if the initial foreground tab is switched away. |
| 503 bool initial_session_restore_foreground_tab_changed_; |
| 504 |
498 // When the timer fires, it forces loading the next background tab if needed. | 505 // When the timer fires, it forces loading the next background tab if needed. |
499 std::unique_ptr<base::OneShotTimer> force_load_timer_; | 506 std::unique_ptr<base::OneShotTimer> force_load_timer_; |
500 | 507 |
501 // The list of navigations that are delayed. | 508 // The list of navigations that are delayed. |
502 std::vector<BackgroundTabNavigationThrottle*> pending_navigations_; | 509 std::vector<BackgroundTabNavigationThrottle*> pending_navigations_; |
503 | 510 |
504 // The tabs that are currently loading. We will consider loading the next | 511 // The tabs that are currently loading. We will consider loading the next |
505 // background tab when these tabs have finished loading or a background tab | 512 // background tab when these tabs have finished loading or a background tab |
506 // is brought to foreground. | 513 // is brought to foreground. |
507 std::set<content::WebContents*> loading_contents_; | 514 std::set<content::WebContents*> loading_contents_; |
508 | 515 |
509 // GRC tab signal observer, receives tab scoped signal from GRC. | 516 // GRC tab signal observer, receives tab scoped signal from GRC. |
510 std::unique_ptr<GRCTabSignalObserver> grc_tab_signal_observer_; | 517 std::unique_ptr<GRCTabSignalObserver> grc_tab_signal_observer_; |
511 | 518 |
512 // Records UMAs for tab and system-related events and properties during | 519 // Records UMAs for tab and system-related events and properties during |
513 // session restore. | 520 // session restore. |
514 std::unique_ptr<TabManagerStatsCollector> tab_manager_stats_collector_; | 521 std::unique_ptr<TabManagerStatsCollector> tab_manager_stats_collector_; |
515 | 522 |
516 // Weak pointer factory used for posting delayed tasks. | 523 // Weak pointer factory used for posting delayed tasks. |
517 base::WeakPtrFactory<TabManager> weak_ptr_factory_; | 524 base::WeakPtrFactory<TabManager> weak_ptr_factory_; |
518 | 525 |
519 DISALLOW_COPY_AND_ASSIGN(TabManager); | 526 DISALLOW_COPY_AND_ASSIGN(TabManager); |
520 }; | 527 }; |
521 | 528 |
522 } // namespace resource_coordinator | 529 } // namespace resource_coordinator |
523 | 530 |
524 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ | 531 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ |
OLD | NEW |