import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1164425: Cleanup interfaces of |ListenSocket|, r=kmachulis (1a158f323)
- Bug 1164417: Add |ConnectionOrientedSocket::PrepareAccept| for accepting socket connections, r=kmachulis (94c6234e0)
- Bug 1154281: Don't include UnixSocket.h in NFC, r=allstars.chh (c4eff006b)
- Bug 1146270 - Move HCI Event Origin into NfcOptions.webidl. r=smaug, dimi (1d7b28488)
- Bug 1127735 - Update TechDiscoveredNotication. r=smaug, dimi (c27f2350c)
- Bug 1152667 - Remove NfcGonkMessage.h r=dimi (c7651156f)
- Bug 1166638: Use |StreamSocketConsumer| in |StreamSocket|, r=kmachulis, dlee, chucklee, htsai (e885dd269)
- Bug 1166638: Use |ListenSocketConsumer| in |ListenSocket|, r=kmachulis, dlee, chucklee, shuang (53315fa5b)
- Bug 1152095 - Check mResultHandlerQ is empty before dispatching DispatchError. r=tzimmermann (c3a187ac4)
- Bug 1159685 - Fix BluetoothSspVariant argument passing for SspRequestNotification. r=shuang (ed398bcd4)
- Bug 1161003: Don't send PDU when connection to Bluetooth daemon is closed, r=shuang (5bb9c69d2)
- Bug 1167207: Remove |BluetoothDaemonChannel|, r=shuang (4470926f6)
- Bug 1167210: Replace |union sockaddr_any| with |struct sockaddr_storage|, r=kmachulis (69af8f130)
- Bug 1159709: Cleanup inherited methods of Bluedroid's |BluetoothSocket|, r=kmachulis (29a11ec67)
- Bug 1168446: Remove |BluetoothSocket::GetSocketAddr|, r=shuang (f1ba86da8)
- Bug 1168446: Change |BluetoothSocket::{ListenSocket,ConnectSocket}| interface, r=shuang (ef9644d68)
- Bug 1168446: Don't store connection parameters in |BluetoothSocket|, r=shuang (c8acbb880)
- Bug 1166231 - Make nsIDOMBlob an empty interface, r=ehsan (4fae64ce9)
- Bug 1176800 part 1. When getting all types, include the types Promises are parametrized over. r=peterv (8ddb8a0c6)
- Bug 1176800 part 2. Add a ToJSValue overload for owning unions. r=peterv (e0a3625d2)
- Bug 1177688, part 1 - Add API and functionality to the BlobImpl classes so that BlobImpl's that are created from an nsIFile can provide information about whether or not the nsIFile was a directory. r=baku (d45beda77)
- Bug 1177688, part 2 - Add support to the FileSystem code for obtaining a listing of a Directory's Directory and File contents via a sequence of Blobs, forking appropriately to support both for e10s and non-e10s. r=baku (d0e5e3205)
- Bug 1177688, part 3 - Implement .getFilesAndDirectories() and .path for DOM Directory objects. r=baku (f22f86472)
- Bug 1177688, part 4 - Add DeviceStorage tests for the new .getFilesAndDirectories() and .path API on Directory. r=baku (70607068a)
- Bug 1177688, part 5 - Follow-up to use nsAutoString on the stack in Directory to avoid unnecessarily allocating. r=baku (d400df943)
- Bug 1177688, part 6 - Follow-up to provide a default BlobDirState::eUnknownIfDir arg to BlobImplBase's ctor to avoid excessively specifying the same argument. r=baku (7779e7b2d)
- Bug 1097479 - Allow nested content process to embed apps and add a nested pref check function. r=kanru (b11bf2b80)
- Bug 1151495 - Support permission prompting from workers for IDB, r=bent (f3983875d)
- Bug 1173525 - Add JS::Construct overload for specifying new.target. (r=Waldo) (1067d0fba)
- Bug 1138198 - Remove unused/undefined member function ParticularProcessPriorityManager::OnChannelConnected. r=khuey (21a5c2590)
- Bug 852925 - Freeze priority changes when the screen is turned off. r=khuey (812a9e303)
- Bug 1137151: Marked destructor of |nsScreenManagerGonk| as protected, r=mwu (4943f388c)
- Bug 1157874 - Remove screen related global variables from nsWindow.cpp r=mwu (3bdc584ad)
- Bug 1157030 - Prevent visibility changes from affecting the process priority when the screen is off. r=khuey (6582a9303)
- Bug 1157030 - Stop special-casing the homescreen in the process priority manager. r=khuey, r=dhylands (bb97a1b61)
- Bug 1161748 - Rehydrate ActivityOptions in a system scope. r=fabrice,gabor (70dbc3b1b)
- Bug 1144132 - Adjust the priority of an activity opener so that it's above other background applications. r=fabrice (9789a87b1)
- Bug 1150315 - Keep SpeechSynthesis state in sync after successive cancel/speak calls. r=smaug (93abc527d)
- Bug 1154741 - Disable test_speech_cancel.html on b2g. r=me (4bcc59b0e)
- Bug 1155034 - Let indirect audio speech services send their own events. Make pause/resume IPC safe. r=smaug (b91bf210b)
- Bug 1086545 - Bind speech task streams to a parent stream held by voice registry. r=padenot (cef7476ec)
- Bug 1155917 - Added volume argument to nsISpeechService.speak(). r=smaug (a945c472a)
- Bug 1162699 - Replace mochitest test synth services with global services to simplify tests. r=smaug (7724212d9)
- Bug 1162699 followup: Add 'override' keyword to overriding methods on FakeSynthCallback. rs=ehsan (15377091b)
pull/6/head
roytam1 2 years ago
parent e23b186b0f
commit b9329817d7
  1. 8
      b2g/app/b2g.js
  2. 14
      dom/activities/ActivitiesService.jsm
  3. 19
      dom/activities/Activity.cpp
  4. 6
      dom/activities/ActivityProxy.js
  5. 5
      dom/activities/interfaces/nsIActivityProxy.idl
  6. 2
      dom/activities/moz.build
  7. 8
      dom/archivereader/ArchiveReader.cpp
  8. 22
      dom/archivereader/ArchiveZipFile.cpp
  9. 4
      dom/archivereader/ArchiveZipFile.h
  10. 122
      dom/base/File.cpp
  11. 118
      dom/base/File.h
  12. 27
      dom/base/MultipartBlobImpl.cpp
  13. 3
      dom/base/MultipartBlobImpl.h
  14. 12
      dom/base/Navigator.cpp
  15. 11
      dom/base/WebSocket.cpp
  16. 11
      dom/base/nsDOMDataChannel.cpp
  17. 29
      dom/base/nsDOMFileReader.cpp
  18. 6
      dom/base/nsDOMFileReader.h
  19. 8
      dom/base/nsDOMWindowUtils.cpp
  20. 41
      dom/base/nsHostObjectProtocolHandler.cpp
  21. 47
      dom/base/nsIDOMBlob.idl
  22. 7
      dom/base/nsXMLHttpRequest.cpp
  23. 12
      dom/bindings/Configuration.py
  24. 12
      dom/bindings/ToJSValue.h
  25. 14
      dom/bindings/parser/WebIDL.py
  26. 1
      dom/bluetooth/bluedroid/BluetoothDaemonConnector.cpp
  27. 432
      dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
  28. 37
      dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
  29. 52
      dom/bluetooth/bluedroid/BluetoothOppManager.cpp
  30. 14
      dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
  31. 178
      dom/bluetooth/bluedroid/BluetoothSocket.cpp
  32. 47
      dom/bluetooth/bluedroid/BluetoothSocket.h
  33. 60
      dom/bluetooth/bluez/BluetoothHfpManager.cpp
  34. 81
      dom/bluetooth/bluez/BluetoothOppManager.cpp
  35. 2
      dom/bluetooth/bluez/BluetoothOppManager.h
  36. 106
      dom/bluetooth/bluez/BluetoothSocket.cpp
  37. 48
      dom/bluetooth/bluez/BluetoothSocket.h
  38. 10
      dom/bluetooth/bluez/BluetoothUnixSocketConnector.cpp
  39. 1
      dom/bluetooth/bluez/BluetoothUnixSocketConnector.h
  40. 2
      dom/browser-element/mochitest/browserElementTestHelpers.js
  41. 38
      dom/browser-element/mochitest/browserElement_AllowEmbedAppsInNestedOOIframe.js
  42. 19
      dom/browser-element/mochitest/file_browserElement_AllowEmbedAppsInNestedOOIframe.html
  43. 2
      dom/browser-element/mochitest/mochitest-oop.ini
  44. 2
      dom/browser-element/mochitest/mochitest.ini
  45. 3
      dom/browser-element/mochitest/priority/mochitest.ini
  46. 63
      dom/browser-element/mochitest/priority/test_Activity.html
  47. 80
      dom/browser-element/mochitest/priority/test_ForegroundLRU.html
  48. 89
      dom/browser-element/mochitest/priority/test_MultipleActivities.html
  49. 13
      dom/browser-element/mochitest/test_browserElement_oop_AllowEmbedAppsInNestedOOIframe.html
  50. 16
      dom/camera/TestGonkCameraHardware.cpp
  51. 8
      dom/devicestorage/DeviceStorageRequestParent.cpp
  52. 21
      dom/devicestorage/nsDeviceStorage.cpp
  53. 41
      dom/devicestorage/test/devicestorage_common.js
  54. 1
      dom/devicestorage/test/mochitest.ini
  55. 97
      dom/devicestorage/test/test_fs_getFilesAndDirectories.html
  56. 60
      dom/devicestorage/test/test_fs_remove.html
  57. 7
      dom/fetch/Fetch.cpp
  58. 46
      dom/fetch/FetchDriver.cpp
  59. 4
      dom/filehandle/FileHandle.cpp
  60. 15
      dom/filesystem/CreateFileTask.cpp
  61. 37
      dom/filesystem/Directory.cpp
  62. 8
      dom/filesystem/Directory.h
  63. 2
      dom/filesystem/FileSystemRequestParent.cpp
  64. 249
      dom/filesystem/GetDirectoryListingTask.cpp
  65. 67
      dom/filesystem/GetDirectoryListingTask.h
  66. 6
      dom/filesystem/PFileSystemRequest.ipdl
  67. 1
      dom/filesystem/moz.build
  68. 14
      dom/html/HTMLCanvasElement.cpp
  69. 32
      dom/html/nsFormSubmission.cpp
  70. 22
      dom/html/nsGenericHTMLFrameElement.cpp
  71. 255
      dom/indexedDB/ActorsChild.cpp
  72. 5
      dom/indexedDB/ActorsParent.cpp
  73. 18
      dom/indexedDB/FileSnapshot.cpp
  74. 4
      dom/indexedDB/FileSnapshot.h
  75. 10
      dom/indexedDB/IDBObjectStore.cpp
  76. 5
      dom/indexedDB/test/browser.ini
  77. 91
      dom/indexedDB/test/browser_permissionsPromptWorker.js
  78. 34
      dom/indexedDB/test/browser_permissionsSharedWorker.html
  79. 14
      dom/indexedDB/test/browser_permissionsSharedWorker.js
  80. 34
      dom/indexedDB/test/browser_permissionsWorker.html
  81. 12
      dom/indexedDB/test/browser_permissionsWorker.js
  82. 163
      dom/ipc/Blob.cpp
  83. 6
      dom/ipc/BlobChild.h
  84. 1
      dom/ipc/DOMTypes.ipdlh
  85. 7
      dom/ipc/PContent.ipdl
  86. 165
      dom/ipc/ProcessPriorityManager.cpp
  87. 15
      dom/media/webspeech/synth/SpeechSynthesis.cpp
  88. 2
      dom/media/webspeech/synth/ipc/SpeechSynthesisParent.cpp
  89. 196
      dom/media/webspeech/synth/ipc/test/file_ipc.html
  90. 7
      dom/media/webspeech/synth/ipc/test/mochitest.ini
  91. 17
      dom/media/webspeech/synth/ipc/test/test_ipc.html
  92. 3
      dom/media/webspeech/synth/moz.build
  93. 17
      dom/media/webspeech/synth/nsISpeechService.idl
  94. 45
      dom/media/webspeech/synth/nsSpeechTask.cpp
  95. 4
      dom/media/webspeech/synth/nsSpeechTask.h
  96. 18
      dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
  97. 7
      dom/media/webspeech/synth/nsSynthVoiceRegistry.h
  98. 3
      dom/media/webspeech/synth/pico/nsPicoService.cpp
  99. 55
      dom/media/webspeech/synth/test/FakeSynthModule.cpp
  100. 183
      dom/media/webspeech/synth/test/common.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -648,7 +648,7 @@ pref("dom.ipc.processPriorityManager.temporaryPriorityLockMS", 5000);
// processes. We use these different levels to force the low-memory killer to
// kill processes in a LRU order.
pref("dom.ipc.processPriorityManager.BACKGROUND.LRUPoolLevels", 5);
pref("dom.ipc.processPriorityManager.FOREGROUND.LRUPoolLevels", 3);
pref("dom.ipc.processPriorityManager.BACKGROUND_PERCEIVABLE.LRUPoolLevels", 4);
// Kernel parameters for process priorities. These affect how processes are
// killed on low-memory and their relative CPU priorities.
@ -676,13 +676,9 @@ pref("hal.processPriorityManager.gonk.FOREGROUND_KEYBOARD.OomScoreAdjust", 200);
pref("hal.processPriorityManager.gonk.FOREGROUND_KEYBOARD.cgroup", "apps");
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.OomScoreAdjust", 400);
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.KillUnderKB", 7168);
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.KillUnderKB", 8192);
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.cgroup", "apps/bg_perceivable");
pref("hal.processPriorityManager.gonk.BACKGROUND_HOMESCREEN.OomScoreAdjust", 534);
pref("hal.processPriorityManager.gonk.BACKGROUND_HOMESCREEN.KillUnderKB", 8192);
pref("hal.processPriorityManager.gonk.BACKGROUND_HOMESCREEN.cgroup", "apps/bg_non_interactive");
pref("hal.processPriorityManager.gonk.BACKGROUND.OomScoreAdjust", 667);
pref("hal.processPriorityManager.gonk.BACKGROUND.KillUnderKB", 20480);
pref("hal.processPriorityManager.gonk.BACKGROUND.cgroup", "apps/bg_non_interactive");

@ -270,7 +270,7 @@ let Activities = {
.getService(Ci.nsISystemMessagesInternal);
if (!sysmm) {
// System message is not present, what should we do?
delete self.callers[aMsg.id];
self.removeCaller(aMsg.id);
return;
}
@ -334,7 +334,7 @@ let Activities = {
"id": aMsg.id,
"result": results
});
delete Activities.callers[aMsg.id];
self.removeCaller(aMsg.id);
});
} else {
let glue = Cc["@mozilla.org/dom/activities/ui-glue;1"]
@ -383,7 +383,7 @@ let Activities = {
try {
this.callers[aId].mm.sendAsyncMessage(aName, aPayload);
} finally {
delete this.callers[aId];
this.removeCaller(aId);
}
},
@ -409,8 +409,10 @@ let Activities = {
switch(aMessage.name) {
case "Activity:Start":
Services.obs.notifyObservers(null, "activity-opened", msg.childID);
this.callers[msg.id] = { mm: mm,
manifestURL: msg.manifestURL,
childID: msg.childID,
pageURL: msg.pageURL };
this.startActivity(msg);
break;
@ -455,6 +457,12 @@ let Activities = {
}
break;
}
},
removeCaller: function activities_removeCaller(id) {
Services.obs.notifyObservers(null, "activity-closed",
this.callers[id].childID);
delete this.callers[id];
}
}

@ -6,6 +6,7 @@
#include "Activity.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/ContentChild.h"
#include "nsContentUtils.h"
#include "nsDOMClassInfo.h"
#include "nsIConsoleService.h"
@ -68,12 +69,24 @@ Activity::Initialize(nsPIDOMWindow* aWindow,
mProxy = do_CreateInstance("@mozilla.org/dom/activities/proxy;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
// We're about the pass the dictionary to a JS-implemented component, so
// rehydrate it in a system scode so that security wrappers don't get in the
// way. See bug 1161748 comment 16.
bool ok;
JS::Rooted<JS::Value> optionsValue(aCx);
if (!ToJSValue(aCx, aOptions, &optionsValue)) {
return NS_ERROR_FAILURE;
{
JSAutoCompartment ac(aCx, xpc::PrivilegedJunkScope());
ok = ToJSValue(aCx, aOptions, &optionsValue);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
}
ok = JS_WrapValue(aCx, &optionsValue);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
mProxy->StartActivity(static_cast<nsIDOMDOMRequest*>(this), optionsValue, aWindow);
ContentChild *cpc = ContentChild::GetSingleton();
uint64_t childID = cpc ? cpc->GetID() : 0;
mProxy->StartActivity(static_cast<nsIDOMDOMRequest*>(this), optionsValue,
aWindow, childID);
return NS_OK;
}

@ -36,7 +36,8 @@ function ActivityProxy() {
}
ActivityProxy.prototype = {
startActivity: function actProxy_startActivity(aActivity, aOptions, aWindow) {
startActivity: function actProxy_startActivity(aActivity, aOptions, aWindow,
aChildID) {
debug("startActivity");
this.window = aWindow;
@ -97,7 +98,8 @@ ActivityProxy.prototype = {
},
getFilterResults: aOptions.getFilterResults,
manifestURL: manifestURL,
pageURL: aWindow.document.location.href });
pageURL: aWindow.document.location.href,
childID: aChildID });
},
receiveMessage: function actProxy_receiveMessage(aMessage) {

@ -9,11 +9,12 @@ interface nsIDOMWindow;
/**
* Implemented by @mozilla.org/dom/activities/proxy;1
*/
[scriptable, uuid(60adef0f-c1a7-4dc5-bc0d-4b879f1e59ca)]
[scriptable, uuid(e04c0bbc-ab7d-41ba-b801-1068dd58660b)]
interface nsIActivityProxy : nsISupports
{
void startActivity(in nsISupports /* MozActivity */ activity,
in jsval options,
in nsIDOMWindow window);
in nsIDOMWindow window,
in unsigned long long childID);
void cleanup();
};

@ -37,4 +37,6 @@ LOCAL_INCLUDES += [
'/dom/base',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'

@ -95,8 +95,12 @@ nsresult
ArchiveReader::GetInputStream(nsIInputStream** aInputStream)
{
// Getting the input stream
mBlobImpl->GetInternalStream(aInputStream);
NS_ENSURE_TRUE(*aInputStream, NS_ERROR_UNEXPECTED);
ErrorResult rv;
mBlobImpl->GetInternalStream(aInputStream, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
return NS_OK;
}

@ -357,23 +357,24 @@ ArchiveInputStream::SetEOF()
// ArchiveZipBlobImpl
nsresult
ArchiveZipBlobImpl::GetInternalStream(nsIInputStream** aStream)
void
ArchiveZipBlobImpl::GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv)
{
if (mLength > INT32_MAX) {
return NS_ERROR_FAILURE;
aRv.Throw(NS_ERROR_FAILURE);
return;
}
ErrorResult rv;
uint64_t size = mBlobImpl->GetSize(rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
uint64_t size = mBlobImpl->GetSize(aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
nsCOMPtr<nsIInputStream> inputStream;
rv = mBlobImpl->GetInternalStream(getter_AddRefs(inputStream));
if (NS_WARN_IF(rv.Failed()) || !inputStream) {
return NS_ERROR_UNEXPECTED;
mBlobImpl->GetInternalStream(getter_AddRefs(inputStream), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
nsRefPtr<ArchiveInputStream> stream = new ArchiveInputStream(size,
@ -384,7 +385,6 @@ ArchiveZipBlobImpl::GetInternalStream(nsIInputStream** aStream)
mCentral);
stream.forget(aStream);
return NS_OK;
}
already_AddRefed<mozilla::dom::BlobImpl>

@ -56,7 +56,9 @@ public:
}
// Overrides:
virtual nsresult GetInternalStream(nsIInputStream**) override;
virtual void GetInternalStream(nsIInputStream** aInputStream,
ErrorResult& aRv) override;
protected:
virtual ~ArchiveZipBlobImpl()
{

@ -229,6 +229,12 @@ Blob::IsFile() const
return mImpl->IsFile();
}
bool
Blob::IsDirectory() const
{
return mImpl->IsDirectory();
}
const nsTArray<nsRefPtr<BlobImpl>>*
Blob::GetSubBlobImpls() const
{
@ -283,52 +289,16 @@ Blob::CreateSlice(uint64_t aStart, uint64_t aLength,
return blob.forget();
}
NS_IMETHODIMP
Blob::GetSize(uint64_t* aSize)
{
MOZ_ASSERT(aSize);
ErrorResult rv;
*aSize = GetSize(rv);
return rv.StealNSResult();
}
uint64_t
Blob::GetSize(ErrorResult& aRv)
{
return mImpl->GetSize(aRv);
}
NS_IMETHODIMP
void
Blob::GetType(nsAString &aType)
{
mImpl->GetType(aType);
return NS_OK;
}
NS_IMETHODIMP
Blob::Slice(int64_t aStart, int64_t aEnd,
const nsAString& aContentType, uint8_t aArgc,
nsIDOMBlob **aBlob)
{
Optional<int64_t> start;
if (aArgc > 0) {
start.Construct(aStart);
}
Optional<int64_t> end;
if (aArgc > 1) {
end.Construct(aEnd);
}
ErrorResult rv;
nsRefPtr<Blob> blob = Slice(start, end, aContentType, rv);
if (rv.Failed()) {
return rv.StealNSResult();
}
blob.forget(aBlob);
return NS_OK;
}
already_AddRefed<Blob>
@ -406,13 +376,13 @@ Blob::Constructor(
return blob.forget();
}
NS_IMETHODIMP_(int64_t)
int64_t
Blob::GetFileId()
{
return mImpl->GetFileId();
}
NS_IMETHODIMP_(void)
void
Blob::AddFileInfo(indexedDB::FileInfo* aFileInfo)
{
mImpl->AddFileInfo(aFileInfo);
@ -424,16 +394,16 @@ Blob::GetFileInfo(indexedDB::FileManager* aFileManager)
return mImpl->GetFileInfo(aFileManager);
}
NS_IMETHODIMP_(bool)
Blob::IsMemoryFile()
bool
Blob::IsMemoryFile() const
{
return mImpl->IsMemoryFile();
}
NS_IMETHODIMP
Blob::GetInternalStream(nsIInputStream** aStream)
void
Blob::GetInternalStream(nsIInputStream** aStream, ErrorResult& aRv)
{
return mImpl->GetInternalStream(aStream);
mImpl->GetInternalStream(aStream, aRv);
}
////////////////////////////////////////////////////////////////////////////
@ -457,10 +427,11 @@ File::Create(nsISupports* aParent, BlobImpl* aImpl)
/* static */ already_AddRefed<File>
File::Create(nsISupports* aParent, const nsAString& aName,
const nsAString& aContentType, uint64_t aLength,
int64_t aLastModifiedDate)
int64_t aLastModifiedDate, BlobDirState aDirState)
{
nsRefPtr<File> file = new File(aParent,
new BlobImplBase(aName, aContentType, aLength, aLastModifiedDate));
new BlobImplBase(aName, aContentType, aLength, aLastModifiedDate,
aDirState));
return file.forget();
}
@ -911,16 +882,17 @@ BlobImplBase::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
{
MOZ_ASSERT(aContentLength);
nsresult rv;
ErrorResult rv;
nsCOMPtr<nsIInputStream> stream;
rv = GetInternalStream(getter_AddRefs(stream));
NS_ENSURE_SUCCESS(rv, rv);
GetInternalStream(getter_AddRefs(stream), rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
ErrorResult error;
*aContentLength = GetSize(error);
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
*aContentLength = GetSize(rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
nsAutoString contentType;
@ -1063,13 +1035,16 @@ const uint32_t sFileStreamFlags =
nsIFileInputStream::DEFER_OPEN |
nsIFileInputStream::SHARE_DELETE;
nsresult
BlobImplFile::GetInternalStream(nsIInputStream** aStream)
void
BlobImplFile::GetInternalStream(nsIInputStream** aStream, ErrorResult& aRv)
{
return mWholeFile ?
NS_NewLocalFileInputStream(aStream, mFile, -1, -1, sFileStreamFlags) :
NS_NewPartialLocalFileInputStream(aStream, mFile, mStart, mLength,
-1, -1, sFileStreamFlags);
if (mWholeFile) {
aRv = NS_NewLocalFileInputStream(aStream, mFile, -1, -1, sFileStreamFlags);
return;
}
aRv = NS_NewPartialLocalFileInputStream(aStream, mFile, mStart, mLength,
-1, -1, sFileStreamFlags);
}
void
@ -1081,6 +1056,17 @@ BlobImplFile::SetPath(const nsAString& aPath)
mPath = aPath;
}
void
BlobImplFile::LookupAndCacheIsDirectory()
{
MOZ_ASSERT(mIsFile,
"This should only be called when this object has been created "
"from an nsIFile to note that the nsIFile is a directory");
bool isDir;
mFile->IsDirectory(&isDir);
mDirState = isDir ? BlobDirState::eIsDir : BlobDirState::eIsNotDir;
}
////////////////////////////////////////////////////////////////////////////
// BlobImplMemory implementation
@ -1096,13 +1082,15 @@ BlobImplMemory::CreateSlice(uint64_t aStart, uint64_t aLength,
return impl.forget();
}
nsresult
BlobImplMemory::GetInternalStream(nsIInputStream** aStream)
void
BlobImplMemory::GetInternalStream(nsIInputStream** aStream, ErrorResult& aRv)
{
if (mLength > INT32_MAX)
return NS_ERROR_FAILURE;
if (mLength > INT32_MAX) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
return DataOwnerAdapter::Create(mDataOwner, mStart, mLength, aStream);
aRv = DataOwnerAdapter::Create(mDataOwner, mStart, mLength, aStream);
}
/* static */ StaticMutex
@ -1228,13 +1216,13 @@ BlobImplTemporaryBlob::CreateSlice(uint64_t aStart, uint64_t aLength,
return impl.forget();
}
nsresult
BlobImplTemporaryBlob::GetInternalStream(nsIInputStream** aStream)
void
BlobImplTemporaryBlob::GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv)
{
nsCOMPtr<nsIInputStream> stream =
new nsTemporaryFileInputStream(mFileDescOwner, mStartPos, mStartPos + mLength);
stream.forget(aStream);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////

@ -51,6 +51,18 @@ class BlobImpl;
class File;
class OwningArrayBufferOrArrayBufferViewOrBlobOrString;
/**
* Used to indicate when a Blob/BlobImpl that was created from an nsIFile
* (when IsFile() will return true) was from an nsIFile for which
* nsIFile::IsDirectory() returned true. This is a tri-state to enable us to
* assert that the state is always set when callers request it.
*/
enum BlobDirState : uint32_t {
eIsDir,
eIsNotDir,
eUnknownIfDir
};
class Blob : public nsIDOMBlob
, public nsIXHRSendable
, public nsIMutable
@ -95,6 +107,12 @@ public:
bool IsFile() const;
/**
* This may return true if the Blob was created from an nsIFile that is a
* directory.
*/
bool IsDirectory() const;
const nsTArray<nsRefPtr<BlobImpl>>* GetSubBlobImpls() const;
// This method returns null if this Blob is not a File; it returns
@ -102,6 +120,9 @@ public:
// otherwise it returns a new File object with the same BlobImpl.
already_AddRefed<File> ToFile();
// XXXjwatt Consider having a ToDirectory() method. The need for a FileSystem
// object complicates that though.
// This method creates a new File object with the given name and the same
// BlobImpl.
already_AddRefed<File> ToFile(const nsAString& aName) const;
@ -110,12 +131,27 @@ public:
CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType,
ErrorResult& aRv);
void
GetInternalStream(nsIInputStream** aStream, ErrorResult& aRv);
int64_t
GetFileId();
indexedDB::FileInfo*
GetFileInfo(indexedDB::FileManager* aFileManager);
void
AddFileInfo(indexedDB::FileInfo* aFileInfo);
// WebIDL methods
nsISupports* GetParentObject() const
{
return mParent;
}
bool
IsMemoryFile() const;
// Blob constructor
static already_AddRefed<Blob>
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
@ -132,7 +168,7 @@ public:
uint64_t GetSize(ErrorResult& aRv);
// XPCOM GetType is OK
void GetType(nsAString& aType);
already_AddRefed<Blob> Slice(const Optional<int64_t>& aStart,
const Optional<int64_t>& aEnd,
@ -169,7 +205,7 @@ public:
static already_AddRefed<File>
Create(nsISupports* aParent, const nsAString& aName,
const nsAString& aContentType, uint64_t aLength,
int64_t aLastModifiedDate);
int64_t aLastModifiedDate, BlobDirState aDirState);
static already_AddRefed<File>
Create(nsISupports* aParent, const nsAString& aName,
@ -297,7 +333,8 @@ public:
virtual const nsTArray<nsRefPtr<BlobImpl>>*
GetSubBlobImpls() const = 0;
virtual nsresult GetInternalStream(nsIInputStream** aStream) = 0;
virtual void GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv) = 0;
virtual int64_t GetFileId() = 0;
@ -318,7 +355,8 @@ public:
virtual void SetLazyData(const nsAString& aName,
const nsAString& aContentType,
uint64_t aLength,
int64_t aLastModifiedDate) = 0;
int64_t aLastModifiedDate,
BlobDirState aDirState) = 0;
virtual bool IsMemoryFile() const = 0;
@ -328,6 +366,27 @@ public:
virtual bool IsFile() const = 0;
/**
* Called when this BlobImpl was created from an nsIFile in order to call
* nsIFile::IsDirectory() and cache the result so that when the BlobImpl is
* copied to another process that informaton is available.
* nsIFile::IsDirectory() does synchronous I/O, and BlobImpl objects may be
* created on the main thread or in a non-chrome process (where I/O is not
* allowed). Do not call this on a non-chrome process, and preferably do not
* call it on the main thread.
*
* Not all creators of BlobImplFile will call this method, in which case
* calling IsDirectory will MOZ_ASSERT.
*/
virtual void LookupAndCacheIsDirectory() = 0;
virtual bool IsDirectory() const = 0;
/**
* Prefer IsDirectory(). This exists to help consumer code pass on state from
* one BlobImpl when creating another.
*/
virtual BlobDirState GetDirState() const = 0;
// True if this implementation can be sent to other threads.
virtual bool MayBeClonedToOtherThreads() const
{
@ -344,9 +403,11 @@ class BlobImplBase : public BlobImpl
{
public:
BlobImplBase(const nsAString& aName, const nsAString& aContentType,
uint64_t aLength, int64_t aLastModifiedDate)
uint64_t aLength, int64_t aLastModifiedDate,
BlobDirState aDirState = BlobDirState::eUnknownIfDir)
: mIsFile(true)
, mImmutable(false)
, mDirState(aDirState)
, mContentType(aContentType)
, mName(aName)
, mStart(0)
@ -361,6 +422,7 @@ public:
uint64_t aLength)
: mIsFile(true)
, mImmutable(false)
, mDirState(BlobDirState::eUnknownIfDir)
, mContentType(aContentType)
, mName(aName)
, mStart(0)
@ -374,6 +436,7 @@ public:
BlobImplBase(const nsAString& aContentType, uint64_t aLength)
: mIsFile(false)
, mImmutable(false)
, mDirState(BlobDirState::eUnknownIfDir)
, mContentType(aContentType)
, mStart(0)
, mLength(aLength)
@ -387,6 +450,7 @@ public:
uint64_t aLength)
: mIsFile(false)
, mImmutable(false)
, mDirState(BlobDirState::eUnknownIfDir)
, mContentType(aContentType)
, mStart(aStart)
, mLength(aLength)
@ -431,9 +495,10 @@ public:
return nullptr;
}
virtual nsresult GetInternalStream(nsIInputStream** aStream) override
virtual void GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv) override
{
return NS_ERROR_NOT_IMPLEMENTED;
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
}
virtual int64_t GetFileId() override;
@ -454,7 +519,8 @@ public:
virtual void
SetLazyData(const nsAString& aName, const nsAString& aContentType,
uint64_t aLength, int64_t aLastModifiedDate) override
uint64_t aLength, int64_t aLastModifiedDate,
BlobDirState aDirState) override
{
NS_ASSERTION(aLength, "must have length");
@ -480,6 +546,27 @@ public:
return mIsFile;
}
virtual void LookupAndCacheIsDirectory() override
{
MOZ_ASSERT(false, "Why is this being called on a non-BlobImplFile?");
}
/**
* Returns true if the nsIFile that this object wraps is a directory.
*/
virtual bool IsDirectory() const override
{
MOZ_ASSERT(mDirState != BlobDirState::eUnknownIfDir,
"Must only be used by callers for whom the code paths are "
"know to call LookupAndCacheIsDirectory()");
return mDirState == BlobDirState::eIsDir;
}
virtual BlobDirState GetDirState() const override
{
return mDirState;
}
virtual bool IsStoredFile() const
{
return false;
@ -514,6 +601,7 @@ protected:
bool mIsFile;
bool mImmutable;
BlobDirState mDirState;
nsString mContentType;
nsString mName;
@ -539,7 +627,8 @@ public:
BlobImplMemory(void* aMemoryBuffer, uint64_t aLength, const nsAString& aName,
const nsAString& aContentType, int64_t aLastModifiedDate)
: BlobImplBase(aName, aContentType, aLength, aLastModifiedDate)
: BlobImplBase(aName, aContentType, aLength, aLastModifiedDate,
BlobDirState::eIsNotDir)
, mDataOwner(new DataOwner(aMemoryBuffer, aLength))
{
NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data");
@ -553,7 +642,8 @@ public:
NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data");
}
virtual nsresult GetInternalStream(nsIInputStream** aStream) override;
virtual void GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv) override;
virtual already_AddRefed<BlobImpl>
CreateSlice(uint64_t aStart, uint64_t aLength,
@ -639,7 +729,8 @@ public:
mFileDescOwner = new nsTemporaryFileInputStream::FileDescOwner(aFD);
}
virtual nsresult GetInternalStream(nsIInputStream** aStream) override;
virtual void GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv) override;
virtual already_AddRefed<BlobImpl>
CreateSlice(uint64_t aStart, uint64_t aLength,
@ -781,10 +872,13 @@ public:
virtual void SetLastModified(int64_t aLastModified) override;
virtual void GetMozFullPathInternal(nsAString& aFullPath,
ErrorResult& aRv) override;
virtual nsresult GetInternalStream(nsIInputStream**) override;
virtual void GetInternalStream(nsIInputStream** aInputStream,
ErrorResult& aRv) override;
void SetPath(const nsAString& aFullPath);
virtual void LookupAndCacheIsDirectory() override;
protected:
virtual ~BlobImplFile() {
if (mFile && mIsTemporary) {

@ -25,30 +25,36 @@ using namespace mozilla::dom;
NS_IMPL_ISUPPORTS_INHERITED0(MultipartBlobImpl, BlobImpl)
nsresult
MultipartBlobImpl::GetInternalStream(nsIInputStream** aStream)
void
MultipartBlobImpl::GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv)
{
nsresult rv;
*aStream = nullptr;
nsCOMPtr<nsIMultiplexInputStream> stream =
do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1");
NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE);
if (NS_WARN_IF(!stream)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
uint32_t i;
for (i = 0; i < mBlobImpls.Length(); i++) {
nsCOMPtr<nsIInputStream> scratchStream;
BlobImpl* blobImpl = mBlobImpls.ElementAt(i).get();
rv = blobImpl->GetInternalStream(getter_AddRefs(scratchStream));
NS_ENSURE_SUCCESS(rv, rv);
blobImpl->GetInternalStream(getter_AddRefs(scratchStream), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
rv = stream->AppendStream(scratchStream);
NS_ENSURE_SUCCESS(rv, rv);
aRv = stream->AppendStream(scratchStream);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
}
stream.forget(aStream);
return NS_OK;
}
already_AddRefed<BlobImpl>
@ -359,8 +365,7 @@ MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindow* aWindow,
nsRefPtr<File> blob = File::CreateFromFile(aWindow, aFile, aBag.mTemporary);
// Pre-cache size.
uint64_t unused;
aRv = blob->GetSize(&unused);
blob->GetSize(aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}

@ -92,7 +92,8 @@ public:
return mLength;
}
virtual nsresult GetInternalStream(nsIInputStream** aInputStream) override;
virtual void GetInternalStream(nsIInputStream** aInputStream,
ErrorResult& aRv) override;
virtual const nsTArray<nsRefPtr<BlobImpl>>* GetSubBlobImpls() const override
{

@ -1215,17 +1215,13 @@ Navigator::SendBeacon(const nsAString& aUrl,
} else if (aData.Value().IsBlob()) {
Blob& blob = aData.Value().GetAsBlob();
rv = blob.GetInternalStream(getter_AddRefs(in));
if (NS_FAILED(rv)) {
aRv.Throw(NS_ERROR_FAILURE);
blob.GetInternalStream(getter_AddRefs(in), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return false;
}
nsAutoString type;
rv = blob.GetType(type);
if (NS_FAILED(rv)) {
aRv.Throw(NS_ERROR_FAILURE);
return false;
}
blob.GetType(type);
mimeType = NS_ConvertUTF16toUTF8(type);
} else if (aData.Value().IsFormData()) {

@ -2300,16 +2300,13 @@ WebSocket::Send(Blob& aData, ErrorResult& aRv)
AssertIsOnTargetThread();
nsCOMPtr<nsIInputStream> msgStream;
nsresult rv = aData.GetInternalStream(getter_AddRefs(msgStream));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
aData.GetInternalStream(getter_AddRefs(msgStream), aRv);
if (NS_WARN_IF(aRv.Failed())){
return;
}
uint64_t msgLength;
rv = aData.GetSize(&msgLength);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
uint64_t msgLength = aData.GetSize(aRv);
if (NS_WARN_IF(aRv.Failed())){
return;
}

@ -270,16 +270,13 @@ nsDOMDataChannel::Send(Blob& aData, ErrorResult& aRv)
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
nsCOMPtr<nsIInputStream> msgStream;
nsresult rv = aData.GetInternalStream(getter_AddRefs(msgStream));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
aData.GetInternalStream(getter_AddRefs(msgStream), aRv);
if (NS_WARN_IF(aRv.Failed())){
return;
}
uint64_t msgLength;
rv = aData.GetSize(&msgLength);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
uint64_t msgLength = aData.GetSize(aRv);
if (NS_WARN_IF(aRv.Failed())){
return;
}

@ -238,9 +238,7 @@ nsDOMFileReader::DoAbort(nsAString& aEvent)
SetDOMStringToNull(mResult);
mResultArrayBuffer = nullptr;
if (mAsyncStream) {
mAsyncStream = nullptr;
}
mAsyncStream = nullptr;
mBlob = nullptr;
//Clean up memory buffer
@ -281,7 +279,8 @@ nsDOMFileReader::DoOnLoadEnd(nsresult aStatus,
// Make sure we drop all the objects that could hold files open now.
nsCOMPtr<nsIAsyncInputStream> stream;
mAsyncStream.swap(stream);
nsCOMPtr<nsIDOMBlob> blob;
nsRefPtr<Blob> blob;
mBlob.swap(blob);
aSuccessEvent = NS_LITERAL_STRING(LOAD_STR);
@ -408,9 +407,8 @@ nsDOMFileReader::ReadFileContent(Blob& aBlob,
}
nsCOMPtr<nsIInputStream> stream;
rv = mBlob->GetInternalStream(getter_AddRefs(stream));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
mBlob->GetInternalStream(getter_AddRefs(stream), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
@ -439,8 +437,10 @@ nsDOMFileReader::ReadFileContent(Blob& aBlob,
mAsyncStream = do_QueryInterface(wrapper);
MOZ_ASSERT(mAsyncStream);
mTotal = mozilla::dom::kUnknownSize;
mBlob->GetSize(&mTotal);
mTotal = mBlob->GetSize(aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
rv = DoAsyncWait(mAsyncStream);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -462,7 +462,7 @@ nsDOMFileReader::ReadFileContent(Blob& aBlob,
}
nsresult
nsDOMFileReader::GetAsText(nsIDOMBlob *aBlob,
nsDOMFileReader::GetAsText(Blob *aBlob,
const nsACString &aCharset,
const char *aFileData,
uint32_t aDataLen,
@ -502,17 +502,16 @@ nsDOMFileReader::GetAsText(nsIDOMBlob *aBlob,
}
nsresult
nsDOMFileReader::GetAsDataURL(nsIDOMBlob *aBlob,
nsDOMFileReader::GetAsDataURL(Blob *aBlob,
const char *aFileData,
uint32_t aDataLen,
nsAString& aResult)
{
aResult.AssignLiteral("data:");
nsresult rv;
nsString contentType;
rv = aBlob->GetType(contentType);
if (NS_SUCCEEDED(rv) && !contentType.IsEmpty()) {
aBlob->GetType(contentType);
if (!contentType.IsEmpty()) {
aResult.Append(contentType);
} else {
aResult.AppendLiteral("application/octet-stream");
@ -520,7 +519,7 @@ nsDOMFileReader::GetAsDataURL(nsIDOMBlob *aBlob,
aResult.AppendLiteral(";base64,");
nsCString encodedData;
rv = Base64Encode(Substring(aFileData, aDataLen), encodedData);
nsresult rv = Base64Encode(Substring(aFileData, aDataLen), encodedData);
NS_ENSURE_SUCCESS(rv, rv);
if (!AppendASCIItoUTF16(encodedData, aResult, fallible)) {

@ -128,10 +128,10 @@ protected:
void ReadFileContent(Blob& aBlob,
const nsAString &aCharset, eDataFormat aDataFormat,
ErrorResult& aRv);
nsresult GetAsText(nsIDOMBlob *aBlob, const nsACString &aCharset,
nsresult GetAsText(Blob *aBlob, const nsACString &aCharset,
const char *aFileData, uint32_t aDataLen,
nsAString &aResult);
nsresult GetAsDataURL(nsIDOMBlob *aBlob, const char *aFileData,
nsresult GetAsDataURL(Blob *aBlob, const char *aFileData,
uint32_t aDataLen, nsAString &aResult);
void FreeFileData() {
@ -141,7 +141,7 @@ protected:
}
char *mFileData;
nsCOMPtr<nsIDOMBlob> mBlob;
nsRefPtr<Blob> mBlob;
nsCString mCharset;
uint32_t mDataLen;

@ -18,6 +18,7 @@
#include "nsFocusManager.h"
#include "nsFrameManager.h"
#include "nsRefreshDriver.h"
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/PendingAnimationTracker.h"
#include "nsIObjectLoadingContent.h"
@ -2865,11 +2866,8 @@ nsDOMWindowUtils::GetFileId(JS::Handle<JS::Value> aFile, JSContext* aCx,
return NS_OK;
}
nsISupports* nativeObj =
nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, obj);
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(nativeObj);
if (blob) {
Blob* blob = nullptr;
if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, obj, blob))) {
*_retval = blob->GetFileId();
return NS_OK;
}

@ -168,9 +168,9 @@ class BlobURLsReporter final : public nsIMemoryReporter
void* aUserArg)
{
EnumArg* envp = static_cast<EnumArg*>(aUserArg);
nsCOMPtr<nsIDOMBlob> blob;
nsCOMPtr<nsIDOMBlob> tmp = do_QueryInterface(aInfo->mObject);
nsRefPtr<Blob> blob = static_cast<Blob*>(tmp.get());
blob = do_QueryInterface(aInfo->mObject);
if (blob) {
NS_NAMED_LITERAL_CSTRING
(desc, "A blob URL allocated with URL.createObjectURL; the referenced "
@ -189,7 +189,10 @@ class BlobURLsReporter final : public nsIMemoryReporter
bool isMemoryFile = blob->IsMemoryFile();
if (isMemoryFile) {
if (NS_FAILED(blob->GetSize(&size))) {
ErrorResult rv;
size = blob->GetSize(rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
size = 0;
}
}
@ -513,9 +516,12 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
}
#endif
ErrorResult rv;
nsCOMPtr<nsIInputStream> stream;
nsresult rv = blob->GetInternalStream(getter_AddRefs(stream));
NS_ENSURE_SUCCESS(rv, rv);
blob->GetInternalStream(getter_AddRefs(stream), rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
nsCOMPtr<nsIChannel> channel;
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
@ -524,7 +530,9 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
EmptyCString(), // aContentType
EmptyCString(), // aContentCharset
aLoadInfo);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
nsString type;
blob->GetType(type);
@ -535,10 +543,9 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
channel->SetContentDispositionFilename(filename);
}
ErrorResult error;
uint64_t size = blob->GetSize(error);
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
uint64_t size = blob->GetSize(rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
channel->SetOriginalURI(uri);
@ -613,12 +620,18 @@ nsresult
NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream)
{
nsRefPtr<BlobImpl> blobImpl;
nsresult rv = NS_GetBlobForBlobURI(aURI, getter_AddRefs(blobImpl));
if (NS_FAILED(rv)) {
return rv;
ErrorResult rv;
rv = NS_GetBlobForBlobURI(aURI, getter_AddRefs(blobImpl));
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
blobImpl->GetInternalStream(aStream, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
return blobImpl->GetInternalStream(aStream);
return NS_OK;
}
nsresult

@ -5,51 +5,8 @@
#include "nsISupports.idl"
%{C++
namespace mozilla {
namespace dom {
namespace indexedDB {
class FileInfo;
class FileManager;
}
}
}
%}
[ptr] native FileInfo(mozilla::dom::indexedDB::FileInfo);
[ptr] native FileManager(mozilla::dom::indexedDB::FileManager);
interface nsIDOMFileError;
interface nsIInputStream;
interface nsIURI;
interface nsIPrincipal;
interface nsIDOMBlob;
[scriptable, builtinclass, uuid(6ef56697-7c9c-41ac-83df-e01c079fb1d1)]
[scriptable, builtinclass, uuid(f344146a-ee1f-417e-8a68-6984ca56f0ae)]
interface nsIDOMBlob : nsISupports
{
readonly attribute unsigned long long size;
readonly attribute DOMString type;
[noscript] readonly attribute nsIInputStream internalStream;
[optional_argc] nsIDOMBlob slice([optional] in long long start,
[optional] in long long end,
[optional] in DOMString contentType);
// Get internal id of stored file. Returns -1 if it is not a stored file.
// Intended only for testing. It can be called on any thread.
[notxpcom] long long getFileId();
// Called when the blob was successfully stored in a database or when
// 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);
// Return true if this blob is a memory file.
[notxpcom] bool isMemoryFile();
// Just an empty interface.
};

@ -1958,7 +1958,12 @@ nsXMLHttpRequest::OnDataAvailable(nsIRequest *request,
if (cancelable) {
// We don't have to read from the local file for the blob response
mDOMBlob->GetSize(&mDataAvailable);
ErrorResult error;
mDataAvailable = mDOMBlob->GetSize(error);