Bug 634666 - Use DEFER_OPEN in m-b [r=mfinkle]
authorAlon Zakai <azakai@mozilla.com>
Fri, 04 Mar 2011 16:51:48 -0800
changeset 2872 a59a3d731222341d2c2b9b44315ac50feb546dd3
parent 2871 edd4fb92ff06e38b7eb6f169183967ea0040cf56
child 2873 62c013ee422ca330adfbcb74d2646c7e979768d4
push id2416
push userazakai@mozilla.com
push dateSat, 05 Mar 2011 00:52:38 +0000
reviewersmfinkle
bugs634666
Bug 634666 - Use DEFER_OPEN in m-b [r=mfinkle]
components/AddonUpdateService.js
components/AutoCompleteCache.js
components/SessionStore.js
--- a/components/AddonUpdateService.js
+++ b/components/AddonUpdateService.js
@@ -169,17 +169,17 @@ var RecommendedSearchResults = {
     if (!aData)
       return;
 
     let stateString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
     stateString.data = aData;
 
     // Initialize the file output stream.
     let ostream = Cc["@mozilla.org/network/safe-file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
-    ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, 0);
+    ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, ostream.DEFER_OPEN);
 
     // Obtain a converter to convert our data to a UTF-8 encoded input stream.
     let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
     converter.charset = "UTF-8";
 
     // Asynchronously copy the data to the file.
     let istream = converter.convertToInputStream(aData);
     NetUtil.asyncCopy(istream, ostream, function(rc) {
--- a/components/AutoCompleteCache.js
+++ b/components/AutoCompleteCache.js
@@ -174,17 +174,17 @@ var AutoCompleteUtils = {
 
     cache.result = copy;
 
     // Convert to json to save to disk..
     let ostream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
     let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
 
     try {
-      ostream.init(this.cacheFile, (MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE), PERMS_FILE, 0);
+      ostream.init(this.cacheFile, (MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE), PERMS_FILE, ostream.DEFER_OPEN);
       converter.charset = "UTF-8";
       let data = converter.convertToInputStream(JSON.stringify(cache));
 
       // Write to the cache file asynchronously
       NetUtil.asyncCopy(data, ostream, function(rv) {
         if (!Components.isSuccessCode(rv))
           Cu.reportError("AutoCompleteUtils: failure during asyncCopy: " + rv);
         else
--- a/components/SessionStore.js
+++ b/components/SessionStore.js
@@ -492,17 +492,17 @@ SessionStore.prototype = {
     Services.obs.notifyObservers(stateString, "sessionstore-state-write", "");
 
     // Don't touch the file if an observer has deleted all state data
     if (!stateString.data)
       return;
 
     // Initialize the file output stream.
     let ostream = Cc["@mozilla.org/network/safe-file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
-    ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, 0);
+    ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, ostream.DEFER_OPEN);
 
     // Obtain a converter to convert our data to a UTF-8 encoded input stream.
     let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
     converter.charset = "UTF-8";
 
     // Asynchronously copy the data to the file.
     let istream = converter.convertToInputStream(aData);
     NetUtil.asyncCopy(istream, ostream, function(rc) {