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

Unified 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@ and rkaplow@ comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/tabs/tab_discard_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tabs/tab_discard_state.h
diff --git a/chrome/browser/ui/tabs/tab_discard_state.h b/chrome/browser/ui/tabs/tab_discard_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..5bdd203f18cba30850b070f8cbafa12d5a4158af
--- /dev/null
+++ b/chrome/browser/ui/tabs/tab_discard_state.h
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_
+#define CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_
+
+#include "base/supports_user_data.h"
+
+namespace content {
+class WebContents;
+}
+
+// Manages the information about the discarding state of a tab. This data is
+// stored in WebContents.
+class TabDiscardState : public base::SupportsUserData::Data {
+ public:
+ // Returns the TabDiscardState associated with |web_contents|. It will create
+ // one if none exists.
+ static TabDiscardState* Get(content::WebContents* web_contents);
+
+ // Sets the TabDiscardState of a |web_contents|. The object referenced by
+ // |state| is now owned by |web_contents|
+ static void Set(content::WebContents* web_contents, TabDiscardState* state);
+
+ // Returns true if |web_contents| has been discarded to save memory.
+ static bool IsDiscarded(content::WebContents* web_contents);
+
+ // Sets/clears the discard state of |web_contents|.
+ static void SetDiscardState(content::WebContents* web_contents, bool state);
+
+ // Returns the number of times |web_contents| has been discarded.
+ static int DiscardCount(content::WebContents* web_contents);
+
+ // Increments the number of times |web_contents| has been discarded.
+ static void IncrementDiscardCount(content::WebContents* web_contents);
+
+ // Copies the discard state from |old_contents| to |new_contents|.
+ static void CopyState(content::WebContents* old_contents,
+ content::WebContents* new_contents);
+
+ TabDiscardState() : is_discarded_(false), discard_count_(0) {}
+
+ private:
+ // Is the tab currently discarded?
+ bool is_discarded_;
+
+ // Number of times the tab has been discarded.
+ int discard_count_;
+};
+
+#endif // CHROME_BROWSER_UI_TABS_TAB_DISCARD_STATE_H_
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/tabs/tab_discard_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698