B2G/gecko/dom/system/gonk/net_worker.js
/**
 * Handle received data from netd.
 */
Handle received data from netd.
Handle received data from netd .
function onNetdMessage(data) {
  let result = "";
  let reason = "";
  let i = 0;
  while (i < data.length) {
    let octet = data[i];
    i += 1;
    if (octet == 32) {
      break;
    }
    result += String.fromCharCode(octet);
  }
  let code = parseInt(result);
  for (; i < data.length; i++) {
    let octet = data[i];
    reason += String.fromCharCode(octet);
  }
  debug("Receiving '" + gCurrentCommand + "' command response from netd.");
  debug("          ==> Code: " + code + "  Reason: " + reason);
  if (isComplete(code)) {
    gPending = false;
  }
  if (gCurrentCallback) {
    gCurrentCallback(isError(code), {code: code, reason: reason});
  }
  if (isComplete(code)) {
    nextNetdCommand();
  }
}
function onNetdMessage ( data ) { let result = "" ; let reason = "" ; let i = 0 ; while ( i < data . length ) { let octet = data [ i ] ; i += 1 ; if ( octet == 32 ) { break ; } result += String . fromCharCode ( octet ) ; } let code = parseInt ( result ) ; for ( ; i < data . length ; i ++ ) { let octet = data [ i ] ; reason += String . fromCharCode ( octet ) ; } debug ( "Receiving '" + gCurrentCommand + "' command response from netd." ) ; debug ( "          ==> Code: " + code + "  Reason: " + reason ) ; if ( isComplete ( code ) ) { gPending = false ; } if ( gCurrentCallback ) { gCurrentCallback ( isError ( code ) , { code : code , reason : reason } ) ; } if ( isComplete ( code ) ) { nextNetdCommand ( ) ; } }
Handle received data from netd.
Handle received data from netd .
// The return result is separated from the reason by a space character. // Set pending to false before we handle next command. // 1xx response code regards as command is proceeding, we need to wait for // final response code such as 2xx, 4xx and 5xx before sending next command. // Handling pending commands if any.