Bug 861264 - Add support for options argument for OS.File.read method. r=Yoric
authorYura Zenevich <yura.zenevich@gmail.com>
Sun, 14 Apr 2013 21:32:07 -0400
changeset 135520 7694941e13d8b0dc65e48ca596801a4f7d2264ed
parent 135519 fe71fc5d82674d31fe6f27f705aeb3ca5410a9aa
child 135521 a03f74d9250952268e15d2f5ca09b09e8e537510
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs861264
milestone23.0a1
Bug 861264 - Add support for options argument for OS.File.read method. r=Yoric
toolkit/components/osfile/osfile_async_front.jsm
toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
--- a/toolkit/components/osfile/osfile_async_front.jsm
+++ b/toolkit/components/osfile/osfile_async_front.jsm
@@ -544,23 +544,24 @@ File.makeDir = function makeDir(path, op
 };
 
 /**
  * Return the contents of a file
  *
  * @param {string} path The path to the file.
  * @param {number=} bytes Optionally, an upper bound to the number of bytes
  * to read.
+ * @param {JSON} options Additional options.
  *
  * @resolves {Uint8Array} A buffer holding the bytes
  * read from the file.
  */
-File.read = function read(path, bytes) {
+File.read = function read(path, bytes, options) {
   let promise = Scheduler.post("read",
-    [Type.path.toMsg(path), bytes], path);
+    [Type.path.toMsg(path), bytes, options], path);
   return promise.then(
     function onSuccess(data) {
       return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
     });
 };
 
 /**
  * Find outs if a file exists.
--- a/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
+++ b/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
@@ -884,17 +884,21 @@ let test_duration = maketest("duration",
     yield OS.File.copy(pathSource, copyFile, copyOptions);
     testOptions(copyOptions);
     yield OS.File.remove(copyFile);
 
     // Trying an operation where options are cloned.
     let pathDest = OS.Path.join(OS.Constants.Path.tmpDir,
       "osfile async test read writeAtomic.tmp");
     let tmpPath = pathDest + ".tmp";
-    let contents = yield OS.File.read(pathSource);
+    let readOptions = {
+      outExecutionDuration: null
+    };
+    let contents = yield OS.File.read(pathSource, undefined, readOptions);
+    testOptions(readOptions);
     // Options structure passed to a OS.File writeAtomic method.
     let writeAtomicOptions = {
       // This field should be first initialized with the actual
       // duration measurement then progressively incremented.
       outExecutionDuration: null,
       tmpPath: tmpPath
     };
     yield OS.File.writeAtomic(pathDest, contents, writeAtomicOptions);