Reviewers: Ray Ryan,

Message:
This patch prevents duplicate data from entering the mhtml document.  It
also removes the override of supportsDataUrls() to prevent the https
fallback case from being excessively penalizing to ImageResource users.



Please review this at http://gwt-code-reviews.appspot.com/86808

Affected files:
   M  
user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java


Index:  
user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java
diff --git  
a/user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java  
b/user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java
index  
2707ab7bbb8e723655722c1fa21a7d13963a26b0..285a9937fb7ee61a31de005234b65dd3baf2f295
  
100644
---  
a/user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java
+++  
b/user/src/com/google/gwt/resources/rebind/context/MhtmlResourceContext.java
@@ -19,9 +19,12 @@ import com.google.gwt.core.ext.GeneratorContext;
  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 @@ public class MhtmlResourceContext extends  
StaticResourceContext {
    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
@@ -60,6 +64,12 @@ public class MhtmlResourceContext extends  
StaticResourceContext {
    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";
      assert bundleBaseIdent != null : "bundleBaseIdent";
@@ -103,8 +113,10 @@ public class MhtmlResourceContext extends  
StaticResourceContext {
       *
       * 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 {
@@ -114,11 +126,6 @@ public class MhtmlResourceContext extends  
StaticResourceContext {
      }
    }

-  @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