B2G/gecko/browser/components/places/tests/browser/head.js
/**
 * Waits for all pending async statements on the default connection, before
 * proceeding with aCallback.
 *
 * @param aCallback
 *        Function to be called when done.
 * @param aScope
 *        Scope for the callback.
 * @param aArguments
 *        Arguments array for the callback.
 *
 * @note The result is achieved by asynchronously executing a query requiring
 *       a write lock.  Since all statements on the same connection are
 *       serialized, the end of this write operation means that all writes are
 *       complete.  Note that WAL makes so that writers don't block readers, but
 *       this is a problem only across different connections.
 */
Waits for all pending async statements on the default connection, before
proceeding with aCallback.

@param aCallback
Function to be called when done.
@param aScope
Scope for the callback.
@param aArguments
Arguments array for the callback.

@note The result is achieved by asynchronously executing a query requiring
a write lock.  Since all statements on the same connection are
serialized, the end of this write operation means that all writes are
complete.  Note that WAL makes so that writers don't block readers, but
this is a problem only across different connections.
Waits for all pending async statements on the default connection before proceeding with aCallback . @param aCallback Function to be called when done . @param aScope Scope for the callback . @param aArguments Arguments array for the callback . @note The result is achieved by asynchronously executing a query requiring a write lock . Since all statements on the same connection are serialized the end of this write operation means that all writes are complete . Note that WAL makes so that writers don ' t block readers but this is a problem only across different connections .
function waitForAsyncUpdates(aCallback, aScope, aArguments)
{
  let scope = aScope || this;
  let args = aArguments || [];
  let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
                              .DBConnection;
  let begin = db.createAsyncStatement("BEGIN EXCLUSIVE");
  begin.executeAsync();
  begin.finalize();
  let commit = db.createAsyncStatement("COMMIT");
  commit.executeAsync({
    handleResult: function() {},
    handleError: function() {},
    handleCompletion: function(aReason)
    {
      aCallback.apply(scope, args);
    }
  });
  commit.finalize();
}
function waitForAsyncUpdates ( aCallback , aScope , aArguments ) { let scope = aScope || this ; let args = aArguments || [ ] ; let db = PlacesUtils . history . QueryInterface ( Ci . nsPIPlacesDatabase ) . DBConnection ; let begin = db . createAsyncStatement ( "BEGIN EXCLUSIVE" ) ; begin . executeAsync ( ) ; begin . finalize ( ) ; let commit = db . createAsyncStatement ( "COMMIT" ) ; commit . executeAsync ( { handleResult : function ( ) { } , handleError : function ( ) { } , handleCompletion : function ( aReason ) { aCallback . apply ( scope , args ) ; } } ) ; commit . finalize ( ) ; }
Waits for all pending async statements on the default connection, before
 proceeding with aCallback.
Waits for all pending async statements on the default connection before proceeding with aCallback .