Bug 757284 - Bring back Blob.mozSlice for now since sites depend on it. r=sicking a=akeybl
authorKyle Huey <khuey@kylehuey.com>
Mon, 04 Jun 2012 00:47:43 -0700
changeset 95951 90f10b5cb7ea072f0e8fb4cd703036b4a89233b3
parent 95950 6b1e65dae1d59fe32c09eb84b93032d446bb12e0
child 95952 9822aa957d92f774e111c559f8c98cf58b197138
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, akeybl
bugs757284
milestone14.0a2
Bug 757284 - Bring back Blob.mozSlice for now since sites depend on it. r=sicking a=akeybl
content/base/public/nsDOMFile.h
content/base/public/nsIDOMFile.idl
content/base/src/nsDOMFile.cpp
content/base/test/fileutils.js
dom/base/nsDOMClassInfo.cpp
--- a/content/base/public/nsDOMFile.h
+++ b/content/base/public/nsDOMFile.h
@@ -65,16 +65,17 @@
 class nsIFile;
 class nsIInputStream;
 class nsIClassInfo;
 class nsIBlobBuilder;
 
 nsresult NS_NewBlobBuilder(nsISupports* *aSupports);
 
 class nsDOMFileBase : public nsIDOMFile,
+                      public nsIBlob_GECKO_13,
                       public nsIXHRSendable,
                       public nsIMutable
 {
 public:
   typedef mozilla::dom::indexedDB::FileInfo FileInfo;
 
   nsDOMFileBase(const nsAString& aName, const nsAString& aContentType,
                 PRUint64 aLength)
@@ -111,16 +112,17 @@ public:
               const nsAString& aContentType) = 0;
 
   virtual const nsTArray<nsCOMPtr<nsIDOMBlob> >*
   GetSubBlobs() const { return nsnull; }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMBLOB
   NS_DECL_NSIDOMFILE
+  NS_DECL_NSIDOMBLOB_GECKO_13
   NS_DECL_NSIXHRSENDABLE
   NS_DECL_NSIMUTABLE
 
 protected:
   bool IsSizeUnknown()
   {
     return mLength == UINT64_MAX;
   }
--- a/content/base/public/nsIDOMFile.idl
+++ b/content/base/public/nsIDOMFile.idl
@@ -83,16 +83,24 @@ interface nsIDOMBlob : nsISupports
   // the blob is initialized from a database. It can be called on any thread.
   [notxpcom] void addFileInfo(in FileInfo aFileInfo);
 
   // Called before the blob is stored in a database to decide if it can be
   // shared or needs to be copied. It can be called on any thread.
   [notxpcom] FileInfo getFileInfo(in FileManager aFileManager);
 };
 
+[scriptable, builtinclass, uuid(96a9f6f5-2353-47a3-9bf5-4b1e0fe11c08)]
+interface nsIBlob_GECKO_13 : nsISupports
+{
+  [optional_argc] nsIDOMBlob mozSlice([optional] in long long start,
+                                      [optional] in long long end,
+                                      [optional] in DOMString contentType);
+};
+
 [scriptable, builtinclass, uuid(b096ef67-7b77-47f8-8e70-5d8ee36416bf)]
 interface nsIDOMFile : nsIDOMBlob
 {
   readonly attribute DOMString name;
   readonly attribute DOMString mozFullPath;
 
   // This performs no security checks!
   [noscript] readonly attribute DOMString mozFullPathInternal;
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -137,16 +137,17 @@ nsresult DataOwnerAdapter::Create(DataOw
 // nsDOMFileBase implementation
 
 DOMCI_DATA(File, nsDOMFileBase)
 DOMCI_DATA(Blob, nsDOMFileBase)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMFileBase)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFile)
   NS_INTERFACE_MAP_ENTRY(nsIDOMBlob)
+  NS_INTERFACE_MAP_ENTRY(nsIBlob_GECKO_13)
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFile, mIsFile)
   NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
   NS_INTERFACE_MAP_ENTRY(nsIMutable)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(File, mIsFile)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(Blob, !mIsFile)
 NS_INTERFACE_MAP_END
 
 // Threadsafe when GetMutable() == false
@@ -258,16 +259,26 @@ nsDOMFileBase::Slice(PRInt64 aStart, PRI
   // Create the new file
   *aBlob = CreateSlice((PRUint64)aStart, (PRUint64)(aEnd - aStart),
                        aContentType).get();
 
   return *aBlob ? NS_OK : NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
+nsDOMFileBase::MozSlice(PRInt64 aStart, PRInt64 aEnd,
+                        const nsAString& aContentType, PRUint8 optional_argc,
+                        nsIDOMBlob **aBlob)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  return Slice(aStart, aEnd, aContentType, optional_argc, aBlob);
+}
+
+NS_IMETHODIMP
 nsDOMFileBase::GetInternalStream(nsIInputStream **aStream)
 {
   // Must be overridden
   NS_NOTREACHED("Must override GetInternalStream");
   
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
--- a/content/base/test/fileutils.js
+++ b/content/base/test/fileutils.js
@@ -199,16 +199,20 @@ function testSlice(file, size, type, con
   is(file.type, type, fileType + " file is correct type");
   is(file.size, size, fileType + " file is correct size");
   ok(file instanceof File, fileType + " file is a File");
   ok(file instanceof Blob, fileType + " file is also a Blob");
   
   var slice = file.slice(0, size);
   ok(slice instanceof Blob, fileType + " fullsize slice is a Blob");
   ok(!(slice instanceof File), fileType + " fullsize slice is not a File");
+
+  var slice = file.mozSlice(0, size);
+  ok(slice instanceof Blob, fileType + " fullsize slice is a Blob");
+  ok(!(slice instanceof File), fileType + " fullsize slice is not a File");
   
   slice = file.slice(0, 1234);
   ok(slice instanceof Blob, fileType + " sized slice is a Blob");
   ok(!(slice instanceof File), fileType + " sized slice is not a File");
   
   slice = file.slice(0, size, "foo/bar");
   is(slice.type, "foo/bar", fileType + " fullsize slice foo/bar type");
 
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -3975,20 +3975,22 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(FileList, nsIDOMFileList)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileList)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
+    DOM_CLASSINFO_MAP_ENTRY(nsIBlob_GECKO_13)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(File, nsIDOMFile)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
+    DOM_CLASSINFO_MAP_ENTRY(nsIBlob_GECKO_13)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFile)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(FileReader, nsIDOMFileReader)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileReader)
     DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
   DOM_CLASSINFO_MAP_END