зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1411504. P1 - always require MediaCache to have a thread to run Update() loops. r=gerald
MozReview-Commit-ID: AYVWuN9CU55 --HG-- extra : rebase_source : 0149e330533b96426bdc7817586df8bd85ec1d03 extra : source : c191b4aa350672a4b3c614a2ea5494cdcca71faf
This commit is contained in:
Родитель
a46ee955ef
Коммит
1efcf7c612
|
@ -303,7 +303,7 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest,
|
|||
// TODO: Don't turn this on until we fix all data races.
|
||||
nsCOMPtr<nsIThreadRetargetableRequest> retarget;
|
||||
if (Preferences::GetBool("media.omt_data_delivery.enabled", false) &&
|
||||
(retarget = do_QueryInterface(aRequest)) && mCacheStream.OwnerThread()) {
|
||||
(retarget = do_QueryInterface(aRequest))) {
|
||||
// Note this will not always succeed. We need to handle the case where
|
||||
// all resources sharing the same cache might run their data callbacks
|
||||
// on different threads.
|
||||
|
|
|
@ -290,18 +290,6 @@ protected:
|
|||
NS_ASSERTION(NS_IsMainThread(), "Only construct MediaCache on main thread");
|
||||
MOZ_COUNT_CTOR(MediaCache);
|
||||
MediaCacheFlusher::RegisterMediaCache(this);
|
||||
|
||||
if (!sThreadInit) {
|
||||
sThreadInit = true;
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewNamedThread("MediaCache", getter_AddRefs(thread));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to create a thread for MediaCache.");
|
||||
return;
|
||||
}
|
||||
sThread = thread.forget();
|
||||
ClearOnShutdown(this, ShutdownPhase::ShutdownThreads);
|
||||
}
|
||||
}
|
||||
|
||||
~MediaCache()
|
||||
|
@ -462,8 +450,7 @@ protected:
|
|||
// A list of resource IDs to notify about the change in suspended status.
|
||||
nsTArray<int64_t> mSuspendedStatusToNotify;
|
||||
// The thread on which we will run data callbacks from the channels.
|
||||
// Could be null if failing to create the thread. Note this thread is shared
|
||||
// among all MediaCache instances.
|
||||
// Note this thread is shared among all MediaCache instances.
|
||||
static StaticRefPtr<nsIThread> sThread;
|
||||
// True if we've tried to init sThread. Note we try once only so it is safe
|
||||
// to access sThread on all threads.
|
||||
|
@ -729,6 +716,26 @@ MediaCache::CloseStreamsForPrivateBrowsing()
|
|||
MediaCache::GetMediaCache(int64_t aContentLength)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
if (!sThreadInit) {
|
||||
sThreadInit = true;
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewNamedThread("MediaCache", getter_AddRefs(thread));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to create a thread for MediaCache.");
|
||||
return nullptr;
|
||||
}
|
||||
sThread = thread.forget();
|
||||
// Note it is safe to pass an invalid pointer for operator=(std::nullptr_t)
|
||||
// is non-virtual and it will not access |this|.
|
||||
ClearOnShutdown(reinterpret_cast<MediaCache*>(0x1),
|
||||
ShutdownPhase::ShutdownThreads);
|
||||
}
|
||||
|
||||
if (!sThread) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aContentLength > 0 &&
|
||||
aContentLength <= int64_t(MediaPrefs::MediaMemoryCacheMaxSize()) * 1024) {
|
||||
// Small-enough resource, use a new memory-backed MediaCache.
|
||||
|
|
Загрузка…
Ссылка в новой задаче