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.
5 #ifndef CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_
6 #define CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_
8 #include "base/supports_user_data.h"
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
{
18 // Returns the TabDiscardState associated with |web_contents|. It will create
19 // one if none exists.
20 static TabDiscardState
* Get(content::WebContents
* web_contents
);
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
);
26 // Returns true if |web_contents| has been discarded to save memory.
27 static bool IsDiscarded(content::WebContents
* web_contents
);
29 // Sets/clears the discard state of |web_contents|.
30 static void SetDiscardState(content::WebContents
* web_contents
, bool state
);
32 // Returns the number of times |web_contents| has been discarded.
33 static int DiscardCount(content::WebContents
* web_contents
);
35 // Increments the number of times |web_contents| has been discarded.
36 static void IncrementDiscardCount(content::WebContents
* web_contents
);
38 // Copies the discard state from |old_contents| to |new_contents|.
39 static void CopyState(content::WebContents
* old_contents
,
40 content::WebContents
* new_contents
);
42 TabDiscardState() : is_discarded_(false), discard_count_(0) {}
45 // Is the tab currently discarded?
48 // Number of times the tab has been discarded.
52 #endif // CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_