Closed Bug 584238 Opened 14 years ago Closed 14 years ago

Add an API to clear the media cache

Categories

(Core :: Audio/Video, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b7
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: ehsan.akhgari, Assigned: roc)

References

Details

Attachments

(1 file, 1 obsolete file)

This is needed for private browsing support (see bug 572243 comment 5).
It should be noted that the depending bug 572243 has been set to block betaN.
blocking2.0: ? → betaN+
Assignee: nobody → roc
What should this API look like? Is there an observer notification that fires when we enter/leave private browsing mode? I suppose I could create an XPCOM service that exposes a single "clear media cache" API, but that would be a bit annoying.

I'm also not sure how this should affect media elements that are playing when you request the media cache to be cleared. Should they just break? Should we flush data but allow the element to put new data into the cache? Or is it OK to somehow keep around the data for those elements?
(In reply to comment #2)
> What should this API look like? Is there an observer notification that fires
> when we enter/leave private browsing mode? I suppose I could create an XPCOM
> service that exposes a single "clear media cache" API, but that would be a bit
> annoying.

Yes, the "private-browsing" topic with "enter" or "exit" as its data.  I could write the patch, I just don't know what the correct internal API to call is to empty the media cache.  If we choose to go through this route, then this bug can just be marked as a dupe of bug 572243 I think.

> I'm also not sure how this should affect media elements that are playing when
> you request the media cache to be cleared. Should they just break? Should we
> flush data but allow the element to put new data into the cache? Or is it OK to
> somehow keep around the data for those elements?

Generally, when we're leaving the private browsing mode, we close all open tabs and restore the user's old session, which means that we don't have to worry about media elements that are playing.

There are two concerns here though.  The first one is that add-ons may use media elements (possibly in their own UI) which survive the private browsing mode transitions.  The other concern is that we have a hidden pref which allows the session to remain untouched when we're exiting or entering the private browsing mode.

The latter is not something to worry about, because we don't officially support that pref, and it only exists to facilitate automated tests.  I'm not sure how to address the first concern though.
Attached patch add cache Flush() API (obsolete) — Splinter Review
Completely untested, but this should flush the cache without breaking any existing elements, even if they're currently playing.

Ehsan, I'll leave the rest of this bug in your capable hands :-)
Oh, you should probably add a call to QueueUpdate() in there.
OK, so I'm stealing this from you.
Assignee: roc → ehsan
Attachment #478191 - Flags: review?(jst)
Whiteboard: [has patch][needs review jst]
Comment on attachment 478191 [details] [diff] [review]
add cache Flush() API

Boris, is this something which you can review?
Attachment #478191 - Flags: review?(jst) → review?(bzbarsky)
Whiteboard: [has patch][needs review jst] → [has patch][needs review bz]
I was going to say that roc should, but he wrote the patch.  I can do it if really needed, but I'd be happier if someone familiar with the media cache reviewed instead.
Comment on attachment 478191 [details] [diff] [review]
add cache Flush() API

Fair enough.  I'll forward the request to Chris.  Chris, feel free to suggest other people if needed.
Attachment #478191 - Flags: review?(bzbarsky) → review?(chris)
Whiteboard: [has patch][needs review bz] → [has patch][needs review cpearce]
Comment on attachment 478191 [details] [diff] [review]
add cache Flush() API

I think Matthew has a better understanding of the media cache than I, passing it onto him.
Attachment #478191 - Flags: review?(chris) → review?(kinetik)
Whiteboard: [has patch][needs review cpearce] → [has patch][needs review kinetik]
+nsMediaCache::FlushInternal()
+{
[...]
+  PR_Close(mFD);
+  Init();
+}

What if |Init()| fails here?  |InitMediaCache()| handles this by deleting and NULLing gMediaCache, making it impossible to call nsMediaCache methods after |Init()| has failed.  In this case, |Init()| may fail silently, mFD is now bogus, and nothing prevents further nsMediaCache method calls.
We can't just null out gMediaCache since we already have nsMediaCacheStreams active which will continue calling methods on gMediaCache.

How about I set mFD to 0 if Init fails? Then all the I/O operations on mFD will return errors, but we already handle I/O errors.
Sounds good.
Attachment #482731 - Flags: review? → review?(kinetik)
Attachment #478191 - Attachment is obsolete: true
Attachment #478191 - Flags: review?(kinetik)
Attachment #482731 - Flags: review?(kinetik) → review+
Whiteboard: [has patch][needs review kinetik] → [needs landing]
http://hg.mozilla.org/mozilla-central/rev/a4ac5ee6d3d1
Assignee: ehsan → roc
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [needs landing]
Target Milestone: --- → mozilla2.0b8
Target Milestone: mozilla2.0b8 → mozilla2.0b7
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: