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

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

Issue 2138503002: Creating contents state byte array before opening stream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: renamed variables, added javadoc, updated AUTHORS Created 4 years, 5 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
Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersister.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersister.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersister.java
index 08c8a0a61e269baeb9f1094ba8d50a416848fec4..28bfe9fbafd9b214ac6d5083a7595b5148e54be8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersister.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersister.java
@@ -6,13 +6,9 @@ package org.chromium.chrome.browser.tabmodel;
import android.util.Log;
-import org.chromium.base.StreamUtil;
import org.chromium.chrome.browser.TabState;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
/**
* Interacts with the file system to persist Tab and TabModel data.
@@ -43,20 +39,12 @@ public abstract class TabPersister {
public boolean saveTabState(int tabId, boolean encrypted, TabState state) {
if (state == null) return false;
- FileOutputStream stream = null;
try {
- stream = openTabStateOutputStream(tabId, encrypted);
- TabState.saveState(stream, state, encrypted);
+ TabState.saveState(getTabStateFile(tabId, encrypted), state, encrypted);
return true;
- } catch (FileNotFoundException exception) {
- Log.w(TAG, "FileNotFoundException while attempt to TabState.");
- } catch (IOException exception) {
- Log.w(TAG, "IO Exception while attempting to save tab state.");
} catch (OutOfMemoryError e) {
Log.w(TAG, "Out of memory error while attempting to save tab state. Erasing.");
deleteTabState(tabId, encrypted);
- } finally {
- StreamUtil.closeQuietly(stream);
}
return false;
@@ -70,9 +58,4 @@ public abstract class TabPersister {
public void deleteTabState(int id, boolean encrypted) {
TabState.deleteTabState(getStateDirectory(), id, encrypted);
}
-
- protected FileOutputStream openTabStateOutputStream(int id, boolean encrypted)
- throws IOException {
- return new FileOutputStream(getTabStateFile(id, encrypted));
- }
}

Powered by Google App Engine
This is Rietveld 408576698