Revision: 6505
Author: b...@google.com
Date: Wed Oct 28 07:06:55 2009
Log: Prevent duplicate data from being emitted by MhtmlResourceContext.

Patch by: bobv
Review by: rjrjr
http://code.google.com/p/google-web-toolkit/source/detail?r=6505

Modified:
   
/trunk/user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java

=======================================
---  
/trunk/user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java
        
Wed May 27 06:48:54 2009
+++  
/trunk/user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java
        
Wed Oct 28 07:06:55 2009
@@ -19,9 +19,12 @@
  import com.google.gwt.core.ext.TreeLogger;
  import com.google.gwt.core.ext.UnableToCompleteException;
  import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.dev.util.Util;

  import java.io.OutputStream;
  import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;

  /**
   * Encodes resources into Multipart HTML files. In order to avoid  
mixed-content
@@ -42,6 +45,7 @@
    private String bundleBaseIdent;
    private int id = 0;
    private String isHttpsIdent;
+  private final Map<String, String> strongNameToExpressions = new  
HashMap<String, String>();

    /**
     * Output is lazily initialized in the case that all deployed resources  
are
@@ -59,6 +63,12 @@
    @Override
    public String deploy(String suggestedFileName, String mimeType, byte[]  
data,
        boolean xhrCompatible) throws UnableToCompleteException {
+
+    String strongName = Util.computeStrongName(data);
+    String toReturn = strongNameToExpressions.get(strongName);
+    if (toReturn != null) {
+      return toReturn;
+    }

      assert partialPath != null : "partialPath";
      assert isHttpsIdent != null : "isHttpsIdent";
@@ -103,8 +113,10 @@
       *
       * isHttps ? (staticLocation) : (bundleBaseIdent + "location")
       */
-    return isHttpsIdent + " ? (" + staticLocation + ") : (" +  
bundleBaseIdent
-        + " + \"" + location + "\")";
+    toReturn = isHttpsIdent + " ? (" + staticLocation + ") : ("
+        + bundleBaseIdent + " + \"" + location + "\")";
+    strongNameToExpressions.put(strongName, toReturn);
+    return toReturn;
    }

    public void finish() throws UnableToCompleteException {
@@ -113,11 +125,6 @@
        getContext().commitResource(getLogger(), out);
      }
    }
-
-  @Override
-  public boolean supportsDataUrls() {
-    return true;
-  }

    void setBundleBaseIdent(String ident) {
      bundleBaseIdent = ident;

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to