/** Implement method of BookmarksInsertionManager.BookmarkInserter. */
  @Override
  public void bulkInsertNonFolders(Collection<BookmarkRecord> records) {
    // All of these records are *not* deleted and *not* folders, so we don't
    // need to update androidID at all!
    // TODO: persist records that fail to insert for later retry.
    ArrayList<Record> toStores = new ArrayList<Record>(records.size());
    for (Record record : records) {
      toStores.add(prepareRecord(record));
    }

    try {
      int stored = dataAccessor.bulkInsert(toStores);
      if (stored != toStores.size()) {
        // Something failed; most pessimistic action is to declare that all insertions failed.
        // TODO: perform the bulkInsert in a transaction and rollback unless all insertions succeed?
        for (Record failed : toStores) {
          delegate.onRecordStoreFailed(
              new RuntimeException(
                  "Possibly failed to bulkInsert non-folder with guid " + failed.guid + "."),
              failed.guid);
        }
        return;
      }
    } catch (NullCursorException e) {
      for (Record failed : toStores) {
        delegate.onRecordStoreFailed(e, failed.guid);
      }
      return;
    }

    // Success For All!
    for (Record succeeded : toStores) {
      try {
        updateBookkeeping(succeeded);
      } catch (Exception e) {
        Logger.warn(
            LOG_TAG,
            "Got exception updating bookkeeping of non-folder with guid " + succeeded.guid + ".",
            e);
      }
      trackRecord(succeeded);
      delegate.onRecordStoreSucceeded(succeeded.guid);
    }
  }