author | Dorel Luca <dluca@mozilla.com> |
Tue, 06 Mar 2018 23:54:12 +0200 | |
changeset 406793 | bccdc684210431c233622650a91454c09f6af9eb |
parent 406780 | f89b9a3c44d2a340de57b0645cf6fb682c0c94db (current diff) |
parent 406792 | 9ee84efab9c8ad0835f8f5f1630138e9049ca53b (diff) |
child 406806 | d9e59ad16af432f6a57e91e57aad49ad0771d7c5 |
child 406831 | 667fe01d1d3e8c0b5e9f55c6517a0bb307811001 |
push id | 33580 |
push user | dluca@mozilla.com |
push date | Tue, 06 Mar 2018 21:54:45 +0000 |
treeherder | mozilla-central@bccdc6842104 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | merge |
milestone | 60.0a1 |
first release with | nightly linux32
bccdc6842104
/
60.0a1
/
20180306220120
/
files
nightly linux64
bccdc6842104
/
60.0a1
/
20180306220120
/
files
nightly mac
bccdc6842104
/
60.0a1
/
20180306220120
/
files
nightly win32
bccdc6842104
/
60.0a1
/
20180306220120
/
files
nightly win64
bccdc6842104
/
60.0a1
/
20180306220120
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
60.0a1
/
20180306220120
/
pushlog to previous
nightly linux64
60.0a1
/
20180306220120
/
pushlog to previous
nightly mac
60.0a1
/
20180306220120
/
pushlog to previous
nightly win32
60.0a1
/
20180306220120
/
pushlog to previous
nightly win64
60.0a1
/
20180306220120
/
pushlog to previous
|
toolkit/components/downloads/moz.build | file | annotate | diff | comparison | revisions | |
toolkit/components/downloads/nsDownloadManager.cpp | file | annotate | diff | comparison | revisions | |
toolkit/components/downloads/nsDownloadManager.h | file | annotate | diff | comparison | revisions | |
toolkit/components/downloads/nsIDownload.idl | file | annotate | diff | comparison | revisions | |
toolkit/components/downloads/nsIDownloadManager.idl | file | annotate | diff | comparison | revisions | |
toolkit/components/downloads/nsIDownloadManagerUI.idl | file | annotate | diff | comparison | revisions | |
toolkit/components/downloads/nsIDownloadProgressListener.idl | file | annotate | diff | comparison | revisions | |
toolkit/themes/linux/mozapps/downloads/downloadIcon.png | file | annotate | diff | comparison | revisions | |
toolkit/themes/osx/mozapps/downloads/downloadIcon.png | file | annotate | diff | comparison | revisions | |
toolkit/themes/windows/mozapps/downloads/downloadIcon.png | file | annotate | diff | comparison | revisions |
--- a/browser/base/content/test/static/browser_all_files_referenced.js +++ b/browser/base/content/test/static/browser_all_files_referenced.js @@ -68,19 +68,16 @@ var whitelist = [ // toolkit/content/aboutRights-unbranded.xhtml doesn't use aboutRights.css {file: "chrome://global/skin/aboutRights.css", skipUnofficial: true}, // devtools/client/inspector/bin/dev-server.js {file: "chrome://devtools/content/inspector/markup/markup.xhtml", isFromDevTools: true}, - // Kept for add-on compatibility, should be removed in bug 851471. - {file: "chrome://mozapps/skin/downloads/downloadIcon.png"}, - // SpiderMonkey parser API, currently unused in browser/ and toolkit/ {file: "resource://gre/modules/reflect.jsm"}, // extensions/pref/autoconfig/src/nsReadConfig.cpp {file: "resource://gre/defaults/autoconfig/prefcalls.js"}, // modules/libpref/Preferences.cpp {file: "resource://gre/greprefs.js"},
--- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -217,17 +217,16 @@ @RESPATH@/components/dom_sidebar.xpt @RESPATH@/components/dom_storage.xpt #ifdef MOZ_WEBSPEECH @RESPATH@/components/dom_webspeechrecognition.xpt #endif @RESPATH@/components/dom_workers.xpt @RESPATH@/components/dom_xul.xpt @RESPATH@/components/dom_presentation.xpt -@RESPATH@/components/downloads.xpt @RESPATH@/components/editor.xpt @RESPATH@/components/enterprisepolicies.xpt @RESPATH@/components/extensions.xpt @RESPATH@/components/exthandler.xpt @RESPATH@/components/fastfind.xpt @RESPATH@/components/feeds.xpt @RESPATH@/components/gfx.xpt @RESPATH@/components/html5.xpt
--- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -8493,16 +8493,17 @@ GetSurfaceDataImpl(mozilla::gfx::DataSou if (!aSurface->Map(mozilla::gfx::DataSourceSurface::MapType::READ, &map)) { return GetSurfaceDataContext::NullValue(); } mozilla::gfx::IntSize size = aSurface->GetSize(); mozilla::CheckedInt32 requiredBytes = mozilla::CheckedInt32(map.mStride) * mozilla::CheckedInt32(size.height); if (!requiredBytes.isValid()) { + aSurface->Unmap(); return GetSurfaceDataContext::NullValue(); } size_t maxBufLen = requiredBytes.value(); mozilla::gfx::SurfaceFormat format = aSurface->GetFormat(); // Surface data handling is totally nuts. This is the magic one needs to // know to access the data.
--- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -30,16 +30,17 @@ #include "nsICryptoHash.h" #include "nsICryptoHMAC.h" #include "nsIKeyModule.h" #include "nsAppDirectoryServiceDefs.h" #include "nsIInputStream.h" #include "nsILineInputStream.h" #include "nsPIDOMWindow.h" #include "mozilla/EventStateManager.h" +#include "mozilla/MozPromise.h" #include "mozilla/Telemetry.h" #include "mozilla/Types.h" #include "mozilla/PeerIdentity.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/File.h" #include "mozilla/dom/MediaStreamBinding.h" @@ -151,49 +152,52 @@ using media::Refcountable; static Atomic<bool> sHasShutdown; typedef media::Pledge<bool, dom::MediaStreamError*> PledgeVoid; struct DeviceState { DeviceState(const RefPtr<MediaDevice>& aDevice, bool aOffWhileDisabled) : mOffWhileDisabled(aOffWhileDisabled) - , mDisableTimer(new MediaTimer()) , mDevice(aDevice) { MOZ_ASSERT(mDevice); } // true if we have stopped mDevice, this is a terminal state. // MainThread only. bool mStopped = false; // true if mDevice is currently enabled, i.e., turned on and capturing. // MainThread only. - bool mDeviceEnabled = true; + bool mDeviceEnabled = false; // true if the application has currently enabled mDevice. // MainThread only. - bool mTrackEnabled = true; + bool mTrackEnabled = false; + + // Time when the application last enabled mDevice. + // MainThread only. + TimeStamp mTrackEnabledTime; // true if an operation to Start() or Stop() mDevice has been dispatched to // the media thread and is not finished yet. // MainThread only. bool mOperationInProgress = false; // true if we are allowed to turn off the underlying source while all tracks // are disabled. // MainThread only. bool mOffWhileDisabled = false; // Timer triggered by a MediaStreamTrackSource signaling that all tracks got // disabled. When the timer fires we initiate Stop()ing mDevice. // If set we allow dynamically stopping and starting mDevice. // Any thread. - const RefPtr<MediaTimer> mDisableTimer; + const RefPtr<MediaTimer> mDisableTimer = new MediaTimer(); // The underlying device we keep state for. Always non-null. // Threadsafe access, but see method declarations for individual constraints. const RefPtr<MediaDevice> mDevice; }; /** * This mimics the capture state from nsIMediaManagerService. @@ -234,16 +238,18 @@ FromCaptureState(CaptureState aState) * don't hold a reference to it during late shutdown. * * There's also a hard reference to the SourceListener through its * SourceStreamListener and the MediaStreamGraph. MediaStreamGraph * clears this on XPCOM_WILL_SHUTDOWN, before MediaManager enters shutdown. */ class SourceListener : public SupportsWeakPtr<SourceListener> { public: + typedef MozPromise<bool /* aIgnored */, RefPtr<MediaMgrError>, true> InitPromise; + MOZ_DECLARE_WEAKREFERENCE_TYPENAME(SourceListener) NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(SourceListener) SourceListener(); /** * Registers this source listener as belonging to the given window listener. */ @@ -252,16 +258,21 @@ public: /** * Marks this listener as active and adds itself as a listener to aStream. */ void Activate(SourceMediaStream* aStream, MediaDevice* aAudioDevice, MediaDevice* aVideoDevice); /** + * Posts a task to initialize and start all associated devices. + */ + RefPtr<InitPromise> InitializeAsync(); + + /** * Stops all live tracks, finishes the associated MediaStream and cleans up. */ void Stop(); /** * Removes this SourceListener from its associated MediaStream and marks it * removed. Also removes the weak reference to the associated window listener. */ @@ -1369,99 +1380,42 @@ public: mOnSuccess, mWindowID, domStream)))); // Dispatch to the media thread to ask it to start the sources, // because that can take a while. // Pass ownership of domStream through the lambda to the nested chrome // notification lambda to ensure it's kept alive until that lambda runs or is discarded. - RefPtr<GetUserMediaStreamRunnable> self = this; - MediaManager::PostTask(NewTaskFrom([self, domStream, callback]() mutable { - MOZ_ASSERT(MediaManager::IsInMediaThread()); - RefPtr<SourceMediaStream> source = - self->mSourceListener->GetSourceStream(); - - RefPtr<MediaMgrError> error = nullptr; - if (self->mAudioDevice) { - nsresult rv = self->mAudioDevice->SetTrack(source, - kAudioTrack, - self->mSourceListener->GetPrincipalHandle()); - if (NS_SUCCEEDED(rv)) { - rv = self->mAudioDevice->Start(); - } else { - nsString log; - if (rv == NS_ERROR_NOT_AVAILABLE) { - log.AssignASCII("Concurrent mic process limit."); - error = new MediaMgrError(NS_LITERAL_STRING("NotReadableError"), log); - } else { - log.AssignASCII("Starting audio failed"); - error = new MediaMgrError(NS_LITERAL_STRING("InternalError"), log); - } - } - } - - if (!error && self->mVideoDevice) { - nsresult rv = self->mVideoDevice->SetTrack(source, - kVideoTrack, - self->mSourceListener->GetPrincipalHandle()); - if (NS_SUCCEEDED(rv)) { - rv = self->mVideoDevice->Start(); - } - if (NS_FAILED(rv)) { - nsString log; - log.AssignASCII("Starting video failed"); - error = new MediaMgrError(NS_LITERAL_STRING("InternalError"), log); - } - } - - if (error) { - // Dispatch the error callback on main thread. - NS_DispatchToMainThread(MakeAndAddRef<ErrorCallbackRunnable>( - self->mOnFailure, *error, self->mWindowID)); - return NS_OK; - } - - // Start() queued the tracks to be added synchronously to avoid races - source->FinishAddTracks(); - - source->AdvanceKnownTracksTime(STREAM_TIME_MAX); - - LOG(("started all sources")); - - // onTracksAvailableCallback must be added to domStream on the main thread. - uint64_t windowID = self->mWindowID; - NS_DispatchToMainThread(NS_NewRunnableFunction("MediaManager::NotifyChromeOfStart", - [source, domStream, callback, windowID]() mutable { - source->SetPullEnabled(true); - - MediaManager* manager = MediaManager::GetIfExists(); - if (!manager) { + mSourceListener->InitializeAsync()->Then( + GetMainThreadSerialEventTarget(), __func__, + [manager = mManager, domStream, callback, + windowListener = mWindowListener]() + { + // Initiating and starting devices succeeded. + // onTracksAvailableCallback must be added to domStream on main thread. + domStream->OnTracksAvailable(callback->release()); + windowListener->ChromeAffectingStateChanged(); + manager->SendPendingGUMRequest(); + },[manager = mManager, windowID = mWindowID, + onFailure = Move(mOnFailure)](const RefPtr<MediaMgrError>& error) + { + // Initiating and starting devices failed. + + // Only run if the window is still active for our window listener. + if (!(manager->IsWindowStillActive(windowID))) { return; } - - nsGlobalWindowInner* window = - nsGlobalWindowInner::GetInnerWindowWithId(windowID); - if (!window) { - MOZ_ASSERT_UNREACHABLE("Should have window"); - return; + // This is safe since we're on main-thread, and the windowlist can only + // be invalidated from the main-thread (see OnNavigation) + if (auto* window = nsGlobalWindowInner::GetInnerWindowWithId(windowID)) { + auto streamError = MakeRefPtr<MediaStreamError>(window->AsInner(), *error); + onFailure->OnError(streamError); } - - domStream->OnTracksAvailable(callback->release()); - - nsresult rv = MediaManager::NotifyRecordingStatusChange(window->AsInner()); - if (NS_FAILED(rv)) { - MOZ_ASSERT_UNREACHABLE("Should be able to notify chrome"); - return; - } - - manager->SendPendingGUMRequest(); - })); - return NS_OK; - })); + }); if (!IsPincipalInfoPrivate(mPrincipalInfo)) { // Call GetPrincipalKey again, this time w/persist = true, to promote // deviceIds to persistent, in case they're not already. Fire'n'forget. RefPtr<Pledge<nsCString>> p = media::GetPrincipalKey(mPrincipalInfo, true); } return NS_OK; @@ -2144,16 +2098,30 @@ MediaManager::PostTask(already_AddRefed< MOZ_CRASH(); return; } NS_ASSERTION(Get(), "MediaManager singleton?"); NS_ASSERTION(Get()->mMediaThread, "No thread yet"); Get()->mMediaThread->message_loop()->PostTask(Move(task)); } +template<typename MozPromiseType, typename FunctionType> +/* static */ RefPtr<MozPromiseType> +MediaManager::PostTask(const char* aName, FunctionType&& aFunction) +{ + MozPromiseHolder<MozPromiseType> holder; + RefPtr<MozPromiseType> promise = holder.Ensure(aName); + MediaManager::PostTask(NS_NewRunnableFunction(aName, + [h = Move(holder), func = Forward<FunctionType>(aFunction)]() mutable + { + func(h); + })); + return promise; +} + /* static */ nsresult MediaManager::NotifyRecordingStatusChange(nsPIDOMWindowInner* aWindow) { NS_ENSURE_ARG(aWindow); nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); if (!obs) { NS_WARNING("Could not get the Observer service for GetUserMedia recording notification."); @@ -3819,16 +3787,120 @@ SourceListener::Activate(SourceMediaStre aVideoDevice, aVideoDevice->GetMediaSource() == dom::MediaSourceEnum::Camera && Preferences::GetBool("media.getusermedia.camera.off_while_disabled.enabled", true)); } mStream->AddListener(mStreamListener); } +RefPtr<SourceListener::InitPromise> +SourceListener::InitializeAsync() +{ + MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread"); + MOZ_DIAGNOSTIC_ASSERT(!mStopped); + + RefPtr<InitPromise> init = MediaManager::PostTask<InitPromise>(__func__, + [ stream = mStream + , principal = GetPrincipalHandle() + , audioDevice = mAudioDeviceState ? mAudioDeviceState->mDevice : nullptr + , videoDevice = mVideoDeviceState ? mVideoDeviceState->mDevice : nullptr + ](MozPromiseHolder<InitPromise>& aHolder) + { + if (audioDevice) { + nsresult rv = audioDevice->SetTrack(stream, kAudioTrack, principal); + if (NS_SUCCEEDED(rv)) { + rv = audioDevice->Start(); + } + if (NS_FAILED(rv)) { + nsString log; + if (rv == NS_ERROR_NOT_AVAILABLE) { + log.AssignASCII("Concurrent mic process limit."); + aHolder.Reject(MakeRefPtr<MediaMgrError>( + NS_LITERAL_STRING("NotReadableError"), log), __func__); + return; + } + log.AssignASCII("Starting audio failed"); + aHolder.Reject(MakeRefPtr<MediaMgrError>( + NS_LITERAL_STRING("InternalError"), log), __func__); + return; + } + } + + if (videoDevice) { + nsresult rv = videoDevice->SetTrack(stream, kVideoTrack, principal); + if (NS_SUCCEEDED(rv)) { + rv = videoDevice->Start(); + } + if (NS_FAILED(rv)) { + if (audioDevice) { + if (NS_WARN_IF(NS_FAILED(audioDevice->Stop()))) { + MOZ_ASSERT_UNREACHABLE("Stopping audio failed"); + } + } + nsString log; + log.AssignASCII("Starting video failed"); + aHolder.Reject(MakeRefPtr<MediaMgrError>(NS_LITERAL_STRING("InternalError"), log), __func__); + return; + } + } + + // Start() queued the tracks to be added synchronously to avoid races + stream->FinishAddTracks(); + stream->AdvanceKnownTracksTime(STREAM_TIME_MAX); + LOG(("started all sources")); + + aHolder.Resolve(true, __func__); + }); + + return init->Then(GetMainThreadSerialEventTarget(), __func__, + [self = RefPtr<SourceListener>(this), this]() + { + if (mStopped) { + // We were shut down during the async init + return InitPromise::CreateAndResolve(true, __func__); + } + + mStream->SetPullEnabled(true); + + for (DeviceState* state : {mAudioDeviceState.get(), + mVideoDeviceState.get()}) { + if (!state) { + continue; + } + MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mStopped); + + state->mDeviceEnabled = true; + state->mTrackEnabled = true; + state->mTrackEnabledTime = TimeStamp::Now(); + } + return InitPromise::CreateAndResolve(true, __func__); + }, [self = RefPtr<SourceListener>(this), this](RefPtr<MediaMgrError>&& aResult) + { + if (mStopped) { + return InitPromise::CreateAndReject(Move(aResult), __func__); + } + + for (DeviceState* state : {mAudioDeviceState.get(), + mVideoDeviceState.get()}) { + if (!state) { + continue; + } + MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled); + MOZ_DIAGNOSTIC_ASSERT(!state->mStopped); + + state->mStopped = true; + } + return InitPromise::CreateAndReject(Move(aResult), __func__); + }); +} + void SourceListener::Stop() { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread"); if (mStopped) { return; } @@ -3951,17 +4023,16 @@ SourceListener::SetEnabledFor(TrackID aT state.mTrackEnabled = aEnable; if (state.mStopped) { // Device terminally stopped. Updating device state is pointless. return; } - if (state.mOperationInProgress) { // If a timer is in progress, it needs to be canceled now so the next // DisableTrack() gets a fresh start. Canceling will trigger another // operation. state.mDisableTimer->Cancel(); return; } @@ -3972,30 +4043,36 @@ SourceListener::SetEnabledFor(TrackID aT // All paths from here on must end in setting `state.mOperationInProgress` // to false. state.mOperationInProgress = true; RefPtr<MediaTimerPromise> timerPromise; if (aEnable) { timerPromise = MediaTimerPromise::CreateAndResolve(true, __func__); + state.mTrackEnabledTime = TimeStamp::Now(); } else { - const TimeDuration offDelay = TimeDuration::FromMilliseconds( + const TimeDuration maxDelay = TimeDuration::FromMilliseconds( Preferences::GetUint( aTrackID == kAudioTrack ? "media.getusermedia.microphone.off_while_disabled.delay_ms" : "media.getusermedia.camera.off_while_disabled.delay_ms", 3000)); - timerPromise = state.mDisableTimer->WaitFor(offDelay, __func__); + const TimeDuration durationEnabled = + TimeStamp::Now() - state.mTrackEnabledTime; + const TimeDuration delay = + TimeDuration::Max(TimeDuration::FromMilliseconds(0), + maxDelay - durationEnabled); + timerPromise = state.mDisableTimer->WaitFor(delay, __func__); } typedef MozPromise<nsresult, bool, /* IsExclusive = */ true> DeviceOperationPromise; RefPtr<SourceListener> self = this; timerPromise->Then(GetMainThreadSerialEventTarget(), __func__, - [self, this, &state, aTrackID, aEnable](bool aDummy) mutable { + [self, this, &state, aTrackID, aEnable]() mutable { MOZ_ASSERT(state.mDeviceEnabled != aEnable, "Device operation hasn't started"); MOZ_ASSERT(state.mOperationInProgress, "It's our responsibility to reset the inProgress state"); LOG(("SourceListener %p %s %s track %d - starting device operation", this, aEnable ? "enabling" : "disabling", aTrackID == kAudioTrack ? "audio" : "video", @@ -4009,25 +4086,22 @@ SourceListener::SetEnabledFor(TrackID aT if (!state.mOffWhileDisabled) { // If the feature to turn a device off while disabled is itself disabled // we shortcut the device operation and tell the ux-updating code // that everything went fine. return DeviceOperationPromise::CreateAndResolve(NS_OK, __func__); } - RefPtr<DeviceOperationPromise::Private> promise = - new DeviceOperationPromise::Private(__func__); - MediaManager::PostTask(NewTaskFrom([self, device = state.mDevice, - aEnable, promise]() mutable { - promise->Resolve(aEnable ? device->Start() : device->Stop(), __func__); - })); - RefPtr<DeviceOperationPromise> result = promise.get(); - return result; - }, [](bool aDummy) { + return MediaManager::PostTask<DeviceOperationPromise>(__func__, + [self, device = state.mDevice, aEnable] + (MozPromiseHolder<DeviceOperationPromise>& h) { + h.Resolve(aEnable ? device->Start() : device->Stop(), __func__); + }); + }, []() { // Timer was canceled by us. We signal this with NS_ERROR_ABORT. return DeviceOperationPromise::CreateAndResolve(NS_ERROR_ABORT, __func__); })->Then(GetMainThreadSerialEventTarget(), __func__, [self, this, &state, aTrackID, aEnable](nsresult aResult) mutable { MOZ_ASSERT(state.mOperationInProgress); state.mOperationInProgress = false; if (state.mStopped) { @@ -4077,17 +4151,17 @@ SourceListener::SetEnabledFor(TrackID aT } // Track state changed during this operation. We'll start over. if (state.mTrackEnabled) { SetEnabledFor(aTrackID, true); } else { SetEnabledFor(aTrackID, false); } - }, [](bool aDummy) { + }, []() { MOZ_ASSERT_UNREACHABLE("Unexpected and unhandled reject"); }); } void SourceListener::StopSharing() { MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -137,16 +137,28 @@ public: // NOTE: never Dispatch(....,NS_DISPATCH_SYNC) to the MediaManager // thread from the MainThread, as we NS_DISPATCH_SYNC to MainThread // from MediaManager thread. static MediaManager* Get(); static MediaManager* GetIfExists(); static void StartupInit(); static void PostTask(already_AddRefed<Runnable> task); + + /** + * Posts an async operation to the media manager thread. + * FunctionType must be a function that takes a `MozPromiseHolder&`. + * + * The returned promise is resolved or rejected by aFunction on the media + * manager thread. + */ + template<typename MozPromiseType, typename FunctionType> + static RefPtr<MozPromiseType> + PostTask(const char* aName, FunctionType&& aFunction); + #ifdef DEBUG static bool IsInMediaThread(); #endif static bool Exists() { return !!sSingleton; }
--- a/dom/media/webrtc/MediaEngineDefault.cpp +++ b/dom/media/webrtc/MediaEngineDefault.cpp @@ -232,16 +232,20 @@ MediaEngineDefaultVideoSource::Start(con return NS_OK; } nsresult MediaEngineDefaultVideoSource::Stop(const RefPtr<const AllocationHandle>& aHandle) { AssertIsOnOwningThread(); + if (mState == kStopped || mState == kAllocated) { + return NS_OK; + } + MOZ_ASSERT(mState == kStarted); MOZ_ASSERT(mTimer); MOZ_ASSERT(mStream); MOZ_ASSERT(IsTrackIDExplicit(mTrackID)); mTimer->Cancel(); mTimer = nullptr; @@ -345,17 +349,17 @@ MediaEngineDefaultVideoSource::Pull(cons MOZ_ASSERT(mTrackID == aTrackID); image = mImage; } } StreamTime delta = aDesiredTime - aStream->GetEndOfAppendedData(aTrackID); if (delta > 0) { // nullptr images are allowed - IntSize size(image ? mOpts.mWidth : 0, image ? mOpts.mHeight : 0); + IntSize size(mOpts.mWidth, mOpts.mHeight); segment.AppendFrame(image.forget(), delta, size, aPrincipalHandle); // This can fail if either a) we haven't added the track yet, or b) // we've removed or finished the track. aStream->AppendToTrack(aTrackID, &segment); } } /** @@ -490,19 +494,22 @@ MediaEngineDefaultAudioSource::Start(con return NS_OK; } nsresult MediaEngineDefaultAudioSource::Stop(const RefPtr<const AllocationHandle>& aHandle) { AssertIsOnOwningThread(); + if (mState == kStopped || mState == kAllocated) { + return NS_OK; + } + MOZ_ASSERT(mState == kStarted); - MutexAutoLock lock(mMutex); mState = kStopped; return NS_OK; } nsresult MediaEngineDefaultAudioSource::Reconfigure( const RefPtr<AllocationHandle>& aHandle,
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp @@ -319,16 +319,20 @@ MediaEngineRemoteVideoSource::Start(cons } nsresult MediaEngineRemoteVideoSource::Stop(const RefPtr<const AllocationHandle>& aHandle) { LOG((__PRETTY_FUNCTION__)); AssertIsOnOwningThread(); + if (mState == kStopped || mState == kAllocated) { + return NS_OK; + } + MOZ_ASSERT(mState == kStarted); if (camera::GetChildAndCall(&camera::CamerasChild::StopCapture, mCapEngine, mCaptureIndex)) { MOZ_DIAGNOSTIC_ASSERT(false, "Stopping a started capture failed"); } {
--- a/dom/media/webrtc/MediaEngineSource.h +++ b/dom/media/webrtc/MediaEngineSource.h @@ -166,16 +166,19 @@ public: const char** aOutBadConstraint) = 0; /** * Called by MediaEngine to stop feeding data to the track associated with * the given AllocationHandle. * * If this was the last AllocationHandle that had been started, * the underlying device will be stopped. + * + * Double-stopping a given allocation handle is allowed and will return NS_OK. + * This is necessary sometimes during shutdown. */ virtual nsresult Stop(const RefPtr<const AllocationHandle>& aHandle) = 0; /** * Called by MediaEngine to deallocate a handle to this source. * * If this was the last registered AllocationHandle, the underlying device * will be deallocated.
--- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp @@ -397,16 +397,21 @@ MediaEngineTabVideoSource::Draw() { mImage = image; mImageSize = size; } nsresult MediaEngineTabVideoSource::Stop(const RefPtr<const AllocationHandle>& aHandle) { AssertIsOnOwningThread(); + + if (mState == kStopped || mState == kAllocated) { + return NS_OK; + } + MOZ_ASSERT(mState == kStarted); // If mBlackedoutWindow is true, we may be running // despite mWindow == nullptr. if (!mWindow && !mBlackedoutWindow) { return NS_OK; }
--- a/ipc/glue/SharedMemoryBasic_mach.mm +++ b/ipc/glue/SharedMemoryBasic_mach.mm @@ -547,19 +547,21 @@ SharedMemoryBasic::Create(size_t size) memory_object_size_t memoryObjectSize = round_page(size); kr = mach_make_memory_entry_64(mach_task_self(), &memoryObjectSize, address, VM_PROT_DEFAULT, &mPort, MACH_PORT_NULL); - if (kr != KERN_SUCCESS) { + if (kr != KERN_SUCCESS || memoryObjectSize < round_page(size)) { LOG_ERROR("Failed to make memory entry (%zu bytes). %s (%x)\n", size, mach_error_string(kr), kr); + CloseHandle(); + mach_vm_deallocate(mach_task_self(), address, round_page(size)); return false; } mMemory = toPointer(address); Mapped(size); return true; }
--- a/mfbt/Maybe.h +++ b/mfbt/Maybe.h @@ -7,28 +7,51 @@ /* A class for optional values and in-place lazy construction. */ #ifndef mozilla_Maybe_h #define mozilla_Maybe_h #include "mozilla/Alignment.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryChecking.h" #include "mozilla/Move.h" #include "mozilla/OperatorNewExtensions.h" +#include "mozilla/Poison.h" #include "mozilla/TypeTraits.h" #include <new> // for placement new #include <ostream> #include <type_traits> namespace mozilla { struct Nothing { }; +namespace detail { + +template<typename T> +struct MaybePoisoner +{ + static const size_t N = sizeof(T); + + static void poison(void* aPtr) + { +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED + // Avoid MOZ_ASSERT in mozWritePoison. + if (N >= sizeof(uintptr_t)) { + mozWritePoison(aPtr, N); + } +#endif + MOZ_MAKE_MEM_UNDEFINED(aPtr, N); + } +}; + +} // namespace detail + /* * Maybe is a container class which contains either zero or one elements. It * serves two roles. It can represent values which are *semantically* optional, * augmenting a type with an explicit 'Nothing' value. In this role, it provides * methods that make it easy to work with values that may be missing, along with * equality and comparison operators so that Maybe values can be stored in * containers. Maybe values can be constructed conveniently in expressions using * type inference, as follows: @@ -88,69 +111,88 @@ class MOZ_NON_PARAM MOZ_INHERIT_TYPE_ANN MOZ_ALIGNAS_IN_STRUCT(T) unsigned char mStorage[sizeof(T)]; char mIsSome; // not bool -- guarantees minimal space consumption // GCC fails due to -Werror=strict-aliasing if |mStorage| is directly cast to // T*. Indirecting through these functions addresses the problem. void* data() { return mStorage; } const void* data() const { return mStorage; } + void poisonData() + { + detail::MaybePoisoner<T>::poison(data()); + } + public: using ValueType = T; - Maybe() : mIsSome(false) { } + Maybe() : mIsSome(false) + { + poisonData(); + } ~Maybe() { reset(); } - MOZ_IMPLICIT Maybe(Nothing) : mIsSome(false) { } + MOZ_IMPLICIT Maybe(Nothing) : mIsSome(false) + { + poisonData(); + } Maybe(const Maybe& aOther) : mIsSome(false) { if (aOther.mIsSome) { emplace(*aOther); + } else { + poisonData(); } } /** * Maybe<T> can be copy-constructed from a Maybe<U> if U is convertible to T. */ template<typename U, typename = typename std::enable_if<std::is_convertible<U, T>::value>::type> MOZ_IMPLICIT Maybe(const Maybe<U>& aOther) : mIsSome(false) { if (aOther.isSome()) { emplace(*aOther); + } else { + poisonData(); } } Maybe(Maybe&& aOther) : mIsSome(false) { if (aOther.mIsSome) { emplace(Move(*aOther)); aOther.reset(); + } else { + poisonData(); } } /** * Maybe<T> can be move-constructed from a Maybe<U> if U is convertible to T. */ template<typename U, typename = typename std::enable_if<std::is_convertible<U, T>::value>::type> MOZ_IMPLICIT Maybe(Maybe<U>&& aOther) : mIsSome(false) { if (aOther.isSome()) { emplace(Move(*aOther)); aOther.reset(); + } else { + poisonData(); } } Maybe& operator=(const Maybe& aOther) { if (&aOther != this) { if (aOther.mIsSome) { if (mIsSome) { @@ -440,16 +482,17 @@ public: } /* If |isSome()|, empties this Maybe and destroys its contents. */ void reset() { if (isSome()) { ref().T::~T(); mIsSome = false; + poisonData(); } } /* * Constructs a T value in-place in this empty Maybe<T>'s storage. The * arguments to |emplace()| are the parameters to T's constructor. */ template<typename... Args>
--- a/mfbt/Poison.h +++ b/mfbt/Poison.h @@ -11,16 +11,17 @@ #ifndef mozilla_Poison_h #define mozilla_Poison_h #include "mozilla/Assertions.h" #include "mozilla/Types.h" #include <stdint.h> +#include <string.h> MOZ_BEGIN_EXTERN_C extern MFBT_DATA uintptr_t gMozillaPoisonValue; /** * @return the poison value. */ @@ -34,21 +35,20 @@ inline uintptr_t mozPoisonValue() * aPtr MUST be aligned at a sizeof(uintptr_t) boundary. * Only an even number of sizeof(uintptr_t) bytes are overwritten, the last * few bytes (if any) is not overwritten. */ inline void mozWritePoison(void* aPtr, size_t aSize) { const uintptr_t POISON = mozPoisonValue(); char* p = (char*)aPtr; - char* limit = p + aSize; - MOZ_ASSERT((uintptr_t)aPtr % sizeof(uintptr_t) == 0, "bad alignment"); + char* limit = p + (aSize & ~(sizeof(uintptr_t) - 1)); MOZ_ASSERT(aSize >= sizeof(uintptr_t), "poisoning this object has no effect"); for (; p < limit; p += sizeof(uintptr_t)) { - *((uintptr_t*)p) = POISON; + memcpy(p, &POISON, sizeof(POISON)); } } /** * Initialize the poison value. * This should only be called once. */ extern MFBT_API void mozPoisonValueInit();
--- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -142,17 +142,16 @@ @BINPATH@/components/dom_storage.xpt @BINPATH@/components/dom_system.xpt #ifdef MOZ_WEBSPEECH @BINPATH@/components/dom_webspeechrecognition.xpt #endif @BINPATH@/components/dom_xhr.xpt @BINPATH@/components/dom_xul.xpt @BINPATH@/components/dom_presentation.xpt -@BINPATH@/components/downloads.xpt @BINPATH@/components/editor.xpt @BINPATH@/components/extensions.xpt @BINPATH@/components/exthandler.xpt @BINPATH@/components/fastfind.xpt @BINPATH@/components/feeds.xpt @BINPATH@/components/gfx.xpt @BINPATH@/components/html5.xpt @BINPATH@/components/htmlparser.xpt
--- a/taskcluster/ci/release-bouncer-aliases/kind.yml +++ b/taskcluster/ci/release-bouncer-aliases/kind.yml @@ -20,23 +20,23 @@ job-defaults: mozilla-beta: scriptworker-prov-v1/bouncer-v1 mozilla-release: scriptworker-prov-v1/bouncer-v1 default: scriptworker-prov-v1/bouncer-dev worker: implementation: bouncer-aliases scopes: by-project: mozilla-beta: - - project:releng:bouncer:action:submission + - project:releng:bouncer:action:aliases - project:releng:bouncer:server:production mozilla-release: - - project:releng:bouncer:action:submission + - project:releng:bouncer:action:aliases - project:releng:bouncer:server:production default: - - project:releng:bouncer:action:submission + - project:releng:bouncer:action:aliases - project:releng:bouncer:server:staging run-on-projects: [] shipping-phase: ship jobs: devedition: bouncer-products: ['installer', 'installer-ssl', 'stub-installer'] shipping-product: devedition
--- a/taskcluster/taskgraph/transforms/bouncer_aliases.py +++ b/taskcluster/taskgraph/transforms/bouncer_aliases.py @@ -24,17 +24,16 @@ def make_task_worker(config, jobs): for job in jobs: resolve_keyed_by( job, 'worker-type', item_name=job['name'], project=config.params['project'] ) resolve_keyed_by( job, 'scopes', item_name=job['name'], project=config.params['project'] ) - job['scopes'].append('project:releng:bouncer:action:aliases') job['worker']['entries'] = craft_bouncer_entries(config, job) del job['bouncer-products'] if job['worker']['entries']: yield job else: logger.warn('No bouncer entries defined in bouncer submission task for "{}". \
--- a/toolkit/components/build/moz.build +++ b/toolkit/components/build/moz.build @@ -15,17 +15,16 @@ SOURCES += [ 'nsToolkitCompsModule.cpp', ] FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ '../../xre', '../alerts', - '../downloads', '../feeds', '../find', '../jsdownloads/src', '../perfmonitoring', '../protobuf', '../reputationservice', '../startup', '../statusfilter',
--- a/toolkit/components/build/nsToolkitCompsCID.h +++ b/toolkit/components/build/nsToolkitCompsCID.h @@ -16,19 +16,16 @@ "@mozilla.org/autocomplete/controller;1" #define NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID \ "@mozilla.org/autocomplete/simple-result;1" #define NS_AUTOCOMPLETEMDBRESULT_CONTRACTID \ "@mozilla.org/autocomplete/mdb-result;1" -#define NS_DOWNLOADMANAGER_CONTRACTID \ - "@mozilla.org/download-manager;1" - #define NS_DOWNLOADPLATFORM_CONTRACTID \ "@mozilla.org/toolkit/download-platform;1" #define NS_FORMHISTORY_CONTRACTID \ "@mozilla.org/satchel/form-history;1" #define NS_FORMFILLCONTROLLER_CONTRACTID \ "@mozilla.org/satchel/form-fill-controller;1" @@ -112,19 +109,16 @@ // {2ee3039b-2de4-43d9-93b0-649beacff39a} #define NS_AUTOCOMPLETESIMPLERESULT_CID \ { 0x2ee3039b, 0x2de4, 0x43d9, { 0x93, 0xb0, 0x64, 0x9b, 0xea, 0xcf, 0xf3, 0x9a } } // {7A6F70B6-2BBD-44b5-9304-501352D44AB5} #define NS_AUTOCOMPLETEMDBRESULT_CID \ { 0x7a6f70b6, 0x2bbd, 0x44b5, { 0x93, 0x4, 0x50, 0x13, 0x52, 0xd4, 0x4a, 0xb5 } } -#define NS_DOWNLOADMANAGER_CID \ - { 0xedb0490e, 0x1dd1, 0x11b2, { 0x83, 0xb8, 0xdb, 0xf8, 0xd8, 0x59, 0x06, 0xa6 } } - #define NS_DOWNLOADPLATFORM_CID \ { 0x649a14c9, 0xfe5c, 0x48ec, { 0x9c, 0x85, 0x00, 0xca, 0xd9, 0xcc, 0xf3, 0x2e } } // {895DB6C7-DBDF-40ea-9F64-B175033243DC} #define NS_FORMFILLCONTROLLER_CID \ { 0x895db6c7, 0xdbdf, 0x40ea, { 0x9f, 0x64, 0xb1, 0x75, 0x3, 0x32, 0x43, 0xdc } } // {59648a91-5a60-4122-8ff2-54b839c84aed}
--- a/toolkit/components/build/nsToolkitCompsModule.cpp +++ b/toolkit/components/build/nsToolkitCompsModule.cpp @@ -14,17 +14,16 @@ #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) #include "nsParentalControlsService.h" #endif #include "mozilla/AlertNotification.h" #include "nsAlertsService.h" -#include "nsDownloadManager.h" #include "DownloadPlatform.h" #include "rdf.h" #include "nsTypeAheadFind.h" #include "ApplicationReputation.h" #include "LoginReputation.h" #include "nsUrlClassifierDBService.h" @@ -79,18 +78,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFindSer #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) NS_GENERIC_FACTORY_CONSTRUCTOR(nsParentalControlsService) #endif NS_GENERIC_FACTORY_CONSTRUCTOR(AlertNotification) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsService) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDownloadManager, - nsDownloadManager::GetSingleton) NS_GENERIC_FACTORY_CONSTRUCTOR(DownloadPlatform) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTypeAheadFind) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ApplicationReputationService, ApplicationReputationService::GetSingleton) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(LoginReputationService, LoginReputationService::GetSingleton) @@ -139,17 +136,16 @@ NS_DEFINE_NAMED_CID(NS_TOOLKIT_PERFORMAN NS_DEFINE_NAMED_CID(NS_TOOLKIT_TERMINATOR_CID); #endif NS_DEFINE_NAMED_CID(NS_USERINFO_CID); NS_DEFINE_NAMED_CID(ALERT_NOTIFICATION_CID); NS_DEFINE_NAMED_CID(NS_ALERTSSERVICE_CID); #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) NS_DEFINE_NAMED_CID(NS_PARENTALCONTROLSSERVICE_CID); #endif -NS_DEFINE_NAMED_CID(NS_DOWNLOADMANAGER_CID); NS_DEFINE_NAMED_CID(NS_DOWNLOADPLATFORM_CID); NS_DEFINE_NAMED_CID(NS_FIND_SERVICE_CID); NS_DEFINE_NAMED_CID(NS_TYPEAHEADFIND_CID); NS_DEFINE_NAMED_CID(NS_APPLICATION_REPUTATION_SERVICE_CID); NS_DEFINE_NAMED_CID(NS_LOGIN_REPUTATION_SERVICE_CID); NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERPREFIXSET_CID); NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERDBSERVICE_CID); NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERSTREAMUPDATER_CID); @@ -175,17 +171,16 @@ static const Module::CIDEntry kToolkitCI { &kNS_TOOLKIT_PERFORMANCESTATSSERVICE_CID, false, nullptr, nsPerformanceStatsServiceConstructor }, #endif // defined (MOZ_HAS_PERFSTATS) { &kNS_USERINFO_CID, false, nullptr, nsUserInfoConstructor }, { &kALERT_NOTIFICATION_CID, false, nullptr, AlertNotificationConstructor }, { &kNS_ALERTSSERVICE_CID, false, nullptr, nsAlertsServiceConstructor }, #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) { &kNS_PARENTALCONTROLSSERVICE_CID, false, nullptr, nsParentalControlsServiceConstructor }, #endif - { &kNS_DOWNLOADMANAGER_CID, false, nullptr, nsDownloadManagerConstructor }, { &kNS_DOWNLOADPLATFORM_CID, false, nullptr, DownloadPlatformConstructor }, { &kNS_FIND_SERVICE_CID, false, nullptr, nsFindServiceConstructor }, { &kNS_TYPEAHEADFIND_CID, false, nullptr, nsTypeAheadFindConstructor }, { &kNS_APPLICATION_REPUTATION_SERVICE_CID, false, nullptr, ApplicationReputationServiceConstructor }, { &kNS_LOGIN_REPUTATION_SERVICE_CID, false, nullptr, LoginReputationServiceConstructor }, { &kNS_URLCLASSIFIERPREFIXSET_CID, false, nullptr, nsUrlClassifierPrefixSetConstructor }, { &kNS_URLCLASSIFIERDBSERVICE_CID, false, nullptr, nsUrlClassifierDBServiceConstructor }, { &kNS_URLCLASSIFIERSTREAMUPDATER_CID, false, nullptr, nsUrlClassifierStreamUpdaterConstructor }, @@ -213,17 +208,16 @@ static const Module::ContractIDEntry kTo { NS_TOOLKIT_PERFORMANCESTATSSERVICE_CONTRACTID, &kNS_TOOLKIT_PERFORMANCESTATSSERVICE_CID }, #endif // defined (MOZ_HAS_PERFSTATS) { NS_USERINFO_CONTRACTID, &kNS_USERINFO_CID }, { ALERT_NOTIFICATION_CONTRACTID, &kALERT_NOTIFICATION_CID }, { NS_ALERTSERVICE_CONTRACTID, &kNS_ALERTSSERVICE_CID }, #if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) { NS_PARENTALCONTROLSSERVICE_CONTRACTID, &kNS_PARENTALCONTROLSSERVICE_CID }, #endif - { NS_DOWNLOADMANAGER_CONTRACTID, &kNS_DOWNLOADMANAGER_CID }, { NS_DOWNLOADPLATFORM_CONTRACTID, &kNS_DOWNLOADPLATFORM_CID }, { NS_FIND_SERVICE_CONTRACTID, &kNS_FIND_SERVICE_CID }, { NS_TYPEAHEADFIND_CONTRACTID, &kNS_TYPEAHEADFIND_CID }, { NS_APPLICATION_REPUTATION_SERVICE_CONTRACTID, &kNS_APPLICATION_REPUTATION_SERVICE_CID }, { NS_LOGIN_REPUTATION_SERVICE_CONTRACTID, &kNS_LOGIN_REPUTATION_SERVICE_CID }, { NS_URLCLASSIFIERPREFIXSET_CONTRACTID, &kNS_URLCLASSIFIERPREFIXSET_CID }, { NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID }, { NS_URICLASSIFIERSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID },
deleted file mode 100644 --- a/toolkit/components/downloads/moz.build +++ /dev/null @@ -1,25 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -with Files('*'): - BUG_COMPONENT = ('Toolkit', 'Download Manager') - -XPIDL_SOURCES += [ - 'nsIDownload.idl', - 'nsIDownloadManager.idl', - 'nsIDownloadManagerUI.idl', - 'nsIDownloadProgressListener.idl', -] - -XPIDL_MODULE = 'downloads' - -UNIFIED_SOURCES += [ - 'nsDownloadManager.cpp' -] - -FINAL_LIBRARY = 'xul' - -CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644 --- a/toolkit/components/downloads/nsDownloadManager.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsIPrefService.h" -#include "nsIPropertyBag2.h" -#include "nsCExternalHandlerService.h" -#include "nsDirectoryServiceDefs.h" -#include "nsDownloadManager.h" - -#include "mozilla/Services.h" - -using namespace mozilla; - -#define DOWNLOAD_MANAGER_BUNDLE "chrome://mozapps/locale/downloads/downloads.properties" - -#define NS_SYSTEMINFO_CONTRACTID "@mozilla.org/system-info;1" - -//////////////////////////////////////////////////////////////////////////////// -//// nsDownloadManager - -NS_IMPL_ISUPPORTS( - nsDownloadManager -, nsIDownloadManager -) - -nsDownloadManager *nsDownloadManager::gDownloadManagerService = nullptr; - -already_AddRefed<nsDownloadManager> -nsDownloadManager::GetSingleton() -{ - if (gDownloadManagerService) { - return do_AddRef(gDownloadManagerService); - } - - auto serv = MakeRefPtr<nsDownloadManager>(); - // Note: This is cleared in the nsDownloadManager constructor. - gDownloadManagerService = serv.get(); - if (NS_SUCCEEDED(serv->Init())) { - return serv.forget(); - } - return nullptr; -} - -nsDownloadManager::~nsDownloadManager() -{ - MOZ_ASSERT(gDownloadManagerService == this); - gDownloadManagerService = nullptr; -} - -nsresult -nsDownloadManager::Init() -{ - nsresult rv; - - nsCOMPtr<nsIStringBundleService> bundleService = - mozilla::services::GetStringBundleService(); - if (!bundleService) - return NS_ERROR_FAILURE; - - rv = bundleService->CreateBundle(DOWNLOAD_MANAGER_BUNDLE, - getter_AddRefs(mBundle)); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; -} - -//////////////////////////////////////////////////////////////////////////////// -//// nsIDownloadManager - -NS_IMETHODIMP -nsDownloadManager::GetActivePrivateDownloadCount(int32_t* aResult) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetActiveDownloadCount(int32_t *aResult) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetActiveDownloads(nsISimpleEnumerator **aResult) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetActivePrivateDownloads(nsISimpleEnumerator **aResult) -{ - return NS_ERROR_UNEXPECTED; -} - -/** - * For platforms where helper apps use the downloads directory (i.e. mobile), - * this should be kept in sync with nsExternalHelperAppService.cpp - */ -NS_IMETHODIMP -nsDownloadManager::GetDefaultDownloadsDirectory(nsIFile **aResult) -{ - nsCOMPtr<nsIFile> downloadDir; - - nsresult rv; - nsCOMPtr<nsIProperties> dirService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - // OSX 10.4: - // Desktop - // OSX 10.5: - // User download directory - // Vista: - // Downloads - // XP/2K: - // My Documents/Downloads - // Linux: - // XDG user dir spec, with a fallback to Home/Downloads - - nsAutoString folderName; - mBundle->GetStringFromName("downloadsFolder", folderName); - -#if defined (XP_MACOSX) - rv = dirService->Get(NS_OSX_DEFAULT_DOWNLOAD_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); -#elif defined(XP_WIN) - rv = dirService->Get(NS_WIN_DEFAULT_DOWNLOAD_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); - - // Check the os version - nsCOMPtr<nsIPropertyBag2> infoService = - do_GetService(NS_SYSTEMINFO_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - int32_t version; - NS_NAMED_LITERAL_STRING(osVersion, "version"); - rv = infoService->GetPropertyAsInt32(osVersion, &version); - NS_ENSURE_SUCCESS(rv, rv); - if (version < 6) { // XP/2K - // First get "My Documents" - rv = dirService->Get(NS_WIN_PERSONAL_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = downloadDir->Append(folderName); - NS_ENSURE_SUCCESS(rv, rv); - - // This could be the first time we are creating the downloads folder in My - // Documents, so make sure it exists. - bool exists; - rv = downloadDir->Exists(&exists); - NS_ENSURE_SUCCESS(rv, rv); - if (!exists) { - rv = downloadDir->Create(nsIFile::DIRECTORY_TYPE, 0755); - NS_ENSURE_SUCCESS(rv, rv); - } - } -#elif defined(XP_UNIX) -#if defined(MOZ_WIDGET_ANDROID) - // Android doesn't have a $HOME directory, and by default we only have - // write access to /data/data/org.mozilla.{$APP} and /sdcard - char* downloadDirPath = getenv("DOWNLOADS_DIRECTORY"); - if (downloadDirPath) { - rv = NS_NewNativeLocalFile(nsDependentCString(downloadDirPath), - true, getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); - } - else { - rv = NS_ERROR_FAILURE; - } -#else - rv = dirService->Get(NS_UNIX_DEFAULT_DOWNLOAD_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(downloadDir)); - // fallback to Home/Downloads - if (NS_FAILED(rv)) { - rv = dirService->Get(NS_UNIX_HOME_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); - rv = downloadDir->Append(folderName); - NS_ENSURE_SUCCESS(rv, rv); - } -#endif -#else - rv = dirService->Get(NS_OS_HOME_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); - rv = downloadDir->Append(folderName); - NS_ENSURE_SUCCESS(rv, rv); -#endif - - downloadDir.forget(aResult); - - return NS_OK; -} - -#define NS_BRANCH_DOWNLOAD "browser.download." -#define NS_PREF_FOLDERLIST "folderList" -#define NS_PREF_DIR "dir" - -NS_IMETHODIMP -nsDownloadManager::GetUserDownloadsDirectory(nsIFile **aResult) -{ - nsresult rv; - nsCOMPtr<nsIProperties> dirService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIPrefService> prefService = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIPrefBranch> prefBranch; - rv = prefService->GetBranch(NS_BRANCH_DOWNLOAD, - getter_AddRefs(prefBranch)); - NS_ENSURE_SUCCESS(rv, rv); - - int32_t val; - rv = prefBranch->GetIntPref(NS_PREF_FOLDERLIST, - &val); - NS_ENSURE_SUCCESS(rv, rv); - - switch(val) { - case 0: // Desktop - { - nsCOMPtr<nsIFile> downloadDir; - rv = dirService->Get(NS_OS_DESKTOP_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(downloadDir)); - NS_ENSURE_SUCCESS(rv, rv); - downloadDir.forget(aResult); - return NS_OK; - } - break; - case 1: // Downloads - return GetDefaultDownloadsDirectory(aResult); - case 2: // Custom - { - nsCOMPtr<nsIFile> customDirectory; - prefBranch->GetComplexValue(NS_PREF_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(customDirectory)); - if (customDirectory) { - bool exists = false; - (void)customDirectory->Exists(&exists); - - if (!exists) { - rv = customDirectory->Create(nsIFile::DIRECTORY_TYPE, 0755); - if (NS_SUCCEEDED(rv)) { - customDirectory.forget(aResult); - return NS_OK; - } - - // Create failed, so it still doesn't exist. Fall out and get the - // default downloads directory. - } - - bool writable = false; - bool directory = false; - (void)customDirectory->IsWritable(&writable); - (void)customDirectory->IsDirectory(&directory); - - if (exists && writable && directory) { - customDirectory.forget(aResult); - return NS_OK; - } - } - rv = GetDefaultDownloadsDirectory(aResult); - if (NS_SUCCEEDED(rv)) { - (void)prefBranch->SetComplexValue(NS_PREF_DIR, - NS_GET_IID(nsIFile), - *aResult); - } - return rv; - } - break; - } - return NS_ERROR_INVALID_ARG; -} - -NS_IMETHODIMP -nsDownloadManager::AddDownload(int16_t aDownloadType, - nsIURI *aSource, - nsIURI *aTarget, - const nsAString& aDisplayName, - nsIMIMEInfo *aMIMEInfo, - PRTime aStartTime, - nsIFile *aTempFile, - nsICancelable *aCancelable, - bool aIsPrivate, - nsIDownload **aDownload) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetDownload(uint32_t aID, nsIDownload **aDownloadItem) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetDownloadByGUID(const nsACString& aGUID, - nsIDownloadManagerResult* aCallback) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::CancelDownload(uint32_t aID) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::RetryDownload(uint32_t aID) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::RemoveDownload(uint32_t aID) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::RemoveDownloadsByTimeframe(int64_t aStartTime, - int64_t aEndTime) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::CleanUp() -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::CleanUpPrivate() -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetCanCleanUp(bool *aResult) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetCanCleanUpPrivate(bool *aResult) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::PauseDownload(uint32_t aID) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::ResumeDownload(uint32_t aID) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetDBConnection(mozIStorageConnection **aDBConn) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::GetPrivateDBConnection(mozIStorageConnection **aDBConn) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::AddListener(nsIDownloadProgressListener *aListener) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::AddPrivacyAwareListener(nsIDownloadProgressListener *aListener) -{ - return NS_ERROR_UNEXPECTED; -} - -NS_IMETHODIMP -nsDownloadManager::RemoveListener(nsIDownloadProgressListener *aListener) -{ - return NS_ERROR_UNEXPECTED; -}
deleted file mode 100644 --- a/toolkit/components/downloads/nsDownloadManager.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef downloadmanager___h___ -#define downloadmanager___h___ - -#include "nsIDownloadManager.h" -#include "nsIDownloadProgressListener.h" -#include "nsIFile.h" -#include "nsIStringBundle.h" -#include "nsISupportsPrimitives.h" -#include "nsString.h" - -class nsDownloadManager final : public nsIDownloadManager -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIDOWNLOADMANAGER - - nsresult Init(); - - static already_AddRefed<nsDownloadManager> GetSingleton(); - - nsDownloadManager() - { - } - -protected: - virtual ~nsDownloadManager(); - -private: - nsCOMPtr<nsIStringBundle> mBundle; - - static nsDownloadManager *gDownloadManagerService; -}; - -#endif
deleted file mode 100644 --- a/toolkit/components/downloads/nsIDownload.idl +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsITransfer.idl" - -interface nsIURI; -interface nsIFile; -interface nsIObserver; -interface nsICancelable; -interface nsIWebProgressListener; -interface nsIMIMEInfo; - -/** - * Represents a download object. - * - * @note This object is no longer updated once it enters a completed state. - * Completed states are the following: - * nsIDownloadManager::DOWNLOAD_FINISHED - * nsIDownloadManager::DOWNLOAD_FAILED - * nsIDownloadManager::DOWNLOAD_CANCELED - * nsIDownloadManager::DOWNLOAD_BLOCKED_PARENTAL - * nsIDownloadManager::DOWNLOAD_DIRTY - * nsIDownloadManager::DOWNLOAD_BLOCKED_POLICY - */ -[scriptable, uuid(2258f465-656e-4566-87cb-f791dbaf0322)] -interface nsIDownload : nsITransfer { - - /** - * The target of a download is always a file on the local file system. - */ - readonly attribute nsIFile targetFile; - - /** - * The percentage of transfer completed. - * If the file size is unknown it'll be -1 here. - */ - readonly attribute long percentComplete; - - /** - * The amount of bytes downloaded so far. - */ - readonly attribute long long amountTransferred; - - /** - * The size of file in bytes. - * Unknown size is represented by -1. - */ - readonly attribute long long size; - - /** - * The source of the transfer. - */ - readonly attribute nsIURI source; - - /** - * The target of the transfer. - */ - readonly attribute nsIURI target; - - /** - * Object that can be used to cancel the download. - * Will be null after the download is finished. - */ - readonly attribute nsICancelable cancelable; - - /** - * The user-readable description of the transfer. - */ - readonly attribute AString displayName; - - /** - * The time a transfer was started. - */ - readonly attribute long long startTime; - - /** - * The speed of the transfer in bytes/sec. - */ - readonly attribute double speed; - - /** - * Optional. If set, it will contain the target's relevant MIME information. - * This includes its MIME Type, helper app, and whether that helper should be - * executed. - */ - readonly attribute nsIMIMEInfo MIMEInfo; - - /** - * The id of the download that is stored in the database - not globally unique. - * For example, a private download and a public one might have identical ids. - * Can only be safely used for direct database manipulation in the database that - * contains this download. Use the guid property instead for safe, database-agnostic - * searching and manipulation. - * - * @deprecated - */ - readonly attribute unsigned long id; - - /** - * The guid of the download that is stored in the database. - * Has the form of twelve alphanumeric characters. - */ - readonly attribute ACString guid; - - /** - * The state of the download. - * @see nsIDownloadManager and nsIXPInstallManagerUI - */ - readonly attribute short state; - - /** - * The referrer uri of the download. This is only valid for HTTP downloads, - * and can be null. - */ - readonly attribute nsIURI referrer; - - /** - * Indicates if the download can be resumed after being paused or not. This - * is only the case if the download is over HTTP/1.1 or FTP and if the - * server supports it. - */ - readonly attribute boolean resumable; - - /** - * Indicates if the download was initiated from a context marked as private, - * controlling whether it should be stored in a permanent manner or not. - */ - readonly attribute boolean isPrivate; - - /** - * Cancel this download if it's currently in progress. - */ - void cancel(); - - /** - * Pause this download if it is in progress. - * - * @throws NS_ERROR_UNEXPECTED if it cannot be paused. - */ - void pause(); - - /** - * Resume this download if it is paused. - * - * @throws NS_ERROR_UNEXPECTED if it cannot be resumed or is not paused. - */ - void resume(); - - /** - * Instruct the download manager to remove this download. Whereas - * cancel simply cancels the transfer, but retains information about it, - * remove removes all knowledge of it. - * - * @see nsIDownloadManager.removeDownload for more detail - * @throws NS_ERROR_FAILURE if the download is active. - */ - void remove(); - - /** - * Instruct the download manager to retry this failed download - * @throws NS_ERROR_NOT_AVAILABLE if the download is not known. - * @throws NS_ERROR_FAILURE if the download is not in the following states: - * nsIDownloadManager::DOWNLOAD_CANCELED - * nsIDownloadManager::DOWNLOAD_FAILED - */ - void retry(); -}; - -%{C++ -// {b02be33b-d47c-4bd3-afd9-402a942426b0} -#define NS_DOWNLOAD_CID \ - { 0xb02be33b, 0xd47c, 0x4bd3, { 0xaf, 0xd9, 0x40, 0x2a, 0x94, 0x24, 0x26, 0xb0 } } -%}
deleted file mode 100644 --- a/toolkit/components/downloads/nsIDownloadManager.idl +++ /dev/null @@ -1,358 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// Keeps track of ongoing downloads, in the form of nsIDownload's. - -#include "nsISupports.idl" - -interface nsIURI; -interface nsIFile; -interface nsIDownload; -interface nsICancelable; -interface nsIMIMEInfo; -interface nsIDownloadProgressListener; -interface nsISimpleEnumerator; -interface mozIStorageConnection; - -[scriptable, function, uuid(0c07ffeb-791b-49f3-ae38-2c331fd55a52)] -interface nsIDownloadManagerResult : nsISupports { - /** - * Process an asynchronous result from getDownloadByGUID. - * - * @param aStatus The result code of the operation: - * * NS_OK: an item was found. No other success values are returned. - * * NS_ERROR_NOT_AVAILABLE: no such item was found. - * * Other error values are possible, but less well-defined. - */ - void handleResult(in nsresult aStatus, in nsIDownload aDownload); -}; - -[scriptable, uuid(b29aac15-7ec4-4ab3-a53b-08f78aed3b34)] -interface nsIDownloadManager : nsISupports { - /** - * Download type for generic file download. - */ - const short DOWNLOAD_TYPE_DOWNLOAD = 0; - - /** - * Download state for uninitialized download object. - */ - const short DOWNLOAD_NOTSTARTED = -1; - - /** - * Download is currently transferring data. - */ - const short DOWNLOAD_DOWNLOADING = 0; - - /** - * Download completed including any processing of the target - * file. (completed) - */ - const short DOWNLOAD_FINISHED = 1; - - /** - * Transfer failed due to error. (completed) - */ - const short DOWNLOAD_FAILED = 2; - - /** - * Download was canceled by the user. (completed) - */ - const short DOWNLOAD_CANCELED = 3; - - /** - * Transfer was paused by the user. - */ - const short DOWNLOAD_PAUSED = 4; - - /** - * Download is active but data has not yet been received. - */ - const short DOWNLOAD_QUEUED = 5; - - /** - * Transfer request was blocked by parental controls proxies. (completed) - */ - const short DOWNLOAD_BLOCKED_PARENTAL = 6; - - /** - * Transferred download is being scanned by virus scanners. - */ - const short DOWNLOAD_SCANNING = 7; - - /** - * A virus was detected in the download. The target will most likely - * no longer exist. (completed) - */ - const short DOWNLOAD_DIRTY = 8; - - /** - * Win specific: Request was blocked by zone policy settings. - * (see bug #416683) (completed) - */ - const short DOWNLOAD_BLOCKED_POLICY = 9; - - - /** - * Creates an nsIDownload and adds it to be managed by the download manager. - * - * @param aSource The source URI of the transfer. Must not be null. - * - * @param aTarget The target URI of the transfer. Must not be null. - * - * @param aDisplayName The user-readable description of the transfer. - * Can be empty. - * - * @param aMIMEInfo The MIME info associated with the target, - * including MIME type and helper app when appropriate. - * This parameter is optional. - * - * @param startTime Time when the download started - * - * @param aTempFile The location of a temporary file; i.e. a file in which - * the received data will be stored, but which is not - * equal to the target file. (will be moved to the real - * target by the DownloadManager, when the download is - * finished). This will be null for all callers except for - * nsExternalHelperAppHandler. Addons should generally pass - * null for aTempFile. This will be moved to the real target - * by the download manager when the download is finished, - * and the action indicated by aMIMEInfo will be executed. - * - * @param aCancelable An object that can be used to abort the download. - * Must not be null. - * - * @param aIsPrivate Used to determine the privacy status of the new download. - * If true, the download is stored in a manner that leaves - * no permanent trace outside of the current private session. - * - * @return The newly created download item with the passed-in properties. - * - * @note This does not actually start a download. If you want to add and - * start a download, you need to create an nsIWebBrowserPersist, pass it - * as the aCancelable object, call this method, set the progressListener - * as the returned download object, then call saveURI. - */ - nsIDownload addDownload(in short aDownloadType, - in nsIURI aSource, - in nsIURI aTarget, - in AString aDisplayName, - in nsIMIMEInfo aMIMEInfo, - in PRTime aStartTime, - in nsIFile aTempFile, - in nsICancelable aCancelable, - in boolean aIsPrivate); - - /** - * Retrieves a download managed by the download manager. This can be one that - * is in progress, or one that has completed in the past and is stored in the - * database. - * - * @param aID The unique ID of the download. - * @return The download with the specified ID. - * @throws NS_ERROR_NOT_AVAILABLE if the download is not in the database. - */ - nsIDownload getDownload(in unsigned long aID); - - /** - * Retrieves a download managed by the download manager. This can be one that - * is in progress, or one that has completed in the past and is stored in the - * database. The result of this method is returned via an asynchronous callback, - * the parameter of which will be an nsIDownload object, or null if none exists - * with the provided GUID. - * - * @param aGUID The unique GUID of the download. - * @param aCallback The callback to invoke with the result of the search. - */ - void getDownloadByGUID(in ACString aGUID, in nsIDownloadManagerResult aCallback); - - /** - * Cancels the download with the specified ID if it's currently in-progress. - * This calls cancel(NS_BINDING_ABORTED) on the nsICancelable provided by the - * download. - * - * @param aID The unique ID of the download. - * @throws NS_ERROR_FAILURE if the download is not in-progress. - */ - void cancelDownload(in unsigned long aID); - - /** - * Removes the download with the specified id if it's not currently - * in-progress. Whereas cancelDownload simply cancels the transfer, but - * retains information about it, removeDownload removes all knowledge of it. - * - * Also notifies observers of the "download-manager-remove-download-guid" - * topic with the download guid as the subject to allow any DM consumers to - * react to the removal. - * - * Also may notify observers of the "download-manager-remove-download" topic - * with the download id as the subject, if the download removed is public - * or if global private browsing mode is in use. This notification is deprecated; - * the guid notification should be relied upon instead. - * - * @param aID The unique ID of the download. - * @throws NS_ERROR_FAILURE if the download is active. - */ - void removeDownload(in unsigned long aID); - - /** - * Removes all inactive downloads that were started inclusively within the - * specified time frame. - * - * @param aBeginTime - * The start time to remove downloads by in microseconds. - * @param aEndTime - * The end time to remove downloads by in microseconds. - */ - void removeDownloadsByTimeframe(in long long aBeginTime, - in long long aEndTime); - - /** - * Pause the specified download. - * - * @param aID The unique ID of the download. - * @throws NS_ERROR_FAILURE if the download is not in-progress. - */ - void pauseDownload(in unsigned long aID); - - /** - * Resume the specified download. - * - * @param aID The unique ID of the download. - * @throws NS_ERROR_FAILURE if the download is not in-progress. - */ - void resumeDownload(in unsigned long aID); - - /** - * Retries a failed download. - * - * @param aID The unique ID of the download. - * @throws NS_ERROR_NOT_AVAILALE if the download id is not known. - * @throws NS_ERROR_FAILURE if the download is not in the following states: - * nsIDownloadManager::DOWNLOAD_CANCELED - * nsIDownloadManager::DOWNLOAD_FAILED - */ - void retryDownload(in unsigned long aID); - - /** - * The database connection to the downloads database. - */ - readonly attribute mozIStorageConnection DBConnection; - readonly attribute mozIStorageConnection privateDBConnection; - - /** - * Whether or not there are downloads that can be cleaned up (removed) - * i.e. downloads that have completed, have failed or have been canceled. - * In global private browsing mode, this reports the status of the relevant - * private or public downloads. In per-window mode, it only reports for - * public ones. - */ - readonly attribute boolean canCleanUp; - - /** - * Whether or not there are private downloads that can be cleaned up (removed) - * i.e. downloads that have completed, have failed or have been canceled. - */ -readonly attribute boolean canCleanUpPrivate; - - /** - * Removes completed, failed, and canceled downloads from the list. - * In global private browsing mode, this operates on the relevant - * private or public downloads. In per-window mode, it only operates - * on public ones. - * - * Also notifies observers of the "download-manager-remove-download-gui" - * and "download-manager-remove-download" topics with a null subject to - * allow any DM consumers to react to the removals. - */ - void cleanUp(); - - /** - * Removes completed, failed, and canceled downloads from the list - * of private downloads. - * - * Also notifies observers of the "download-manager-remove-download-gui" - * and "download-manager-remove-download" topics with a null subject to - * allow any DM consumers to react to the removals. - */ -void cleanUpPrivate(); - - /** - * The number of files currently being downloaded. - * - * In global private browsing mode, this reports the status of the relevant - * private or public downloads. In per-window mode, it only reports public - * ones. - */ - readonly attribute long activeDownloadCount; - - /** - * The number of private files currently being downloaded. - */ - readonly attribute long activePrivateDownloadCount; - - /** - * An enumeration of active nsIDownloads - * - * In global private browsing mode, this reports the status of the relevant - * private or public downloads. In per-window mode, it only reports public - * ones. - */ - readonly attribute nsISimpleEnumerator activeDownloads; - - /** - * An enumeration of active private nsIDownloads - */ - readonly attribute nsISimpleEnumerator activePrivateDownloads; - - /** - * Adds a listener to the download manager. It is expected that this - * listener will only access downloads via their deprecated integer id attribute, - * and when global private browsing compatibility mode is disabled, this listener - * will receive no notifications for downloads marked private. - */ - void addListener(in nsIDownloadProgressListener aListener); - - /** - * Adds a listener to the download manager. This listener must be able to - * understand and use the guid attribute of downloads for all interactions - * with the download manager. - */ - void addPrivacyAwareListener(in nsIDownloadProgressListener aListener); - - /** - * Removes a listener from the download manager. - */ - void removeListener(in nsIDownloadProgressListener aListener); - - /** - * Returns the platform default downloads directory. - */ - readonly attribute nsIFile defaultDownloadsDirectory; - - /** - * Returns the user configured downloads directory. - * The path is dependent on two user configurable prefs - * set in preferences: - * - * browser.download.folderList - * Indicates the location users wish to save downloaded - * files too. - * Values: - * 0 - The desktop is the default download location. - * 1 - The system's downloads folder is the default download location. - * 2 - The default download location is elsewhere as specified in - * browser.download.dir. If invalid, userDownloadsDirectory - * will fallback on defaultDownloadsDirectory. - * - * browser.download.dir - - * A local path the user may have selected at some point - * where downloaded files are saved. The use of which is - * enabled when folderList equals 2. - */ - readonly attribute nsIFile userDownloadsDirectory; -}; - -
deleted file mode 100644 --- a/toolkit/components/downloads/nsIDownloadManagerUI.idl +++ /dev/null @@ -1,55 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" -interface nsIInterfaceRequestor; -interface nsIDownload; - -[scriptable, uuid(0c76d4cf-0b06-4c1a-9bea-520c7bbdba99)] -interface nsIDownloadManagerUI : nsISupports { - /** - * The reason that should be passed when the user requests to show the - * download manager's UI. - */ - const short REASON_USER_INTERACTED = 0; - - /** - * The reason that should be passed to the show method when we are displaying - * the UI because a new download is being added to it. - */ - const short REASON_NEW_DOWNLOAD = 1; - - /** - * Shows the Download Manager's UI to the user. - * - * @param [optional] aWindowContext - * The parent window context to show the UI. - * @param [optional] aDownload - * The download to be preselected upon opening. - * @param [optional] aReason - * The reason to show the download manager's UI. This defaults to - * REASON_USER_INTERACTED, and should be one of the previously listed - * constants. - * @param [optional] aUsePrivateUI - * Pass true as this argument to hint to the implementation that it - * should only display private downloads in the UI, if possible. - */ - void show([optional] in nsIInterfaceRequestor aWindowContext, - [optional] in nsIDownload aDownload, - [optional] in short aReason, - [optional] in boolean aUsePrivateUI); - - /** - * Indicates if the UI is visible or not. - */ - readonly attribute boolean visible; - - /** - * Brings attention to the UI if it is already visible - * - * @throws NS_ERROR_UNEXPECTED if the UI is not visible. - */ - void getAttention(); -}; -
deleted file mode 100644 --- a/toolkit/components/downloads/nsIDownloadProgressListener.idl +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A minimally extended progress listener used by download manager - * to update its default UI. This is implemented in nsDownloadProgressListener.js. - * See nsIWebProgressListener for documentation, and use its constants. This isn't - * too pretty, but the alternative is having this extend nsIWebProgressListener and - * adding an |item| attribute, which would mean a separate nsIDownloadProgressListener - * for every nsIDownloadItem, which is a waste... - */ - -#include "nsISupports.idl" - -interface nsIWebProgress; -interface nsIRequest; -interface nsIURI; -interface nsIDownload; -interface nsIDOMDocument; - -[scriptable, uuid(7acb07ea-cac2-4c15-a3ad-23aaa789ed51)] -interface nsIDownloadProgressListener : nsISupports { - - /** - * document - * The document of the download manager frontend. - */ - - attribute nsIDOMDocument document; - - /** - * Dispatched whenever the state of the download changes. - * - * @param aState The previous download sate. - * @param aDownload The download object. - * @see nsIDownloadManager for download states. - */ - void onDownloadStateChange(in short aState, in nsIDownload aDownload); - - void onStateChange(in nsIWebProgress aWebProgress, - in nsIRequest aRequest, - in unsigned long aStateFlags, - in nsresult aStatus, - in nsIDownload aDownload); - - void onProgressChange(in nsIWebProgress aWebProgress, - in nsIRequest aRequest, - in long long aCurSelfProgress, - in long long aMaxSelfProgress, - in long long aCurTotalProgress, - in long long aMaxTotalProgress, - in nsIDownload aDownload); - - void onSecurityChange(in nsIWebProgress aWebProgress, - in nsIRequest aRequest, - in unsigned long aState, - in nsIDownload aDownload); - -};
--- a/toolkit/components/moz.build +++ b/toolkit/components/moz.build @@ -24,17 +24,16 @@ DIRS += [ 'browser', 'cloudstorage', 'commandlines', 'contentprefs', 'contextualidentity', 'crashes', 'crashmonitor', 'diskspacewatcher', - 'downloads', 'enterprisepolicies', 'extensions', 'filewatcher', 'finalizationwitness', 'find', 'jsdownloads', 'jsoncpp/src/lib_json', 'lz4',
--- a/toolkit/modules/Services.jsm +++ b/toolkit/modules/Services.jsm @@ -71,17 +71,16 @@ XPCOMUtils.defineLazyGetter(Services, "i var initTable = { appShell: ["@mozilla.org/appshell/appShellService;1", "nsIAppShellService"], cache: ["@mozilla.org/network/cache-service;1", "nsICacheService"], cache2: ["@mozilla.org/netwerk/cache-storage-service;1", "nsICacheStorageService"], cpmm: ["@mozilla.org/childprocessmessagemanager;1", "nsIMessageSender"], console: ["@mozilla.org/consoleservice;1", "nsIConsoleService"], cookies: ["@mozilla.org/cookiemanager;1", "nsICookieManager"], - downloads: ["@mozilla.org/download-manager;1", "nsIDownloadManager"], droppedLinkHandler: ["@mozilla.org/content/dropped-link-handler;1", "nsIDroppedLinkHandler"], els: ["@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"], eTLD: ["@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService"], intl: ["@mozilla.org/mozintl;1", "mozIMozIntl"], locale: ["@mozilla.org/intl/localeservice;1", "mozILocaleService"], logins: ["@mozilla.org/login-manager;1", "nsILoginManager"], obs: ["@mozilla.org/observer-service;1", "nsIObserverService"], perms: ["@mozilla.org/permissionmanager;1", "nsIPermissionManager"],
--- a/toolkit/modules/tests/xpcshell/test_Services.js +++ b/toolkit/modules/tests/xpcshell/test_Services.js @@ -28,17 +28,16 @@ function run_test() { checkService("cache2", Ci.nsICacheStorageService); checkService("clipboard", Ci.nsIClipboard); checkService("console", Ci.nsIConsoleService); checkService("cookies", Ci.nsICookieManager); checkService("dirsvc", Ci.nsIDirectoryService); checkService("dirsvc", Ci.nsIProperties); checkService("DOMRequest", Ci.nsIDOMRequestService); checkService("domStorageManager", Ci.nsIDOMStorageManager); - checkService("downloads", Ci.nsIDownloadManager); checkService("droppedLinkHandler", Ci.nsIDroppedLinkHandler); checkService("eTLD", Ci.nsIEffectiveTLDService); checkService("focus", Ci.nsIFocusManager); checkService("io", Ci.nsIIOService); checkService("intl", Ci.mozIMozIntl); checkService("locale", Ci.mozILocaleService); checkService("logins", Ci.nsILoginManager); checkService("obs", Ci.nsIObserverService);
deleted file mode 100644 index 82ec7afe137ad82e6330df40291afb2ae665d2c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@<O00001
--- a/toolkit/themes/linux/mozapps/jar.mn +++ b/toolkit/themes/linux/mozapps/jar.mn @@ -1,15 +1,14 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. toolkit.jar: #include ../../shared/mozapps.inc.mn - skin/classic/mozapps/downloads/downloadIcon.png (downloads/downloadIcon.png) * skin/classic/mozapps/extensions/extensions.css (extensions/extensions.css) * skin/classic/mozapps/extensions/newaddon.css (extensions/newaddon.css) skin/classic/mozapps/extensions/heart.png (extensions/heart.png) skin/classic/mozapps/profile/profileicon.png (profile/profileicon.png) skin/classic/mozapps/update/updates.css (update/updates.css) #if MOZ_BUILD_APP == browser [browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
deleted file mode 100644 index 1d5cedd0ae72b39c1b7f5458272e406439676b8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@<O00001
--- a/toolkit/themes/osx/mozapps/jar.mn +++ b/toolkit/themes/osx/mozapps/jar.mn @@ -1,16 +1,15 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. toolkit.jar: #include ../../shared/mozapps.inc.mn skin/classic/mozapps/downloads/buttons.png (downloads/buttons.png) - skin/classic/mozapps/downloads/downloadIcon.png (downloads/downloadIcon.png) skin/classic/mozapps/downloads/unknownContentType.css (downloads/unknownContentType.css) skin/classic/mozapps/extensions/discover-logo.png (extensions/discover-logo.png) skin/classic/mozapps/extensions/rating-won.png (extensions/rating-won.png) skin/classic/mozapps/extensions/rating-not-won.png (extensions/rating-not-won.png) skin/classic/mozapps/extensions/cancel.png (extensions/cancel.png) skin/classic/mozapps/extensions/toolbarbutton-dropmarker.png (extensions/toolbarbutton-dropmarker.png) skin/classic/mozapps/extensions/heart.png (extensions/heart.png) skin/classic/mozapps/extensions/about.css (extensions/about.css)
deleted file mode 100644 index 870ea9eb62914636706aed221d4b630870edbe52..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@<O00001
--- a/toolkit/themes/windows/mozapps/jar.mn +++ b/toolkit/themes/windows/mozapps/jar.mn @@ -1,15 +1,14 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. toolkit.jar: #include ../../shared/mozapps.inc.mn - skin/classic/mozapps/downloads/downloadIcon.png (downloads/downloadIcon.png) * skin/classic/mozapps/extensions/extensions.css (extensions/extensions.css) skin/classic/mozapps/extensions/heart.png (extensions/heart.png) * skin/classic/mozapps/extensions/newaddon.css (extensions/newaddon.css) skin/classic/mozapps/profile/profileicon.png (profile/profileicon.png) skin/classic/mozapps/update/updates.css (update/updates.css) #if MOZ_BUILD_APP == browser [browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar: