コード例 #1
0
 public synchronized boolean isConsumer(ImageConsumer ic) {
   for (ImageDecoder id = decoders; id != null; id = id.next) {
     if (id.isConsumer(ic)) {
       return true;
     }
   }
   return ImageConsumerQueue.isConsumer(consumers, ic);
 }
コード例 #2
0
 synchronized void addConsumer(ImageConsumer ic, boolean produce) {
   checkSecurity(null, false);
   for (ImageDecoder id = decoders; id != null; id = id.next) {
     if (id.isConsumer(ic)) {
       // This consumer is already being fed.
       return;
     }
   }
   ImageConsumerQueue cq = consumers;
   while (cq != null && cq.consumer != ic) {
     cq = cq.next;
   }
   if (cq == null) {
     cq = new ImageConsumerQueue(this, ic);
     cq.next = consumers;
     consumers = cq;
   } else {
     if (!cq.secure) {
       Object context = null;
       SecurityManager security = System.getSecurityManager();
       if (security != null) {
         context = security.getSecurityContext();
       }
       if (cq.securityContext == null) {
         cq.securityContext = context;
       } else if (!cq.securityContext.equals(context)) {
         // If there are two different security contexts that both
         // have a handle on the same ImageConsumer, then there has
         // been a security breach and whether or not they trade
         // image data is small fish compared to what they could be
         // trading.  Throw a Security exception anyway...
         errorConsumer(cq, false);
         throw new SecurityException("Applets are trading image data!");
       }
     }
     cq.interested = true;
   }
   if (produce && decoder == null) {
     startProduction();
   }
 }