Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: chrome/browser/ui/tabs/tab_discard_state.h

Issue 1332003002: Add option to disallow the discarding of a tab that was previously discarded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky@ comments + fix tests. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698