Prevent duplicate data from being emitted by MhtmlResourceContext.

Patch by: bobv
Review by: rjrjr

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6505 8db76d5a-ed1c-0410-87a9-c151d255dfc7
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 2707ab7..285a993 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.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
@@ -60,6 +64,12 @@
   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 @@
      * 
      * 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 @@
     }
   }
 
-  @Override
-  public boolean supportsDataUrls() {
-    return true;
-  }
-
   void setBundleBaseIdent(String ident) {
     bundleBaseIdent = ident;
   }