B2G/gecko/browser/modules/NewTabUtils.jsm
/**
   * Gets the current set of links delivered by this provider.
   * @param aCallback The function that the array of links is passed to.
   */
Gets the current set of links delivered by this provider.
@param aCallback The function that the array of links is passed to.
Gets the current set of links delivered by this provider . @param aCallback The function that the array of links is passed to .
function PlacesProvider_getLinks(aCallback) {
    let options = PlacesUtils.history.getNewQueryOptions();
    options.maxResults = HISTORY_RESULTS_LIMIT;
    options.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_FRECENCY_DESCENDING
    let links = [];
    let callback = {
      handleResult: function (aResultSet) {
        let row;
        while (row = aResultSet.getNextRow()) {
          let url = row.getResultByIndex(1);
          if (LinkChecker.checkLoadURI(url)) {
            let title = row.getResultByIndex(2);
            links.push({url: url, title: title});
          }
        }
      },
      handleError: function (aError) {
        aCallback([]);
      },
      handleCompletion: function (aReason) {
        aCallback(links);
      }
    };
    let query = PlacesUtils.history.getNewQuery();
    let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase);
    db.asyncExecuteLegacyQueries([query], 1, options, callback);
  }
function PlacesProvider_getLinks ( aCallback ) { let options = PlacesUtils . history . getNewQueryOptions ( ) ; options . maxResults = HISTORY_RESULTS_LIMIT ; options . sortingMode = Ci . nsINavHistoryQueryOptions . SORT_BY_FRECENCY_DESCENDING let links = [ ] ; let callback = { handleResult : function ( aResultSet ) { let row ; while ( row = aResultSet . getNextRow ( ) ) { let url = row . getResultByIndex ( 1 ) ; if ( LinkChecker . checkLoadURI ( url ) ) { let title = row . getResultByIndex ( 2 ) ; links . push ( { url : url , title : title } ) ; } } } , handleError : function ( aError ) { aCallback ( [ ] ) ; } , handleCompletion : function ( aReason ) { aCallback ( links ) ; } } ; let query = PlacesUtils . history . getNewQuery ( ) ; let db = PlacesUtils . history . QueryInterface ( Ci . nsPIPlacesDatabase ) ; db . asyncExecuteLegacyQueries ( [ query ] , 1 , options , callback ) ; }
Gets the current set of links delivered by this provider.
Gets the current set of links delivered by this provider .
// Sort by frecency, descending. // Should we somehow handle this error? // Execute the query.