/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
mozilla::ipc::PBackgroundChild* actor =
mozilla::ipc::BackgroundChild::GetOrCreateForCurrentThread(); if (NS_WARN_IF(!actor)) { // We are probably shutting down. return;
}
FileSystemTaskParentBase::FileSystemTaskParentBase(
FileSystemBase* aFileSystem, const FileSystemParams& aParam,
FileSystemRequestParent* aParent)
: Runnable("dom::FileSystemTaskParentBase"),
mErrorValue(NS_OK),
mFileSystem(aFileSystem),
mRequestParent(aParent),
mBackgroundEventTarget(GetCurrentSerialEventTarget()) {
MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
MOZ_ASSERT(aFileSystem, "aFileSystem should not be null.");
MOZ_ASSERT(aParent);
MOZ_ASSERT(mBackgroundEventTarget);
mozilla::ipc::AssertIsOnBackgroundThread();
}
FileSystemTaskParentBase::~FileSystemTaskParentBase() { // This task can be released on different threads because we dispatch it (as // runnable) to main-thread, I/O and then back to the PBackground thread.
NS_ProxyRelease("FileSystemTaskParentBase::mFileSystem",
mBackgroundEventTarget, mFileSystem.forget());
NS_ProxyRelease("FileSystemTaskParentBase::mRequestParent",
mBackgroundEventTarget, mRequestParent.forget());
}
NS_IMETHODIMP
FileSystemTaskParentBase::Run() { // 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, if we need to run some code in the main-thread, we // dispatch a runnable to this thread. // 3. The final step happens in the PBackground thread.
// If we are here, it's because the I/O work has been done, but we have // something to do on the main-thread. if (NS_IsMainThread()) {
MOZ_ASSERT(MainThreadNeeded());
nsresult rv = MainThreadWork(); if (NS_WARN_IF(NS_FAILED(rv))) {
SetError(rv);
}
// Let's go back to PBackground thread to finish the work.
rv = mBackgroundEventTarget->Dispatch(this, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv;
}
return NS_OK;
}
// Run I/O thread tasks if (!mozilla::ipc::IsOnBackgroundThread()) {
nsresult rv = IOWork(); if (NS_WARN_IF(NS_FAILED(rv))) {
SetError(rv);
}
if (MainThreadNeeded()) {
rv = GetMainThreadSerialEventTarget()->Dispatch(this, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv;
} return NS_OK;
}
// Let's go back to PBackground thread to finish the work.
rv = mBackgroundEventTarget->Dispatch(this, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv;
}
return NS_OK;
}
// If we are here, it's because the I/O work has been done and we have to // handle the result back via IPC.
mozilla::ipc::AssertIsOnBackgroundThread();
HandleResult(); return NS_OK;
}
} // namespace mozilla::dom
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.