| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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 CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_ |
| 6 #define CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_ |
| 7 |
| 8 #include "base/supports_user_data.h" |
| 9 |
| 10 namespace content { |
| 11 class WebContents; |
| 12 } |
| 13 |
| 14 // Manages the information about the discarding state of a tab. This data is |
| 15 // stored in WebContents. |
| 16 class TabDiscardState : public base::SupportsUserData::Data { |
| 17 public: |
| 18 // Returns the TabDiscardState associated with |web_contents|. It will create |
| 19 // one if none exists. |
| 20 static TabDiscardState* Get(content::WebContents* web_contents); |
| 21 |
| 22 // Sets the TabDiscardState of a |web_contents|. The object referenced by |
| 23 // |state| is now owned by |web_contents| |
| 24 static void Set(content::WebContents* web_contents, TabDiscardState* state); |
| 25 |
| 26 // Returns true if |web_contents| has been discarded to save memory. |
| 27 static bool IsDiscarded(content::WebContents* web_contents); |
| 28 |
| 29 // Sets/clears the discard state of |web_contents|. |
| 30 static void SetDiscardState(content::WebContents* web_contents, bool state); |
| 31 |
| 32 // Returns the number of times |web_contents| has been discarded. |
| 33 static int DiscardCount(content::WebContents* web_contents); |
| 34 |
| 35 // Increments the number of times |web_contents| has been discarded. |
| 36 static void IncrementDiscardCount(content::WebContents* web_contents); |
| 37 |
| 38 // Copies the discard state from |old_contents| to |new_contents|. |
| 39 static void CopyState(content::WebContents* old_contents, |
| 40 content::WebContents* new_contents); |
| 41 |
| 42 TabDiscardState() : is_discarded_(false), discard_count_(0) {} |
| 43 |
| 44 private: |
| 45 // Is the tab currently discarded? |
| 46 bool is_discarded_; |
| 47 |
| 48 // Number of times the tab has been discarded. |
| 49 int discard_count_; |
| 50 }; |
| 51 |
| 52 #endif // CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_ |
| OLD | NEW |