зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1346801 - No need to dispatch runnables to the main-thread for Entries API, r=qdot
This commit is contained in:
Родитель
a2f4a0ab3a
Коммит
e4d85e8db3
|
@ -72,15 +72,6 @@ public:
|
|||
bool
|
||||
GetRealPath(BlobImpl* aFile, nsIFile** aPath) const;
|
||||
|
||||
// IPC initialization
|
||||
// See how these 2 methods are used in FileSystemTaskChildBase.
|
||||
|
||||
virtual bool
|
||||
NeedToGoToMainThread() const { return false; }
|
||||
|
||||
virtual nsresult
|
||||
MainThreadWork() { return NS_ERROR_FAILURE; }
|
||||
|
||||
virtual bool
|
||||
ClonableToDifferentThreadOrProcess() const { return false; }
|
||||
|
||||
|
|
|
@ -256,12 +256,6 @@ FileSystemTaskParentBase::Start()
|
|||
AssertIsOnBackgroundThread();
|
||||
mFileSystem->AssertIsOnOwningThread();
|
||||
|
||||
if (NeedToGoToMainThread()) {
|
||||
DebugOnly<nsresult> rv = NS_DispatchToMainThread(this, NS_DISPATCH_NORMAL);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToCurrentThread failed");
|
||||
return;
|
||||
}
|
||||
|
||||
DebugOnly<nsresult> rv = DispatchToIOThread(this);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchToIOThread failed");
|
||||
}
|
||||
|
@ -305,52 +299,12 @@ FileSystemTaskParentBase::SetError(const nsresult& aErrorValue)
|
|||
mErrorValue = FileSystemErrorFromNsError(aErrorValue);
|
||||
}
|
||||
|
||||
bool
|
||||
FileSystemTaskParentBase::NeedToGoToMainThread() const
|
||||
{
|
||||
return mFileSystem->NeedToGoToMainThread();
|
||||
}
|
||||
|
||||
nsresult
|
||||
FileSystemTaskParentBase::MainThreadWork()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return mFileSystem->MainThreadWork();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileSystemTaskParentBase::Run()
|
||||
{
|
||||
// This method can run in 3 different threads. Here why:
|
||||
// 1. if we are on the main-thread it's because the task must do something
|
||||
// here. If no errors are returned we go the step 2.
|
||||
// 2. We can be here directly if the task doesn't have nothing to do on the
|
||||
// main-thread. We are are on the I/O thread and we call IOWork().
|
||||
// 3. Both step 1 (in case of error) and step 2 end up here where return the
|
||||
// value back to the PBackground thread.
|
||||
if (NS_IsMainThread()) {
|
||||
MOZ_ASSERT(NeedToGoToMainThread());
|
||||
|
||||
nsresult rv = MainThreadWork();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
SetError(rv);
|
||||
|
||||
// Something when wrong. Let's go to the Background thread directly
|
||||
// skipping the I/O thread step.
|
||||
rv = mBackgroundEventTarget->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Next step must happen on the I/O thread.
|
||||
rv = DispatchToIOThread(this);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
// This method can run in 2 different threads. Here why:
|
||||
// 1. We are are on the I/O thread and we call IOWork().
|
||||
// 2. After step 1, it returns back to the PBackground thread.
|
||||
|
||||
// Run I/O thread tasks
|
||||
if (!IsOnBackgroundThread()) {
|
||||
|
|
|
@ -225,17 +225,6 @@ public:
|
|||
void
|
||||
HandleResult();
|
||||
|
||||
// If this task must do something on the main-thread before IOWork(), it must
|
||||
// overwrite this method. Otherwise it returns true if the FileSystem must be
|
||||
// initialized on the main-thread. It's called from the Background thread.
|
||||
virtual bool
|
||||
NeedToGoToMainThread() const;
|
||||
|
||||
// This method is called only if NeedToGoToMainThread() returns true.
|
||||
// Of course, it runs on the main-thread.
|
||||
virtual nsresult
|
||||
MainThreadWork();
|
||||
|
||||
bool
|
||||
HasError() const { return NS_FAILED(mErrorValue); }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче