Bug 912442 - Part 3: Remove m prefix from worker_buf.js and fix the tests. r=allstars.chh
authorEdgar Chen <echen@mozilla.com>
Fri, 06 Sep 2013 17:03:51 +0800
changeset 160076 d30b98249891db40f667fc9c39b87c41052363fa
parent 160075 bec7d3a9ad7ca2145907b9735573671ee787593e
child 160077 dac3d1df51cfaa87a8186073742f34229484639f
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars
bugs912442
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 912442 - Part 3: Remove m prefix from worker_buf.js and fix the tests. r=allstars.chh
dom/system/gonk/ril_worker.js
dom/system/gonk/tests/test_ril_worker_buf.js
dom/system/gonk/worker_buf.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -145,33 +145,33 @@ let Buf = {
     } else if (response_type == RESPONSE_TYPE_UNSOLICITED) {
       request_type = this.readUint32();
       if (DEBUG) debug("Unsolicited response for request type " + request_type);
     } else {
       if (DEBUG) debug("Unknown response type: " + response_type);
       return;
     }
 
-    RIL.handleParcel(request_type, this.mReadAvailable, options);
+    RIL.handleParcel(request_type, this.readAvailable, options);
   },
 
   /**
    * Start a new outgoing parcel.
    *
    * @param type
    *        Integer specifying the request type.
    * @param options [optional]
    *        Object containing information about the request, e.g. the
    *        original main thread message object that led to the RIL request.
    */
   newParcel: function newParcel(type, options) {
     if (DEBUG) debug("New outgoing parcel of type " + type);
 
     // We're going to leave room for the parcel size at the beginning.
-    this.mOutgoingIndex = this.PARCEL_SIZE_SIZE;
+    this.outgoingIndex = this.PARCEL_SIZE_SIZE;
     this.writeUint32(type);
     this.writeUint32(this.mToken);
 
     if (!options) {
       options = {};
     }
     options.rilRequestType = type;
     options.rilRequestError = null;
--- a/dom/system/gonk/tests/test_ril_worker_buf.js
+++ b/dom/system/gonk/tests/test_ril_worker_buf.js
@@ -27,17 +27,18 @@ function add_test_incoming_parcel(parcel
     if (!parcel) {
       parcel = newIncomingParcel(-1,
                                  worker.RESPONSE_TYPE_UNSOLICITED,
                                  worker.REQUEST_VOICE_REGISTRATION_STATE,
                                  [0, 0, 0, 0]);
     }
 
     // supports only requests less or equal than UINT8_MAX(255).
-    let request = parcel[worker.PARCEL_SIZE_SIZE + worker.UINT32_SIZE];
+    let buf = worker.Buf;
+    let request = parcel[buf.PARCEL_SIZE_SIZE + worker.UINT32_SIZE];
     worker.RIL[request] = function ril_request_handler() {
       handler(worker);
       worker.postMessage();
     };
 
     worker.onRILMessage(parcel);
 
     // end of incoming parcel's trip, let's do next test.
@@ -106,40 +107,40 @@ add_test(function test_incoming_parcel_b
   }
 
   // Do nothing in handleParcel().
   let request = worker.REQUEST_VOICE_REGISTRATION_STATE;
   worker.RIL[request] = null;
 
   // Prepare two parcels, whose sizes are both smaller than the incoming buffer
   // size but larger when combined, to trigger the bug.
-  let pA_dataLength = buf.INCOMING_BUFFER_LENGTH / 2;
+  let pA_dataLength = buf.incomingBufferLength / 2;
   let pA = newIncomingParcel(-1,
                              worker.RESPONSE_TYPE_UNSOLICITED,
                              request,
                              calloc(pA_dataLength, 1));
-  let pA_parcelSize = pA.length - worker.PARCEL_SIZE_SIZE;
+  let pA_parcelSize = pA.length - buf.PARCEL_SIZE_SIZE;
 
-  let pB_dataLength = buf.INCOMING_BUFFER_LENGTH * 3 / 4;
+  let pB_dataLength = buf.incomingBufferLength * 3 / 4;
   let pB = newIncomingParcel(-1,
                              worker.RESPONSE_TYPE_UNSOLICITED,
                              request,
                              calloc(pB_dataLength, 1));
-  let pB_parcelSize = pB.length - worker.PARCEL_SIZE_SIZE;
+  let pB_parcelSize = pB.length - buf.PARCEL_SIZE_SIZE;
 
   // First, send an incomplete pA and verifies related data pointer:
   let p1 = pA.subarray(0, pA.length - 1);
   worker.onRILMessage(p1);
   // The parcel should not have been processed.
   do_check_eq(buf.readAvailable, 0);
   // buf.currentParcelSize should have been set because incoming data has more
   // than 4 octets.
   do_check_eq(buf.currentParcelSize, pA_parcelSize);
   // buf.readIncoming should contains remaining unconsumed octets count.
-  do_check_eq(buf.readIncoming, p1.length - worker.PARCEL_SIZE_SIZE);
+  do_check_eq(buf.readIncoming, p1.length - buf.PARCEL_SIZE_SIZE);
   // buf.incomingWriteIndex should be ready to accept the last octet.
   do_check_eq(buf.incomingWriteIndex, p1.length);
 
   // Second, send the last octet of pA and whole pB. The Buf should now expand
   // to cover both pA & pB.
   let p2 = new Uint8Array(1 + pB.length);
   p2.set(pA.subarray(pA.length - 1), 0);
   p2.set(pB, 1);
--- a/dom/system/gonk/worker_buf.js
+++ b/dom/system/gonk/worker_buf.js
@@ -18,247 +18,247 @@ const UINT32_SIZE = 4;
  *
  * The outgoing buffer is to prepare outgoing parcels. The index is reset
  * every time a parcel is sent.
  */
 
 let Buf = {
   PARCEL_SIZE_SIZE: UINT32_SIZE,
 
-  mIncomingBufferLength: 1024,
-  mIncomingBuffer: null,
-  mIncomingBytes: null,
-  mIncomingWriteIndex: 0,
-  mIncomingReadIndex: 0,
-  mReadIncoming: 0,
-  mReadAvailable: 0,
-  mCurrentParcelSize: 0,
+  incomingBufferLength: 1024,
+  incomingBuffer: null,
+  incomingBytes: null,
+  incomingWriteIndex: 0,
+  incomingReadIndex: 0,
+  readIncoming: 0,
+  readAvailable: 0,
+  currentParcelSize: 0,
 
-  mOutgoingBufferLength: 1024,
-  mOutgoingBuffer: null,
-  mOutgoingBytes: null,
-  mOutgoingIndex: 0,
-  mOutgoingBufferCalSizeQueue: null,
+  outgoingBufferLength: 1024,
+  outgoingBuffer: null,
+  outgoingBytes: null,
+  outgoingIndex: 0,
+  outgoingBufferCalSizeQueue: null,
 
   _init: function _init() {
-    this.mIncomingBuffer = new ArrayBuffer(this.mIncomingBufferLength);
-    this.mOutgoingBuffer = new ArrayBuffer(this.mOutgoingBufferLength);
+    this.incomingBuffer = new ArrayBuffer(this.incomingBufferLength);
+    this.outgoingBuffer = new ArrayBuffer(this.outgoingBufferLength);
 
-    this.mIncomingBytes = new Uint8Array(this.mIncomingBuffer);
-    this.mOutgoingBytes = new Uint8Array(this.mOutgoingBuffer);
+    this.incomingBytes = new Uint8Array(this.incomingBuffer);
+    this.outgoingBytes = new Uint8Array(this.outgoingBuffer);
 
     // Track where incoming data is read from and written to.
-    this.mIncomingWriteIndex = 0;
-    this.mIncomingReadIndex = 0;
+    this.incomingWriteIndex = 0;
+    this.incomingReadIndex = 0;
 
     // Leave room for the parcel size for outgoing parcels.
-    this.mOutgoingIndex = this.PARCEL_SIZE_SIZE;
+    this.outgoingIndex = this.PARCEL_SIZE_SIZE;
 
     // How many bytes we've read for this parcel so far.
-    this.mReadIncoming = 0;
+    this.readIncoming = 0;
 
     // How many bytes available as parcel data.
-    this.mReadAvailable = 0;
+    this.readAvailable = 0;
 
     // Size of the incoming parcel. If this is zero, we're expecting a new
     // parcel.
-    this.mCurrentParcelSize = 0;
+    this.currentParcelSize = 0;
 
     // Queue for storing outgoing override points
-    this.mOutgoingBufferCalSizeQueue = [];
+    this.outgoingBufferCalSizeQueue = [];
   },
 
   /**
-   * Mark current mOutgoingIndex as start point for calculation length of data
-   * written to mOutgoingBuffer.
+   * Mark current outgoingIndex as start point for calculation length of data
+   * written to outgoingBuffer.
    * Mark can be nested for here uses queue to remember marks.
    *
    * @param writeFunction
-   *        Function to write data length into mOutgoingBuffer, this function is
+   *        Function to write data length into outgoingBuffer, this function is
    *        also used to allocate buffer for data length.
    *        Raw data size(in Uint8) is provided as parameter calling writeFunction.
    *        If raw data size is not in proper unit for writing, user can adjust
    *        the length value in writeFunction before writing.
    **/
   startCalOutgoingSize: function startCalOutgoingSize(writeFunction) {
-    let sizeInfo = {index: this.mOutgoingIndex,
+    let sizeInfo = {index: this.outgoingIndex,
                     write: writeFunction};
 
     // Allocate buffer for data lemgtj.
     writeFunction.call(0);
 
     // Get size of data length buffer for it is not counted into data size.
-    sizeInfo.size = this.mOutgoingIndex - sizeInfo.index;
+    sizeInfo.size = this.outgoingIndex - sizeInfo.index;
 
     // Enqueue size calculation information.
-    this.mOutgoingBufferCalSizeQueue.push(sizeInfo);
+    this.outgoingBufferCalSizeQueue.push(sizeInfo);
   },
 
   /**
    * Calculate data length since last mark, and write it into mark position.
    **/
   stopCalOutgoingSize: function stopCalOutgoingSize() {
-    let sizeInfo = this.mOutgoingBufferCalSizeQueue.pop();
+    let sizeInfo = this.outgoingBufferCalSizeQueue.pop();
 
-    // Remember current mOutgoingIndex.
-    let currentOutgoingIndex = this.mOutgoingIndex;
+    // Remember current outgoingIndex.
+    let currentOutgoingIndex = this.outgoingIndex;
     // Calculate data length, in uint8.
-    let writeSize = this.mOutgoingIndex - sizeInfo.index - sizeInfo.size;
+    let writeSize = this.outgoingIndex - sizeInfo.index - sizeInfo.size;
 
     // Write data length to mark, use same function for allocating buffer to make
     // sure there is no buffer overloading.
-    this.mOutgoingIndex = sizeInfo.index;
+    this.outgoingIndex = sizeInfo.index;
     sizeInfo.write(writeSize);
 
-    // Restore mOutgoingIndex.
-    this.mOutgoingIndex = currentOutgoingIndex;
+    // Restore outgoingIndex.
+    this.outgoingIndex = currentOutgoingIndex;
   },
 
   /**
    * Grow the incoming buffer.
    *
    * @param min_size
    *        Minimum new size. The actual new size will be the the smallest
    *        power of 2 that's larger than this number.
    */
   growIncomingBuffer: function growIncomingBuffer(min_size) {
     if (DEBUG) {
-      debug("Current buffer of " + this.mIncomingBufferLength +
+      debug("Current buffer of " + this.incomingBufferLength +
             " can't handle incoming " + min_size + " bytes.");
     }
-    let oldBytes = this.mIncomingBytes;
-    this.mIncomingBufferLength =
+    let oldBytes = this.incomingBytes;
+    this.incomingBufferLength =
       2 << Math.floor(Math.log(min_size)/Math.log(2));
-    if (DEBUG) debug("New incoming buffer size: " + this.mIncomingBufferLength);
-    this.mIncomingBuffer = new ArrayBuffer(this.mIncomingBufferLength);
-    this.mIncomingBytes = new Uint8Array(this.mIncomingBuffer);
-    if (this.mIncomingReadIndex <= this.mIncomingWriteIndex) {
+    if (DEBUG) debug("New incoming buffer size: " + this.incomingBufferLength);
+    this.incomingBuffer = new ArrayBuffer(this.incomingBufferLength);
+    this.incomingBytes = new Uint8Array(this.incomingBuffer);
+    if (this.incomingReadIndex <= this.incomingWriteIndex) {
       // Read and write index are in natural order, so we can just copy
       // the old buffer over to the bigger one without having to worry
       // about the indexes.
-      this.mIncomingBytes.set(oldBytes, 0);
+      this.incomingBytes.set(oldBytes, 0);
     } else {
       // The write index has wrapped around but the read index hasn't yet.
       // Write whatever the read index has left to read until it would
       // circle around to the beginning of the new buffer, and the rest
       // behind that.
-      let head = oldBytes.subarray(this.mIncomingReadIndex);
-      let tail = oldBytes.subarray(0, this.mIncomingReadIndex);
-      this.mIncomingBytes.set(head, 0);
-      this.mIncomingBytes.set(tail, head.length);
-      this.mIncomingReadIndex = 0;
-      this.mIncomingWriteIndex += head.length;
+      let head = oldBytes.subarray(this.incomingReadIndex);
+      let tail = oldBytes.subarray(0, this.incomingReadIndex);
+      this.incomingBytes.set(head, 0);
+      this.incomingBytes.set(tail, head.length);
+      this.incomingReadIndex = 0;
+      this.incomingWriteIndex += head.length;
     }
     if (DEBUG) {
-      debug("New incoming buffer size is " + this.mIncomingBufferLength);
+      debug("New incoming buffer size is " + this.incomingBufferLength);
     }
   },
 
   /**
    * Grow the outgoing buffer.
    *
    * @param min_size
    *        Minimum new size. The actual new size will be the the smallest
    *        power of 2 that's larger than this number.
    */
   growOutgoingBuffer: function growOutgoingBuffer(min_size) {
     if (DEBUG) {
-      debug("Current buffer of " + this.mOutgoingBufferLength +
+      debug("Current buffer of " + this.outgoingBufferLength +
             " is too small.");
     }
-    let oldBytes = this.mOutgoingBytes;
-    this.mOutgoingBufferLength =
+    let oldBytes = this.outgoingBytes;
+    this.outgoingBufferLength =
       2 << Math.floor(Math.log(min_size)/Math.log(2));
-    this.mOutgoingBuffer = new ArrayBuffer(this.mOutgoingBufferLength);
-    this.mOutgoingBytes = new Uint8Array(this.mOutgoingBuffer);
-    this.mOutgoingBytes.set(oldBytes, 0);
+    this.outgoingBuffer = new ArrayBuffer(this.outgoingBufferLength);
+    this.outgoingBytes = new Uint8Array(this.outgoingBuffer);
+    this.outgoingBytes.set(oldBytes, 0);
     if (DEBUG) {
-      debug("New outgoing buffer size is " + this.mOutgoingBufferLength);
+      debug("New outgoing buffer size is " + this.outgoingBufferLength);
     }
   },
 
   /**
    * Functions for reading data from the incoming buffer.
    *
    * These are all little endian, apart from readParcelSize();
    */
 
   /**
    * Ensure position specified is readable.
    *
    * @param index
    *        Data position in incoming parcel, valid from 0 to
-   *        mCurrentParcelSize.
+   *        currentParcelSize.
    */
   ensureIncomingAvailable: function ensureIncomingAvailable(index) {
-    if (index >= this.mCurrentParcelSize) {
+    if (index >= this.currentParcelSize) {
       throw new Error("Trying to read data beyond the parcel end!");
     } else if (index < 0) {
       throw new Error("Trying to read data before the parcel begin!");
     }
   },
 
   /**
    * Seek in current incoming parcel.
    *
    * @param offset
    *        Seek offset in relative to current position.
    */
   seekIncoming: function seekIncoming(offset) {
-    // Translate to 0..mCurrentParcelSize
-    let cur = this.mCurrentParcelSize - this.mReadAvailable;
+    // Translate to 0..currentParcelSize
+    let cur = this.currentParcelSize - this.readAvailable;
 
     let newIndex = cur + offset;
     this.ensureIncomingAvailable(newIndex);
 
-    // ... mIncomingReadIndex -->|
-    // 0               new     cur           mCurrentParcelSize
+    // ... incomingReadIndex -->|
+    // 0               new     cur           currentParcelSize
     // |================|=======|====================|
-    // |<--        cur       -->|<- mReadAvailable ->|
-    // |<-- newIndex -->|<--  new mReadAvailable  -->|
-    this.mReadAvailable = this.mCurrentParcelSize - newIndex;
+    // |<--        cur       -->|<- readAvailable ->|
+    // |<-- newIndex -->|<--  new readAvailable  -->|
+    this.readAvailable = this.currentParcelSize - newIndex;
 
     // Translate back:
-    if (this.mIncomingReadIndex < cur) {
-      // The mIncomingReadIndex is wrapped.
-      newIndex += this.mIncomingBufferLength;
+    if (this.incomingReadIndex < cur) {
+      // The incomingReadIndex is wrapped.
+      newIndex += this.incomingBufferLength;
     }
-    newIndex += (this.mIncomingReadIndex - cur);
-    newIndex %= this.mIncomingBufferLength;
-    this.mIncomingReadIndex = newIndex;
+    newIndex += (this.incomingReadIndex - cur);
+    newIndex %= this.incomingBufferLength;
+    this.incomingReadIndex = newIndex;
   },
 
   readUint8Unchecked: function readUint8Unchecked() {
-    let value = this.mIncomingBytes[this.mIncomingReadIndex];
-    this.mIncomingReadIndex = (this.mIncomingReadIndex + 1) %
-                             this.mIncomingBufferLength;
+    let value = this.incomingBytes[this.incomingReadIndex];
+    this.incomingReadIndex = (this.incomingReadIndex + 1) %
+                             this.incomingBufferLength;
     return value;
   },
 
   readUint8: function readUint8() {
-    // Translate to 0..mCurrentParcelSize
-    let cur = this.mCurrentParcelSize - this.mReadAvailable;
+    // Translate to 0..currentParcelSize
+    let cur = this.currentParcelSize - this.readAvailable;
     this.ensureIncomingAvailable(cur);
 
-    this.mReadAvailable--;
+    this.readAvailable--;
     return this.readUint8Unchecked();
   },
 
   readUint8Array: function readUint8Array(length) {
-    // Translate to 0..mCurrentParcelSize
-    let last = this.mCurrentParcelSize - this.mReadAvailable;
+    // Translate to 0..currentParcelSize
+    let last = this.currentParcelSize - this.readAvailable;
     last += (length - 1);
     this.ensureIncomingAvailable(last);
 
     let array = new Uint8Array(length);
     for (let i = 0; i < length; i++) {
       array[i] = this.readUint8Unchecked();
     }
 
-    this.mReadAvailable -= length;
+    this.readAvailable -= length;
     return array;
   },
 
   readUint16: function readUint16() {
     return this.readUint8() | this.readUint8() << 8;
   },
 
   readUint32: function readUint32() {
@@ -323,29 +323,29 @@ let Buf = {
    * Functions for writing data to the outgoing buffer.
    */
 
   /**
    * Ensure position specified is writable.
    *
    * @param index
    *        Data position in outgoing parcel, valid from 0 to
-   *        mOutgoingBufferLength.
+   *        outgoingBufferLength.
    */
   ensureOutgoingAvailable: function ensureOutgoingAvailable(index) {
-    if (index >= this.mOutgoingBufferLength) {
+    if (index >= this.outgoingBufferLength) {
       this.growOutgoingBuffer(index + 1);
     }
   },
 
   writeUint8: function writeUint8(value) {
-    this.ensureOutgoingAvailable(this.mOutgoingIndex);
+    this.ensureOutgoingAvailable(this.outgoingIndex);
 
-    this.mOutgoingBytes[this.mOutgoingIndex] = value;
-    this.mOutgoingIndex++;
+    this.outgoingBytes[this.outgoingIndex] = value;
+    this.outgoingIndex++;
   },
 
   writeUint16: function writeUint16(value) {
     this.writeUint8(value & 0xff);
     this.writeUint8((value >> 8) & 0xff);
   },
 
   writeUint32: function writeUint32(value) {
@@ -385,61 +385,61 @@ let Buf = {
   },
 
   writeParcelSize: function writeParcelSize(value) {
     /**
      *  Parcel size will always be the first thing in the parcel byte
      *  array, but the last thing written. Store the current index off
      *  to a temporary to be reset after we write the size.
      */
-    let currentIndex = this.mOutgoingIndex;
-    this.mOutgoingIndex = 0;
+    let currentIndex = this.outgoingIndex;
+    this.outgoingIndex = 0;
     this.writeUint8((value >> 24) & 0xff);
     this.writeUint8((value >> 16) & 0xff);
     this.writeUint8((value >> 8) & 0xff);
     this.writeUint8(value & 0xff);
-    this.mOutgoingIndex = currentIndex;
+    this.outgoingIndex = currentIndex;
   },
 
   copyIncomingToOutgoing: function copyIncomingToOutgoing(length) {
     if (!length || (length < 0)) {
       return;
     }
 
     let translatedReadIndexEnd =
-      this.mCurrentParcelSize - this.mReadAvailable + length - 1;
+      this.currentParcelSize - this.readAvailable + length - 1;
     this.ensureIncomingAvailable(translatedReadIndexEnd);
 
-    let translatedWriteIndexEnd = this.mOutgoingIndex + length - 1;
+    let translatedWriteIndexEnd = this.outgoingIndex + length - 1;
     this.ensureOutgoingAvailable(translatedWriteIndexEnd);
 
-    let newIncomingReadIndex = this.mIncomingReadIndex + length;
-    if (newIncomingReadIndex < this.mIncomingBufferLength) {
+    let newIncomingReadIndex = this.incomingReadIndex + length;
+    if (newIncomingReadIndex < this.incomingBufferLength) {
       // Reading won't cause wrapping, go ahead with builtin copy.
-      this.mOutgoingBytes
-          .set(this.mIncomingBytes.subarray(this.mIncomingReadIndex,
-                                            newIncomingReadIndex),
-               this.mOutgoingIndex);
+      this.outgoingBytes
+          .set(this.incomingBytes.subarray(this.incomingReadIndex,
+                                           newIncomingReadIndex),
+               this.outgoingIndex);
     } else {
       // Not so lucky.
-      newIncomingReadIndex %= this.mIncomingBufferLength;
-      this.mOutgoingBytes
-          .set(this.mIncomingBytes.subarray(this.mIncomingReadIndex,
-                                            this.mIncomingBufferLength),
-               this.mOutgoingIndex);
+      newIncomingReadIndex %= this.incomingBufferLength;
+      this.outgoingBytes
+          .set(this.incomingBytes.subarray(this.incomingReadIndex,
+                                           this.incomingBufferLength),
+               this.outgoingIndex);
       if (newIncomingReadIndex) {
-        let firstPartLength = this.mIncomingBufferLength - this.mIncomingReadIndex;
-        this.mOutgoingBytes.set(this.mIncomingBytes.subarray(0, newIncomingReadIndex),
-                               this.mOutgoingIndex + firstPartLength);
+        let firstPartLength = this.incomingBufferLength - this.incomingReadIndex;
+        this.outgoingBytes.set(this.incomingBytes.subarray(0, newIncomingReadIndex),
+                               this.outgoingIndex + firstPartLength);
       }
     }
 
-    this.mIncomingReadIndex = newIncomingReadIndex;
-    this.mReadAvailable -= length;
-    this.mOutgoingIndex += length;
+    this.incomingReadIndex = newIncomingReadIndex;
+    this.readAvailable -= length;
+    this.outgoingIndex += length;
   },
 
   /**
    * Parcel management
    */
 
   /**
    * Write incoming data to the circular buffer.
@@ -447,140 +447,140 @@ let Buf = {
    * @param incoming
    *        Uint8Array containing the incoming data.
    */
   writeToIncoming: function writeToIncoming(incoming) {
     // We don't have to worry about the head catching the tail since
     // we process any backlog in parcels immediately, before writing
     // new data to the buffer. So the only edge case we need to handle
     // is when the incoming data is larger than the buffer size.
-    let minMustAvailableSize = incoming.length + this.mReadIncoming;
-    if (minMustAvailableSize > this.mIncomingBufferLength) {
+    let minMustAvailableSize = incoming.length + this.readIncoming;
+    if (minMustAvailableSize > this.incomingBufferLength) {
       this.growIncomingBuffer(minMustAvailableSize);
     }
 
     // We can let the typed arrays do the copying if the incoming data won't
     // wrap around the edges of the circular buffer.
-    let remaining = this.mIncomingBufferLength - this.mIncomingWriteIndex;
+    let remaining = this.incomingBufferLength - this.incomingWriteIndex;
     if (remaining >= incoming.length) {
-      this.mIncomingBytes.set(incoming, this.mIncomingWriteIndex);
+      this.incomingBytes.set(incoming, this.incomingWriteIndex);
     } else {
       // The incoming data would wrap around it.
       let head = incoming.subarray(0, remaining);
       let tail = incoming.subarray(remaining);
-      this.mIncomingBytes.set(head, this.mIncomingWriteIndex);
-      this.mIncomingBytes.set(tail, 0);
+      this.incomingBytes.set(head, this.incomingWriteIndex);
+      this.incomingBytes.set(tail, 0);
     }
-    this.mIncomingWriteIndex = (this.mIncomingWriteIndex + incoming.length) %
-                               this.mIncomingBufferLength;
+    this.incomingWriteIndex = (this.incomingWriteIndex + incoming.length) %
+                               this.incomingBufferLength;
   },
 
   /**
    * Process incoming data.
    *
    * @param incoming
    *        Uint8Array containing the incoming data.
    */
   processIncoming: function processIncoming(incoming) {
     if (DEBUG) {
       debug("Received " + incoming.length + " bytes.");
-      debug("Already read " + this.mReadIncoming);
+      debug("Already read " + this.readIncoming);
     }
 
     this.writeToIncoming(incoming);
-    this.mReadIncoming += incoming.length;
+    this.readIncoming += incoming.length;
     while (true) {
-      if (!this.mCurrentParcelSize) {
+      if (!this.currentParcelSize) {
         // We're expecting a new parcel.
-        if (this.mReadIncoming < this.PARCEL_SIZE_SIZE) {
+        if (this.readIncoming < this.PARCEL_SIZE_SIZE) {
           // We don't know how big the next parcel is going to be, need more
           // data.
           if (DEBUG) debug("Next parcel size unknown, going to sleep.");
           return;
         }
-        this.mCurrentParcelSize = this.readParcelSize();
+        this.currentParcelSize = this.readParcelSize();
         if (DEBUG) {
-          debug("New incoming parcel of size " + this.mCurrentParcelSize);
+          debug("New incoming parcel of size " + this.currentParcelSize);
         }
         // The size itself is not included in the size.
-        this.mReadIncoming -= this.PARCEL_SIZE_SIZE;
+        this.readIncoming -= this.PARCEL_SIZE_SIZE;
       }
 
-      if (this.mReadIncoming < this.mCurrentParcelSize) {
+      if (this.readIncoming < this.currentParcelSize) {
         // We haven't read enough yet in order to be able to process a parcel.
-        if (DEBUG) debug("Read " + this.mReadIncoming + ", but parcel size is "
-                         + this.mCurrentParcelSize + ". Going to sleep.");
+        if (DEBUG) debug("Read " + this.readIncoming + ", but parcel size is "
+                         + this.currentParcelSize + ". Going to sleep.");
         return;
       }
 
       // Alright, we have enough data to process at least one whole parcel.
       // Let's do that.
-      let expectedAfterIndex = (this.mIncomingReadIndex + this.mCurrentParcelSize)
-                               % this.mIncomingBufferLength;
+      let expectedAfterIndex = (this.incomingReadIndex + this.currentParcelSize)
+                               % this.incomingBufferLength;
 
       if (DEBUG) {
         let parcel;
-        if (expectedAfterIndex < this.mIncomingReadIndex) {
-          let head = this.mIncomingBytes.subarray(this.mIncomingReadIndex);
-          let tail = this.mIncomingBytes.subarray(0, expectedAfterIndex);
+        if (expectedAfterIndex < this.incomingReadIndex) {
+          let head = this.incomingBytes.subarray(this.incomingReadIndex);
+          let tail = this.incomingBytes.subarray(0, expectedAfterIndex);
           parcel = Array.slice(head).concat(Array.slice(tail));
         } else {
-          parcel = Array.slice(this.mIncomingBytes.subarray(
-            this.mIncomingReadIndex, expectedAfterIndex));
+          parcel = Array.slice(this.incomingBytes.subarray(
+            this.incomingReadIndex, expectedAfterIndex));
         }
-        debug("Parcel (size " + this.mCurrentParcelSize + "): " + parcel);
+        debug("Parcel (size " + this.currentParcelSize + "): " + parcel);
       }
 
       if (DEBUG) debug("We have at least one complete parcel.");
       try {
-        this.mReadAvailable = this.mCurrentParcelSize;
+        this.readAvailable = this.currentParcelSize;
         this.processParcel();
       } catch (ex) {
         if (DEBUG) debug("Parcel handling threw " + ex + "\n" + ex.stack);
       }
 
       // Ensure that the whole parcel was consumed.
-      if (this.mIncomingReadIndex != expectedAfterIndex) {
+      if (this.incomingReadIndex != expectedAfterIndex) {
         if (DEBUG) {
           debug("Parcel handler didn't consume whole parcel, " +
-                Math.abs(expectedAfterIndex - this.mIncomingReadIndex) +
+                Math.abs(expectedAfterIndex - this.incomingReadIndex) +
                 " bytes left over");
         }
-        this.mIncomingReadIndex = expectedAfterIndex;
+        this.incomingReadIndex = expectedAfterIndex;
       }
-      this.mReadIncoming -= this.mCurrentParcelSize;
-      this.mReadAvailable = 0;
-      this.mCurrentParcelSize = 0;
+      this.readIncoming -= this.currentParcelSize;
+      this.readAvailable = 0;
+      this.currentParcelSize = 0;
     }
   },
 
   /**
    * Communicate with the IPC thread.
    */
   sendParcel: function sendParcel() {
     // Compute the size of the parcel and write it to the front of the parcel
     // where we left room for it. Note that he parcel size does not include
     // the size itself.
-    let parcelSize = this.mOutgoingIndex - this.PARCEL_SIZE_SIZE;
+    let parcelSize = this.outgoingIndex - this.PARCEL_SIZE_SIZE;
     this.writeParcelSize(parcelSize);
 
     // This assumes that postRILMessage will make a copy of the ArrayBufferView
     // right away!
-    let parcel = this.mOutgoingBytes.subarray(0, this.mOutgoingIndex);
+    let parcel = this.outgoingBytes.subarray(0, this.outgoingIndex);
     if (DEBUG) debug("Outgoing parcel: " + Array.slice(parcel));
     this.onSendParcel(parcel);
-    this.mOutgoingIndex = this.PARCEL_SIZE_SIZE;
+    this.outgoingIndex = this.PARCEL_SIZE_SIZE;
   },
 
   getCurrentParcelSize: function getCurrentParcelSize() {
-    return this.mCurrentParcelSize;
+    return this.currentParcelSize;
   },
 
   getReadAvailable: function getReadAvailable() {
-    return this.mReadAvailable;
+    return this.readAvailable;
   }
 
   /**
    * Process one parcel.
    *
    * |processParcel| is an implementation provided incoming parcel processing
    * function invoked when we have received a complete parcel.  Implementation
    * may call multiple read functions to extract data from the incoming buffer.