WebContents takePrerenderedUrl(IBinder session,String url,String referrer){
  ThreadUtils.assertOnUiThread();
  if (mPrerender == null || session == null || !session.equals(mPrerender.mSession)) {
    return null;
  }
  WebContents webContents=mPrerender.mWebContents;
  String prerenderedUrl=mPrerender.mUrl;
  String prerenderReferrer=mPrerender.mReferrer;
  if (referrer == null)   referrer="";
  mPrerender=null;
  if (TextUtils.equals(prerenderedUrl,url) && TextUtils.equals(prerenderReferrer,referrer)) {
    return webContents;
  }
  mExternalPrerenderHandler.cancelCurrentPrerender();
  webContents.destroy();
  return null;
}

WebContents takePrerenderedUrl ( IBinder session , String url , String referrer ) { ThreadUtils . assertOnUiThread ( ) ; if ( mPrerender == null || session == null || ! session . equals ( mPrerender . mSession ) ) { return null ; } WebContents webContents = mPrerender . mWebContents ; String prerenderedUrl = mPrerender . mUrl ; String prerenderReferrer = mPrerender . mReferrer ; if ( referrer == null ) referrer = "" ; mPrerender = null ; if ( TextUtils . equals ( prerenderedUrl , url ) && TextUtils . equals ( prerenderReferrer , referrer ) ) { return webContents ; } mExternalPrerenderHandler . cancelCurrentPrerender ( ) ; webContents . destroy ( ) ; return null ; }
transfers a prerendered webcontents if one exists . this resets the internal webcontents ; a subsequent call to this method returns null . must be called from the ui thread . if a prerender exists for a different url with the same sessionid or with a different referrer , then this is treated as a mispredict from the client application , and cancels the previous prerender . this is done to avoid keeping resources laying around for too long , but is subject to a race condition , as the following scenario is possible : the application calls : 1 . maylaunchurl ( url1 ) < - ipc 2 . loadurl ( url2 ) < - intent 3 . maylaunchurl ( url3 ) < - ipc if the ipc for url3 arrives before the intent for url2 , then this methods cancels the prerender for url3 , which is unexpected . on the other hand , not cancelling the previous prerender leads to wasted resources , as a webcontents is lingering . this can be solved by requiring applications to call maylaunchurl ( null ) to cancel a current prerender before 2 , that is for a mispredict .
