Backed out 2 changesets (bug 1672431) for causing bustages in IOUtils.cpp

CLOSED TREE

Backed out changeset 9d117ef49249 (bug 1672431)
Backed out changeset fa79148301f5 (bug 1672431)
This commit is contained in:
Alexandru Michis 2021-03-10 06:32:41 +02:00
Родитель a01b2fd470
Коммит 62a9d11677
4 изменённых файлов: 626 добавлений и 888 удалений

Просмотреть файл

@ -206,12 +206,6 @@ namespace IOUtils {
Promise<boolean> exists(DOMString path);
};
[Exposed=Window]
partial namespace IOUtils {
[Throws]
readonly attribute any profileBeforeChange;
};
/**
* Options to be passed to the |IOUtils.readUTF8| method.
*/

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -14,14 +14,12 @@
#include "mozilla/DataMutex.h"
#include "mozilla/MozPromise.h"
#include "mozilla/Result.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/IOUtilsBinding.h"
#include "mozilla/dom/TypedArray.h"
#include "nsIAsyncShutdown.h"
#include "nsISerialEventTarget.h"
#include "nsPrintfCString.h"
#include "nsProxyRelease.h"
#include "nsString.h"
#include "nsStringFwd.h"
#include "nsTArray.h"
@ -121,10 +119,6 @@ class IOUtils final {
static already_AddRefed<Promise> Exists(GlobalObject& aGlobal,
const nsAString& aPath);
static void GetProfileBeforeChange(GlobalObject& aGlobal,
JS::MutableHandle<JS::Value>,
ErrorResult& aRv);
class JsBuffer;
/**
@ -148,20 +142,27 @@ class IOUtils final {
struct InternalFileInfo;
struct InternalWriteOpts;
class MozLZ4;
class EventQueue;
class State;
/**
* Dispatch a task on the event queue and resolve or reject the associated
* promise based on the result.
*
* @param aPromise The promise corresponding to the task running on the event
* queue.
* @param aFunc The task to run.
*/
static StaticDataMutex<StaticRefPtr<nsISerialEventTarget>>
sBackgroundEventTarget;
static StaticRefPtr<nsIAsyncShutdownClient> sBarrier;
static Atomic<bool> sShutdownStarted;
template <typename OkT, typename Fn, typename... Args>
static RefPtr<IOUtils::IOPromise<OkT>> InvokeToIOPromise(Fn aFunc,
Args... aArgs);
static already_AddRefed<nsIAsyncShutdownClient> GetShutdownBarrier();
static already_AddRefed<nsISerialEventTarget> GetBackgroundEventTarget();
static void SetShutdownHooks();
template <typename OkT, typename Fn>
static void DispatchAndResolve(EventQueue* aQueue, Promise* aPromise,
Fn aFunc);
static RefPtr<IOPromise<OkT>> RunOnBackgroundThread(Fn aFunc);
template <typename OkT, typename Fn>
static void RunOnBackgroundThreadAndResolve(Promise* aPromise, Fn aFunc);
/**
* Creates a new JS Promise.
@ -175,6 +176,16 @@ class IOUtils final {
const InternalFileInfo& aInternalFileInfo,
JS::MutableHandle<JS::Value> aValue);
/**
* Resolves |aPromise| with an appropriate JS value for |aValue|.
*/
template <typename T>
static void ResolveJSPromise(Promise* aPromise, T&& aValue);
/**
* Rejects |aPromise| with an appropriate |DOMException| describing |aError|.
*/
static void RejectJSPromise(Promise* aPromise, const IOError& aError);
/**
* Attempts to read the entire file at |aPath| into a buffer.
*
@ -358,80 +369,6 @@ class IOUtils final {
* @return Whether or not the file exists.
*/
static Result<bool, IOError> ExistsSync(nsIFile* aFile);
enum class EventQueueStatus {
Uninitialized,
Initialized,
Shutdown,
};
enum class ShutdownBlockerStatus {
Uninitialized,
Initialized,
Failed,
};
/**
* Internal IOUtils state.
*/
class State {
public:
StaticAutoPtr<EventQueue> mEventQueue;
EventQueueStatus mQueueStatus = EventQueueStatus::Uninitialized;
ShutdownBlockerStatus mBlockerStatus = ShutdownBlockerStatus::Uninitialized;
/**
* Set up shutdown hooks to free our internals at shutdown.
*
* NB: Must be called on main thread.
*/
void SetShutdownHooks();
};
using StateMutex = StaticDataMutex<State>;
/**
* Lock the state mutex and return a handle. If shutdown has not yet
* finished, the internals will be constructed if necessary.
*
* @returns A handle to the internal state, which can be used to retrieve the
* event queue.
* If |Some| is returned, |mEventQueue| is guaranteed to be
* initialized. If shutdown has finished, |Nothing| is returned.
*/
static Maybe<StateMutex::AutoLock> GetState();
static StateMutex sState;
};
/**
* The IOUtils event queue.
*/
class IOUtils::EventQueue final {
friend void IOUtils::State::SetShutdownHooks();
public:
EventQueue();
EventQueue(const EventQueue&) = delete;
EventQueue(EventQueue&&) = delete;
EventQueue& operator=(const EventQueue&) = delete;
EventQueue& operator=(EventQueue&&) = delete;
template <typename OkT, typename Fn>
RefPtr<IOPromise<OkT>> Dispatch(Fn aFunc);
Result<already_AddRefed<nsIAsyncShutdownClient>, nsresult>
GetProfileBeforeChangeClient();
Result<already_AddRefed<nsIAsyncShutdownBarrier>, nsresult>
GetProfileBeforeChangeBarrier();
private:
nsresult SetShutdownHooks();
nsCOMPtr<nsISerialEventTarget> mBackgroundEventTarget;
nsCOMPtr<nsIAsyncShutdownBarrier> mProfileBeforeChangeBarrier;
};
/**
@ -544,25 +481,13 @@ class IOUtils::MozLZ4 {
Span<const uint8_t> aFileContents, IOUtils::BufferKind);
};
class IOUtilsShutdownBlocker : public nsIAsyncShutdownBlocker,
public nsIAsyncShutdownCompletionCallback {
class IOUtilsShutdownBlocker : public nsIAsyncShutdownBlocker {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIASYNCSHUTDOWNBLOCKER
NS_DECL_NSIASYNCSHUTDOWNCOMPLETIONCALLBACK
enum Phase {
ProfileBeforeChange,
XpcomWillShutdown,
};
explicit IOUtilsShutdownBlocker(Phase aPhase) : mPhase(aPhase) {}
private:
virtual ~IOUtilsShutdownBlocker() = default;
Phase mPhase;
RefPtr<nsIAsyncShutdownClient> mParentClient;
};
/**

Просмотреть файл

@ -287,7 +287,7 @@ var ClientIDImpl = {
try {
await IOUtils.makeDirectory(gDatareportingPath);
} catch (ex) {
if (!(ex instanceof DOMException) || ex.name !== "AbortError") {
if (ex.name != "NotAllowedError") {
throw ex;
}
}