B2G/gecko/dom/mobilemessage/src/ril/MmsService.js
/**
     * Send MMS request to MMSC.
     *
     * @param method
     *        "GET" or "POST".
     * @param url
     *        Target url string.
     * @param istream
     *        An nsIInputStream instance as data source to be sent or null.
     * @param callback
     *        A callback function that takes two arguments: one for http
     *        status, the other for wrapped PDU data for further parsing.
     */
Send MMS request to MMSC.
@param method
"GET" or "POST".
@param url
Target url string.
@param istream
An nsIInputStream instance as data source to be sent or null.
@param callback
A callback function that takes two arguments: one for http
status, the other for wrapped PDU data for further parsing.
Send MMS request to MMSC . @param method " GET " or " POST " . @param url Target url string . @param istream An nsIInputStream instance as data source to be sent or null . @param callback A callback function that takes two arguments : one for http status the other for wrapped PDU data for further parsing .
function sendRequest(method, url, istream, callback) {
      let cancellable = {
        callback: callback,
        isDone: false,
        isCancelled: false,
        cancel: function cancel() {
          if (this.isDone) {
            return;
          }
          this.isCancelled = true;
          if (this.isAcquiringConn) {
            this.done(_HTTP_STATUS_USER_CANCELLED, null);
          } else if (this.xhr) {
            this.xhr.abort();
          }
        },
        done: function done(httpStatus, data) {
          this.isDone = true;
          if (!this.callback) {
            return;
          }
          if (this.isCancelled) {
            this.callback(_HTTP_STATUS_USER_CANCELLED, null);
          } else {
            this.callback(httpStatus, data);
          }
        }
      };
      cancellable.isAcquiringConn =
        !gMmsConnection.acquire((function (connected) {
        cancellable.isAcquiringConn = false;
        if (!connected || cancellable.isCancelled) {
          gMmsConnection.release();
          if (!cancellable.isDone) {
            cancellable.done(cancellable.isCancelled ?
                             _HTTP_STATUS_USER_CANCELLED : 0, null);
          }
          return;
        }
        if (DEBUG) debug("sendRequest: register proxy filter to " + url);
        let proxyFilter = new MmsProxyFilter(url);
        gpps.registerFilter(proxyFilter, 0);
        cancellable.xhr = this.sendHttpRequest(method, url, istream, proxyFilter,
                                               cancellable.done.bind(cancellable));
      }).bind(this));
      return cancellable;
    }
function sendRequest ( method , url , istream , callback ) { let cancellable = { callback : callback , isDone : false , isCancelled : false , cancel : function cancel ( ) { if ( this . isDone ) { return ; } this . isCancelled = true ; if ( this . isAcquiringConn ) { this . done ( _HTTP_STATUS_USER_CANCELLED , null ) ; } else if ( this . xhr ) { this . xhr . abort ( ) ; } } , done : function done ( httpStatus , data ) { this . isDone = true ; if ( ! this . callback ) { return ; } if ( this . isCancelled ) { this . callback ( _HTTP_STATUS_USER_CANCELLED , null ) ; } else { this . callback ( httpStatus , data ) ; } } } ; cancellable . isAcquiringConn = ! gMmsConnection . acquire ( ( function ( connected ) { cancellable . isAcquiringConn = false ; if ( ! connected || cancellable . isCancelled ) { gMmsConnection . release ( ) ; if ( ! cancellable . isDone ) { cancellable . done ( cancellable . isCancelled ? _HTTP_STATUS_USER_CANCELLED : 0 , null ) ; } return ; } if ( DEBUG ) debug ( "sendRequest: register proxy filter to " + url ) ; let proxyFilter = new MmsProxyFilter ( url ) ; gpps . registerFilter ( proxyFilter , 0 ) ; cancellable . xhr = this . sendHttpRequest ( method , url , istream , proxyFilter , cancellable . done . bind ( cancellable ) ) ; } ) . bind ( this ) ) ; return cancellable ; }
Send MMS request to MMSC.
Send MMS request to MMSC .
// TODO: bug 810226 - Support GPRS bearer for MMS transmission and reception. // It's too late to cancel. // We cannot cancel data connection setup here, so we invoke done() // here and handle |cancellable.isDone| in callback function of // |gMmsConnection.acquire|. // Client has already sent the HTTP request. Try to abort it.