예제 #1
0
 /** {@inheritDoc} */
 @Override
 public void dispatchResourceLoadEvent(
     long frame, int state, String url, String contentType, double progress, int errorCode) {
   final Settings settings = SettingsManager.settings();
   if (settings == null) {
     throw new RuntimeException("Request made after browser closed. Ignoring...");
   }
   synchronized (statusCode) {
     if (url.startsWith("http://") || url.startsWith("https://")) {
       if (state == LoadListenerClient.RESOURCE_STARTED) {
         resources.put(frame + url, System.currentTimeMillis());
       } else if (state == LoadListenerClient.RESOURCE_FINISHED
           || state == LoadListenerClient.RESOURCE_FAILED) {
         String original = null;
         original = statusMonitor.originalFromRedirect(url);
         resources.remove(frame + url);
         if (original != null) {
           resources.remove(frame + original);
         }
       }
     }
   }
   if ((settings.logTrace()) && (url.startsWith("http://") || url.startsWith("https://"))) {
     trace("Rsrc", frame, state, url, contentType, progress, errorCode);
   }
 }
예제 #2
0
 /** {@inheritDoc} */
 @Override
 public void dispatchLoadEvent(
     final long frame,
     final int state,
     String url,
     String contentType,
     double progress,
     int errorCode) {
   final Settings settings = SettingsManager.settings();
   if (settings == null) {
     throw new RuntimeException("Request made after browser closed. Ignoring...");
   }
   synchronized (statusCode) {
     if (state == LoadListenerClient.PAGE_STARTED) {
       contextItem.resetFrameId(frame);
       if (settings.logJavascript()) {
         JavascriptLog.attach(Accessor.getPageFor(contextItem.engine.get()), frame);
       }
     }
     contextItem.addFrameId(frame);
     if (state == LoadListenerClient.PAGE_STARTED
         || state == LoadListenerClient.PAGE_REDIRECTED
         || state == LoadListenerClient.DOCUMENT_AVAILABLE) {
       if (contextItem.currentFrameId() == frame) {
         if (state == LoadListenerClient.PAGE_STARTED) {
           StatusMonitor.instance().clearStatusMonitor();
         }
         resetStatusCode(false);
         resources.put(frame + url, System.currentTimeMillis());
         statusMonitor.startStatusMonitor(url);
       }
       statusMonitor.addPrimaryDocument(url);
     } else if (statusCode.get() == 0
         && contextItem.currentFrameId() == frame
         && (state == LoadListenerClient.PAGE_FINISHED
             || state == LoadListenerClient.LOAD_STOPPED
             || state == LoadListenerClient.LOAD_FAILED)) {
       final int newStatusCode = statusMonitor.stopStatusMonitor(url);
       resources.remove(frame + url);
       Thread thread =
           new Thread(new AjaxListener(newStatusCode, statusCode, resources, timeoutMS.get()));
       ajaxListeners.add(thread);
       thread.start();
     }
   }
   if (settings.logTrace()) {
     trace("Page", frame, state, url, contentType, progress, errorCode);
   }
 }