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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/FrozenNativePage.java

Issue 322253002: Allow "freezing" NativePages to spare up memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed assert false from updateForUrl() Created 6 years, 6 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/Tab.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/FrozenNativePage.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/FrozenNativePage.java b/chrome/android/java/src/org/chromium/chrome/browser/FrozenNativePage.java
new file mode 100644
index 0000000000000000000000000000000000000000..201718e4e1b6e74a1713bc7ff267e842548b678c
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/FrozenNativePage.java
@@ -0,0 +1,71 @@
+// Copyright 2014 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.
+
+package org.chromium.chrome.browser;
+
+import android.view.View;
+
+/**
+ * A empty stand-in for a native page. An inactive NativePage may be replaced with a
+ * FrozenNativePage to free up resources.
+ *
+ * Any method may be called on this object, except for getView(), which will trigger an assert and
+ * return null.
+ */
+public class FrozenNativePage implements NativePage {
+ private final String mUrl;
+ private final String mHost;
+ private final String mTitle;
+ private final int mBackgroundColor;
+
+ /**
+ * Creates a FrozenNativePage to replace the given NativePage and destroys the NativePage.
+ */
+ public static FrozenNativePage freeze(NativePage nativePage) {
+ FrozenNativePage fnp = new FrozenNativePage(nativePage);
+ nativePage.destroy();
+ return fnp;
+ }
+
+ private FrozenNativePage(NativePage nativePage) {
+ mHost = nativePage.getHost();
+ mUrl = nativePage.getUrl();
+ mTitle = nativePage.getTitle();
+ mBackgroundColor = nativePage.getBackgroundColor();
+ }
+
+ @Override
+ public View getView() {
+ assert false;
+ return null;
+ }
+
+ @Override
+ public String getTitle() {
+ return mTitle;
+ }
+
+ @Override
+ public String getUrl() {
+ return mUrl;
+ }
+
+ @Override
+ public String getHost() {
+ return mHost;
+ }
+
+ @Override
+ public int getBackgroundColor() {
+ return mBackgroundColor;
+ }
+
+ @Override
+ public void updateForUrl(String url) {
+ }
+
+ @Override
+ public void destroy() {
+ }
+}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/Tab.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698