Commit Graph
138 Commits
Author SHA1 Message Date
JW Wang dfe62eef7b Bug 1404771. P2 - always access mThrottleReadahead within the lock. r=gerald
So it is easier to run Update() loops off the main thread in the future.

MozReview-Commit-ID: LdxzQf6B3GK
2017-09-20 16:37:32 +08:00
JW Wang 36f2b97d1b Bug 1404771. P1 - fix the comment of mStreamLength. r=gerald
mStreamLength is always accessed within the lock. So it is safe to read/write
mStreamLength on all threads.

MozReview-Commit-ID: 9zJ2cwRrL5L
2017-09-20 16:29:46 +08:00
JW Wang a9545320e0 Bug 1401471. P4 - always access mChannelOffset within the cache monitor. r=gerald
MozReview-Commit-ID: KIQU3PrBUj1
2017-09-20 16:23:21 +08:00
JW Wang 1e43a9509b Bug 1401471. P3 - store the seek target in StreamAction so we won't need to read mChannelOffset outside the cache monitor. r=gerald
MozReview-Commit-ID: Kkbs3WbSBVm
2017-09-20 16:20:56 +08:00
JW Wang ef1b196897 Bug 1401471. P2 - remove SEEK_AND_RESUME. r=gerald
MozReview-Commit-ID: ACdp3wVuurb
2017-09-20 16:16:07 +08:00
JW Wang 4b5f7e2ed3 Bug 1401471. P1 - make StreamAction a struct so we can associate data with each action in the future. r=gerald
MozReview-Commit-ID: A0ZpunJgNYm
2017-09-20 16:12:31 +08:00
Phil Ringnalda edbbee2be4 Backed out 4 changesets (bug 1401471) because it depends on 1401461 which is being backed out
Backed out changeset 6a2c85349226 (bug 1401471)
Backed out changeset 554875cb6a2e (bug 1401471)
Backed out changeset f871c6aa4d90 (bug 1401471)
Backed out changeset ff9dbb6a6692 (bug 1401471)

MozReview-Commit-ID: 80kxfUqbik4
2017-09-21 20:29:08 -07:00
JW Wang 9da34137ce Bug 1401471. P4 - always access mChannelOffset within the cache monitor. r=gerald
MozReview-Commit-ID: KIQU3PrBUj1
2017-09-20 16:23:21 +08:00
JW Wang fd330f77ff Bug 1401471. P3 - store the seek target in StreamAction so we won't need to read mChannelOffset outside the cache monitor. r=gerald
MozReview-Commit-ID: Kkbs3WbSBVm
2017-09-20 16:20:56 +08:00
JW Wang d51321971b Bug 1401471. P2 - remove SEEK_AND_RESUME. r=gerald
MozReview-Commit-ID: ACdp3wVuurb
2017-09-20 16:16:07 +08:00
JW Wang 2f01d87b9b Bug 1401471. P1 - make StreamAction a struct so we can associate data with each action in the future. r=gerald
MozReview-Commit-ID: A0ZpunJgNYm
2017-09-20 16:12:31 +08:00
JW Wang ac8357fd11 Bug 1400155 - early return from NotifyDataReceived() when the stream is already closed. r=gerald
See comment 3 for the detail. We can't assert !mClosed since NotifyDataReceived()
could be called after the stream is closed.

MozReview-Commit-ID: 4pTfjABdl9B
2017-09-19 15:32:54 +08:00
JW Wang a3ee1e12ce Bug 1399760. P3 - keep ID of the loading channel so we check whether the data callback is from an old channel. r=gerald
The load ID works as follows:
1. A load ID is passed to MediaCacheStream::NotifyDataStarted()
   when loading a new channel.
2. Each MediaCacheStream::NotifyDataReceived() call is also associated
   with a load ID from which the data is received.
3. If |mLoadID != aLoadID| tests to be true in NotifyDataReceived(), it means
   the data is from an old channel and should be discarded.
4. MediaCache::Update() reset mLoadID for the stream before calling
   CacheClientSeek() to prevent data from the old channel from being
   stored to the wrong position.

MozReview-Commit-ID: 9kBoublLlln
2017-09-20 11:41:08 +08:00
JW Wang f5b0fcf275 Bug 1400166. P1 - move re-initialization code to Flush() for it is confusing to call Init() twice. r=gerald
MozReview-Commit-ID: 6KolHyGkqXo
2017-09-18 10:52:17 +08:00
Andrea Marchesini d17869c26b Bug 1388125 - Move ChannelMediaResource to separate files, r=jya 2017-09-18 13:33:49 +02:00
Andrea Marchesini c3af63011a Bug 1388125 - Move FileMediaResource to separate files, r=jya 2017-09-18 13:31:08 +02:00
JW Wang 54701eeaf5 Bug 1399751. P2 - pass a block index to FindBlockForIncomingData() so it doesn't depend on mChannelOffset. r=gerald
MozReview-Commit-ID: 7VltaDyxndl
2017-09-14 10:42:54 +08:00
JW Wang aed3074c6b Bug 1399751. P1 - pass a block index to AllocateAndWriteBlock() so it doesn't depend on mChannelOffset. r=gerald
MozReview-Commit-ID: EJmxrE5X6nA
2017-09-14 10:39:06 +08:00
JW Wang e705d27dd9 Bug 1399372 - update the principal only once per OnDataAvailable() call. r=cpearce
MozReview-Commit-ID: BWyDmKglWsl
2017-08-29 17:57:00 +08:00
JW Wang 0c544831b4 Bug 1398711. P2 - write to mClosed only when the cache monitor is held. r=gerald
This fixes the data race when Seek() read mClosed off the main thread.

MozReview-Commit-ID: GO7Kk5VgVpg
2017-09-08 17:46:56 +08:00
JW Wang d8537b0d75 Bug 1395855. P1 - remove ChannelMediaResource::mOffset so we have less data race to worry about. r=cpearce
We have MediaCacheStream::mChannelOffset to keep the download positon.
We don't need 2 variables for the same purpose.

MozReview-Commit-ID: IpnEJWuA9A9
2017-09-08 15:09:37 +08:00
JW Wang 0256ee98b4 Bug 1398659. P12 - remove unused MediaCacheStream::mHasHadUpdate. r=gerald
MozReview-Commit-ID: 98Nhi924Jip
2017-09-08 15:46:53 +08:00
JW Wang 1b28e6a469 Bug 1398659. P4 - remove unused code and add some assertions. r=gerald
MozReview-Commit-ID: LRgF9qjdMXz
2017-09-05 17:39:57 +08:00
JW Wang de1a5eb96a Bug 1398659. P1 - tighten up the assertions in InitAsClone(). r=gerald
We also make it return void since it now always succeeds.

MozReview-Commit-ID: H1oQWoguEzF
2017-09-05 17:28:14 +08:00
Phil Ringnalda 24e7cdc7a4 Backed out 3 changesets (bug 1395017) for frequent failures in test_video_crossorigin.html
Backed out changeset 438657f4637d (bug 1395017)
Backed out changeset 243ef641e6c3 (bug 1395017)
Backed out changeset 78625f947f69 (bug 1395017)

MozReview-Commit-ID: DeBaUOPQrAD
2017-09-05 22:39:50 -07:00
JW Wang 7dcdf92a5a Bug 1395017. P3 - always dispatch a task to run UpdatePrincipal() even when CacheClientUpdatePrincipal() already runs in the main thread. r=cpearce
When MediaCacheStream::NotifyDataReceived() runs off the main thread,
there is no guarantee that the principal will be updated before the new
data is observable to the consumer because the principal can only be
updated on the main thread while the consumer can access the data off
the main thread.

To make the code simpler, we always dispatch a task to run UpdatePrincipal()
even when CacheClientUpdatePrincipal() already runs in the main thread.

This also avoid the deadlock because ChannelMediaResource::UpdatePrincipal()
will never run with the cache monitor held.

MozReview-Commit-ID: 9CdrJnaV0hl
2017-08-30 11:42:25 +08:00
JW Wang f7c00b8bf8 Bug 1395017. P2 - assert ResourceStreamIterator should either run in the main thread or with the lock held. r=cpearce
MozReview-Commit-ID: Jm9alyQFFtA
2017-08-30 11:26:01 +08:00
JW Wang 35b532a6f8 Bug 1395017. P1 - dispatch a task to the main thread to update the principal when necessary. r=cpearce
MozReview-Commit-ID: BWyDmKglWsl
2017-08-29 17:57:00 +08:00
JW Wang 34c9a5bf2c Bug 1394724. P4 - merge MediaCacheStream::Close() and CloseInternal(). r=cpearce
MozReview-Commit-ID: Fo43lKYPA0m
2017-08-29 16:46:42 +08:00
JW Wang 3e640e4753 Bug 1394724. P3 - fix data race in reading mClosed in MediaCacheStream::NotifyDataReceived(). r=cpearce
1. mCacheStream.Close() should happen after CloseChannel() to avoid data race
   in reading mClosed in MediaCacheStream::NotifyDataReceived().
2. MediaCache::Update() and CloseStreamsForPrivateBrowsing() should call
   ChannelMediaResource::Close() to ensure mCacheStream.Close() happens
   after CloseChannel().

MozReview-Commit-ID: 1o3yPbm3Gy6
2017-08-29 16:41:17 +08:00
JW Wang 133ce481a6 Bug 1388612. P1 - remove MediaResource::EnsureCacheUpToDate(). r=gerald
This is a workaround to fix bug 687972. It should be OK now to remove
it since we have fix bug 1108960  where MediaCache failed to run the
update loop to update the suspend status of the stream.

MozReview-Commit-ID: MbInehhScs
2017-08-09 16:07:53 +08:00
Bevis Tseng 2ecbda13e2 Bug 1378930 - Part 2: Remove the aName parameter from SchedulerGroup/DocGroup/DispatcherTrait. r=billm 2017-07-26 16:13:35 +08:00
Gerald Squelart 720d6c7dc1 Bug 1379091 - Let block cache tell MediaCache its block use limit - r=cpearce
MozReview-Commit-ID: 5ZCD3NoeYEP
2017-07-10 10:23:02 +12:00
Gerald Squelart 62866b1c74 Bug 1378518 - Use offset-to-block utilities to check MediaCache offset ranges - r=jwwang
MozReview-Commit-ID: 8IsctoABVrb
2017-07-06 15:42:56 +12:00
Gerald Squelart 94f4f33576 Bug 1378518 - Better MediaCache GetMaxBlocks() computation - r=jwwang
Retrieve pref from MediaPrefs, which is more efficient than
Preferences::GetInt().

Also refactored computations to avoid unnecessary type conversions.

MozReview-Commit-ID: Ii27lthRRNI
2017-07-06 16:12:58 +12:00
Gerald Squelart 4846c52f04 Bug 1374441 - Backed out bug 1374173 (MediaCacheStream Seek&Read refactoring) - r=jwwang
Bug 1374173 seems to be the cause of all MediaCache intermittent assertion
failures. It's not an important bug, so let's back-out and verify that
intermittents disappear.

MozReview-Commit-ID: 2X8iW1hWu99
2017-06-23 13:18:07 +12:00
Jean-Yves Avenard 88a286dcec Bug 1374596: P7. Fix includes as per coding style. r=padenot
MozReview-Commit-ID: 5WfOWcOoxg0
2017-06-20 17:56:55 +02:00
Gerald Squelart 2963b055ba Bug 1374173 - SeekInternal is only used to SEEK_SET - r=jwwang
So its code can be simplified by removing the code doing other operations.

MozReview-Commit-ID: 32g7lp2XLNE
2017-06-13 16:13:33 +12:00
Gerald Squelart 4bbfb19ea0 Bug 1374173 - Make MediaCacheStream::Seek and Read internal - r=jwwang
MozReview-Commit-ID: 9tPETuUYDrV
2017-06-13 15:57:46 +12:00
Gerald Squelart 3ed9a049d9 Bug 1371882 - Remove unneeded MediaCache::mContentLength - r=cpearce
Now that MediaCache doesn't use the content length to decide which block cache
to use, and can know it's the file-backed MediaCache (to reset the pointer,
and for telemetry purposes), we don't need to store mContentLength anymore.

MozReview-Commit-ID: KjxarKFe9WK
2017-06-15 17:32:26 +12:00
Gerald Squelart 98db6e6b8a Bug 1371882 - MemoryBlockCache is responsible for tracking the combined size of all its buffers - r=cpearce
MemoryBlockCache won't allow initializing, or growing an existing buffer,
above the limit (min of 'media.memory_caches_combined_limit_kb' or
sysmem*'media.memory_caches_combined_limit_pc_sysmem'/100).

MozReview-Commit-ID: 6MkwFp2eeth
2017-06-15 17:10:54 +12:00
Gerald Squelart fd2e395619 Bug 1371882 - Let GetMediaCache decide which block cache to use - r=cpearce
This allows a fallback to the file-backed MediaCache, if a MemoryBlockCache
could not be created and initialized (which may happen in the next patch,
where MemoryBlockCache will take care of not using more than
MediaMemoryCachesCombinedLimit).

MediaCache::Init() is not needed anymore, as its only work was to initialize
its block cache.

MozReview-Commit-ID: ItAdOPuxEvt
2017-06-15 16:32:06 +12:00
Gerald Squelart 93250d7745 Bug 1371882 - MediaCache::Flush reinitializes block cache instead of recreating it - r=cpearce
This saves from destruction&re-construction efforts, makes the flushing less
prone to first-initialization failures.
And it will allow moving the choice of block cache outside of MediaCache::Init.

MozReview-Commit-ID: 8vSunM3rRkL
2017-06-15 16:12:30 +12:00
Gerald Squelart e087bba1cc Bug 1371882 - MediaCache is now ref-counted - r=cpearce
MediaCacheStreams have owning shared pointers to their MediaCache, and
a MediaCache owns itself while an update is in flight.
A non-owning pointer `gMediaCache` is only used by GetMediaCache and
~MediaCache to manage the one file-backed MediaCache.

MozReview-Commit-ID: AQHuXWGrKt6
2017-06-15 15:02:25 +12:00
Gerald Squelart c6ecb5dcf3 Bug 1371882 - Remove MediaBlockCacheBase::Close() - r=cpearce
The only external use of Close was always followed by an implicit destruction
(by resetting the RefPtr), so we don't need to expose it, and it can be done
from the destructor.

FileBlockCache keeps its Close() function for internal use.
Also, FileBlockCache::mIsOpen is redundant, as it's true iff mThread is not
null.

MozReview-Commit-ID: LV7YVrwJvGG
2017-06-15 14:10:05 +12:00
Gerald Squelart cecb486d0c Bug 1371882 - Avoid MemoryBlockCache when combined sizes > 'media.memory_caches_combined_limit_...' - r=cpearce
Don't go over the lowest of 'media.memory_caches_combined_limit_kb'
(kilobytes) or 'media.memory_caches_combined_limit_pc_sysmem' (percents of
system memory).

Added more logging around creation/destruction of MediaCaches.

MozReview-Commit-ID: Cdz4ycyn1RR
2017-06-12 15:42:26 +12:00
Gerald Squelart 4daecb1c1d Bug 1371882 - MediaCache uses MemoryBlockCache when content length is known - r=cpearce
MozReview-Commit-ID: 35A4Vc95NtB
2017-06-09 18:56:34 +12:00
Gerald Squelart ef5f2c8386 Bug 1371882 - Rename MediaCache::mFileCache to mBlockCache - r=cpearce
Because blocks may not necessarily be held in files anymore.

MozReview-Commit-ID: 2GNc7B5w2Jt
2017-06-14 17:01:46 +12:00
Gerald Squelart cd9374e0a0 Bug 1371882 - Virtualize FileBlockCache's API into MediaBlockCacheBase - r=cpearce
MozReview-Commit-ID: Eya0RWiyiEP
2017-06-09 14:26:22 +12:00
Gerald Squelart 269d41be34 Bug 1371882 - If content length <= 'media.memory_cache_max_size', use a discrete memory-backed MediaCache - r=cpearce
MozReview-Commit-ID: HH1R6LjKkxb
2017-06-09 23:15:04 +12:00