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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool CanSuspendBackgroundedRenderer(int render_process_id) const; | 147 bool CanSuspendBackgroundedRenderer(int render_process_id) const; |
148 | 148 |
149 // Returns true if |first| is considered less desirable to be killed than | 149 // Returns true if |first| is considered less desirable to be killed than |
150 // |second|. | 150 // |second|. |
151 static bool CompareTabStats(const TabStats& first, const TabStats& second); | 151 static bool CompareTabStats(const TabStats& first, const TabStats& second); |
152 | 152 |
153 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as | 153 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as |
154 // the WebContents could be deleted if the user closed the tab. | 154 // the WebContents could be deleted if the user closed the tab. |
155 static int64_t IdFromWebContents(content::WebContents* web_contents); | 155 static int64_t IdFromWebContents(content::WebContents* web_contents); |
156 | 156 |
| 157 void MarkSessionRestoreStarted() { is_during_session_restore_ = true; } |
| 158 |
| 159 void MarkSessionRestoreEnded() { is_during_session_restore_ = false; } |
| 160 |
| 161 bool IsDuringSessionRestore() const { return is_during_session_restore_; } |
| 162 |
| 163 bool HasInitialActiveTabChanged() const { |
| 164 return initial_active_tab_changed_; |
| 165 } |
| 166 |
157 private: | 167 private: |
158 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, PurgeBackgroundRenderer); | 168 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, PurgeBackgroundRenderer); |
159 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ActivateTabResetPurgeState); | 169 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ActivateTabResetPurgeState); |
160 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ShouldPurgeAtDefaultTime); | 170 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ShouldPurgeAtDefaultTime); |
161 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DefaultTimeToPurgeInCorrectRange); | 171 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DefaultTimeToPurgeInCorrectRange); |
162 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); | 172 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable); |
163 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); | 173 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); |
164 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); | 174 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); |
165 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); | 175 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); |
166 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); | 176 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // associated Browser objects are crawled. The first of these is considered to | 369 // associated Browser objects are crawled. The first of these is considered to |
360 // be the 'active' tab strip model. | 370 // be the 'active' tab strip model. |
361 // TODO(chrisha): Factor out tab-strip model enumeration to a helper class, | 371 // TODO(chrisha): Factor out tab-strip model enumeration to a helper class, |
362 // and make a delegate that centralizes all testing seams. | 372 // and make a delegate that centralizes all testing seams. |
363 using TestTabStripModel = std::pair<const TabStripModel*, bool>; | 373 using TestTabStripModel = std::pair<const TabStripModel*, bool>; |
364 std::vector<TestTabStripModel> test_tab_strip_models_; | 374 std::vector<TestTabStripModel> test_tab_strip_models_; |
365 | 375 |
366 // List of observers that will receive notifications on state changes. | 376 // List of observers that will receive notifications on state changes. |
367 base::ObserverList<TabManagerObserver> observers_; | 377 base::ObserverList<TabManagerObserver> observers_; |
368 | 378 |
| 379 bool is_during_session_restore_; |
| 380 |
| 381 bool initial_active_tab_changed_; |
| 382 |
369 // Weak pointer factory used for posting delayed tasks. | 383 // Weak pointer factory used for posting delayed tasks. |
370 base::WeakPtrFactory<TabManager> weak_ptr_factory_; | 384 base::WeakPtrFactory<TabManager> weak_ptr_factory_; |
371 | 385 |
372 DISALLOW_COPY_AND_ASSIGN(TabManager); | 386 DISALLOW_COPY_AND_ASSIGN(TabManager); |
373 }; | 387 }; |
374 | 388 |
375 } // namespace resource_coordinator | 389 } // namespace resource_coordinator |
376 | 390 |
377 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ | 391 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_H_ |
OLD | NEW |