コード例 #1
0
 /**
  * Subscribe to a USK. When it is updated, the content will be fetched (subject to the limits in
  * fctx), and returned to the callback. If we are asked to do a background fetch, we will only
  * fetch editions when we are fairly confident there are no more to fetch.
  *
  * @param origUSK The USK to poll.
  * @param cb Callback, called when we have downloaded a new key.
  * @param runBackgroundFetch If true, start a background fetcher for the key, which will run
  *     forever until we unsubscribe. Note that internally we use subscribeSparse() in this case,
  *     i.e. we will only download editions which we are confident about.
  * @param fctx Fetcher context for actually fetching the keys. Not used by the USK polling.
  * @param prio Priority for fetching the content (see constants in RequestScheduler).
  * @param sparse If true, only fetch once we're sure it's the latest edition.
  * @return
  */
 public USKRetriever subscribeContent(
     USK origUSK,
     USKRetrieverCallback cb,
     boolean runBackgroundFetch,
     FetchContext fctx,
     short prio,
     RequestClient client) {
   USKRetriever ret = new USKRetriever(fctx, prio, client, cb, origUSK);
   USKCallback toSub = ret;
   if (logMINOR) Logger.minor(this, "Subscribing to " + origUSK + " for " + cb);
   if (runBackgroundFetch) {
     USKSparseProxyCallback proxy = new USKSparseProxyCallback(ret, origUSK);
     ret.setProxy(proxy);
     toSub = proxy;
   }
   subscribe(origUSK, toSub, runBackgroundFetch, fctx.ignoreUSKDatehints, client);
   return ret;
 }
コード例 #2
0
 /**
  * Subscribe to a USK with a custom FetchContext. This is "off the books", i.e. the background
  * fetcher isn't started by subscribe().
  */
 public USKRetriever subscribeContentCustom(
     USK origUSK, USKRetrieverCallback cb, FetchContext fctx, short prio, RequestClient client) {
   USKRetriever ret = new USKRetriever(fctx, prio, client, cb, origUSK);
   USKCallback toSub = ret;
   if (logMINOR) Logger.minor(this, "Subscribing to " + origUSK + " for " + cb);
   USKSparseProxyCallback proxy = new USKSparseProxyCallback(ret, origUSK);
   ret.setProxy(proxy);
   toSub = proxy;
   /* runBackgroundFetch=false -> ignoreUSKDatehints unused */
   subscribe(origUSK, toSub, false, client);
   USKFetcher f =
       new USKFetcher(
           origUSK,
           this,
           fctx,
           new USKFetcherWrapper(origUSK, prio, client),
           3,
           true,
           false,
           false);
   ret.setFetcher(f);
   return ret;
 }
コード例 #3
0
 public void unsubscribeContent(USK origUSK, USKRetriever ret, boolean runBackgroundFetch) {
   ret.unsubscribe(this);
 }