зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1418917. P1 - run some functions off the main thread. r=bechen,gerald
MozReview-Commit-ID: Fn9OveV69hX --HG-- extra : rebase_source : 36ed72bea695f07694d83c418ba45d89cf1f03be extra : intermediate-source : e25c80e8ea6991b4f06bc4305b602c792a5b1e8a extra : source : d20765cfa8575943c62b933563e36ee9ffa4e765
This commit is contained in:
Родитель
bee29ac23b
Коммит
e672887f6f
|
@ -1937,17 +1937,23 @@ void
|
||||||
MediaCacheStream::NotifyLoadID(uint32_t aLoadID)
|
MediaCacheStream::NotifyLoadID(uint32_t aLoadID)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aLoadID > 0);
|
MOZ_ASSERT(aLoadID > 0);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||||
|
"MediaCacheStream::NotifyLoadID",
|
||||||
|
[ client = RefPtr<ChannelMediaResource>(mClient), this, aLoadID ]() {
|
||||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||||
mLoadID = aLoadID;
|
mLoadID = aLoadID;
|
||||||
|
});
|
||||||
|
OwnerThread()->Dispatch(r.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaCacheStream::NotifyDataStarted(uint32_t aLoadID,
|
MediaCacheStream::NotifyDataStartedInternal(uint32_t aLoadID,
|
||||||
int64_t aOffset,
|
int64_t aOffset,
|
||||||
bool aSeekable,
|
bool aSeekable,
|
||||||
int64_t aLength)
|
int64_t aLength)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
MOZ_ASSERT(OwnerThread()->IsOnCurrentThread());
|
||||||
MOZ_ASSERT(aLoadID > 0);
|
MOZ_ASSERT(aLoadID > 0);
|
||||||
LOG("Stream %p DataStarted: %" PRId64 " aLoadID=%u aLength=%" PRId64,
|
LOG("Stream %p DataStarted: %" PRId64 " aLoadID=%u aLength=%" PRId64,
|
||||||
this,
|
this,
|
||||||
|
@ -1999,6 +2005,23 @@ MediaCacheStream::UpdatePrincipal(nsIPrincipal* aPrincipal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaCacheStream::NotifyDataStarted(uint32_t aLoadID,
|
||||||
|
int64_t aOffset,
|
||||||
|
bool aSeekable,
|
||||||
|
int64_t aLength)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
MOZ_ASSERT(aLoadID > 0);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||||
|
"MediaCacheStream::NotifyDataStarted",
|
||||||
|
[ =, client = RefPtr<ChannelMediaResource>(mClient) ]() {
|
||||||
|
NotifyDataStartedInternal(aLoadID, aOffset, aSeekable, aLength);
|
||||||
|
});
|
||||||
|
OwnerThread()->Dispatch(r.forget());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaCacheStream::NotifyDataReceived(uint32_t aLoadID,
|
MediaCacheStream::NotifyDataReceived(uint32_t aLoadID,
|
||||||
uint32_t aCount,
|
uint32_t aCount,
|
||||||
|
@ -2460,12 +2483,18 @@ MediaCacheStream::SetReadMode(ReadMode aMode)
|
||||||
void
|
void
|
||||||
MediaCacheStream::SetPlaybackRate(uint32_t aBytesPerSecond)
|
MediaCacheStream::SetPlaybackRate(uint32_t aBytesPerSecond)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(aBytesPerSecond > 0, "Zero playback rate not allowed");
|
MOZ_ASSERT(aBytesPerSecond > 0, "Zero playback rate not allowed");
|
||||||
|
|
||||||
|
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||||
|
"MediaCacheStream::SetPlaybackRate",
|
||||||
|
[ =, client = RefPtr<ChannelMediaResource>(mClient) ]() {
|
||||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||||
if (aBytesPerSecond == mPlaybackBytesPerSecond)
|
if (!mClosed && mPlaybackBytesPerSecond != aBytesPerSecond) {
|
||||||
return;
|
|
||||||
mPlaybackBytesPerSecond = aBytesPerSecond;
|
mPlaybackBytesPerSecond = aBytesPerSecond;
|
||||||
mMediaCache->QueueUpdate();
|
mMediaCache->QueueUpdate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
OwnerThread()->Dispatch(r.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -2493,12 +2522,18 @@ void
|
||||||
MediaCacheStream::ThrottleReadahead(bool bThrottle)
|
MediaCacheStream::ThrottleReadahead(bool bThrottle)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||||
|
"MediaCacheStream::ThrottleReadahead",
|
||||||
|
[ client = RefPtr<ChannelMediaResource>(mClient), this, bThrottle ]() {
|
||||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||||
if (mThrottleReadahead != bThrottle) {
|
if (!mClosed && mThrottleReadahead != bThrottle) {
|
||||||
LOGI("Stream %p ThrottleReadahead %d", this, bThrottle);
|
LOGI("Stream %p ThrottleReadahead %d", this, bThrottle);
|
||||||
mThrottleReadahead = bThrottle;
|
mThrottleReadahead = bThrottle;
|
||||||
mMediaCache->QueueUpdate();
|
mMediaCache->QueueUpdate();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
OwnerThread()->Dispatch(r.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
|
|
@ -454,6 +454,11 @@ private:
|
||||||
// waiting on the media cache monitor. Called on the main thread only.
|
// waiting on the media cache monitor. Called on the main thread only.
|
||||||
void FlushPartialBlockInternal(bool aNotify, ReentrantMonitorAutoEnter& aReentrantMonitor);
|
void FlushPartialBlockInternal(bool aNotify, ReentrantMonitorAutoEnter& aReentrantMonitor);
|
||||||
|
|
||||||
|
void NotifyDataStartedInternal(uint32_t aLoadID,
|
||||||
|
int64_t aOffset,
|
||||||
|
bool aSeekable,
|
||||||
|
int64_t aLength);
|
||||||
|
|
||||||
void NotifyDataEndedInternal(uint32_t aLoadID,
|
void NotifyDataEndedInternal(uint32_t aLoadID,
|
||||||
nsresult aStatus,
|
nsresult aStatus,
|
||||||
bool aReopenOnError);
|
bool aReopenOnError);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче